B3D models crashing MiniB3D

BlitzMax Forums/MiniB3D Module/B3D models crashing MiniB3D

jtfrench(Posted 2011) [#1]
Hi,

I'm encountering an odd crash when loading certain .b3d models into my MiniB3D-based game. The models themselves appear to render fine, but after being loaded in the 3D scene for a few seconds they eventually cause the program to crash. This sometimes happens after trying to "orbit" the scene using mouse picking, but also occurs when just leaving the model loaded into the scene.

The model export path we're currently using is taking models in .x format, opening them in Fragmotion and exporting to B3D.

Below is an example of a stack trace we would get when the error occurred while orbiting the scene:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000020f1bdbc
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.toscaledesign.wip         	0x00065f8f MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 255
1   com.toscaledesign.wip         	0x000660d1 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 577
2   com.toscaledesign.wip         	0x000660d1 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 577
3   com.toscaledesign.wip         	0x00066118 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 648
4   com.toscaledesign.wip         	0x00066118 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 648
5   com.toscaledesign.wip         	0x00066118 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 648
6   com.toscaledesign.wip         	0x00066118 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 648
7   com.toscaledesign.wip         	0x00066118 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 648
8   com.toscaledesign.wip         	0x000660d1 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 577
9   com.toscaledesign.wip         	0x000660d1 MeshCollider::collide(Box const&, Line const&, float, Transform const&, Collision*, MeshCollider::Node*) + 577
10  com.toscaledesign.wip         	0x000672a0 MeshCollider::collide(Line const&, float, Transform const&, Collision*) + 1472
11  com.toscaledesign.wip         	0x0006b4d8 hitTest(Line const&, float, Transform const&, MeshCollider*, int, Collision*, CollisionInfo&) + 1816
12  com.toscaledesign.wip         	0x0006b53d C_Pick + 77
13  com.toscaledesign.wip         	0x0005c992 6947 + 59
14  com.toscaledesign.wip         	0x0005bfab _sidesign_minib3d_TPick_CameraPick + 288
15  com.toscaledesign.wip         	0x000636a6 sidesign_minib3d_CameraPick + 32
16  com.toscaledesign.wip         	0x000131f8 3034 + 108
17  com.toscaledesign.wip         	0x00005aec 1514 + 10
18  com.toscaledesign.wip         	0x00003d68 74 + 73
19  com.toscaledesign.wip         	0x00003430 135 + 76
20  com.toscaledesign.wip         	0x00002d4a 4 + 20
21  com.toscaledesign.wip         	0x00002e7e run + 78
22  com.apple.Foundation          	0x94e0a4df _nsnote_callback + 176
23  com.apple.CoreFoundation      	0x99629793 __CFXNotificationPost + 947
24  com.apple.CoreFoundation      	0x9962919a _CFXNotificationPostNotification + 186
25  com.apple.Foundation          	0x94dff384 -[NSNotificationCenter postNotificationName:object:userInfo:] + 128
26  com.apple.Foundation          	0x94e0c789 -[NSNotificationCenter postNotificationName:object:] + 56
27  com.apple.AppKit              	0x907f7422 -[NSApplication _postDidFinishNotification] + 125
28  com.apple.AppKit              	0x907f7332 -[NSApplication _sendFinishLaunchingNotification] + 74
29  com.apple.AppKit              	0x9094e4ed -[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 274
30  com.apple.AppKit              	0x9094e10d -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 101
31  com.apple.Foundation          	0x94e3f7a4 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 511
32  com.apple.Foundation          	0x94e3f568 _NSAppleEventManagerGenericHandler + 228
33  com.apple.AE                  	0x9244cf58 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 166
34  com.apple.AE                  	0x9244ce57 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 43
35  com.apple.AE                  	0x9244cd61 aeProcessAppleEvent + 197
36  com.apple.HIToolbox           	0x95d40389 AEProcessAppleEvent + 50
37  com.apple.AppKit              	0x907c79ca _DPSNextEvent + 1420
38  com.apple.AppKit              	0x907c6fce -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
39  com.apple.AppKit              	0x90789247 -[NSApplication run] + 821
40  com.toscaledesign.wip         	0x000033a7 main + 999
41  com.toscaledesign.wip         	0x00002b7d _start + 208
42  com.toscaledesign.wip         	0x00002aac start + 40


Any ideas?

Thanks,
Jason


AdamRedwoods(Posted 2011) [#2]
Not sure. The stack looks like it's running through the collision tree.
Check TCollision.bmx to make sure you're passing valid data to the functions.


Warner(Posted 2011) [#3]
I noticed in TPick.bmx, there is something peculiar. It looks as if there is a bunch of vector objects created each time the function is called. However, I cannot find a place where they are released/freed.

Maybe it is causing a memory leak?


jtfrench(Posted 2011) [#4]
Interesting idea. If this were the case though, wouldn't everyone's minib3d apps start crashing after running long enough?

@AdamRedwoods:
Are you suggesting that bad data is being passed to the collision functions, causing the program to abort?


Warner(Posted 2011) [#5]
I think you could best first try to force the bug to appear in a separate example. Try loading the asserting model, placing it in view, then using CameraPick or LinePick in a For..Next loop very often. It is much easier to trace the bug if you could somehow isolate it in a small testing program.
Then, exclude a few lines in TPick.bmx or TCollision.bmx that you think are responsible for this. If that helps, restore some of the lines you removed. Using that method, you should be able to isolate what part of the program is causing the error.