Howto debug segmentation faults and bus errors

Micah

Registered
I have an application (series of) that I compile with NO ERRORs =) and the end exes ends up giving me a Segmentation fault or a bus error...

Then the "Send error to Apple" shows up with something like this:
Code:
Date/Time:      2005-08-06 21:46:32.552 -0500
OS Version:     10.4.2 (Build 8C46)
Report Version: 3

Command: walktest
Path:    ./walktest.app/Contents/MacOS/walktest
Parent:  bash [1617]

Version:        0.99 (0)
Build Version:  ???
Project Name:   walktest
Source Version: ???

PID:    29697
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0xffffffff

Thread 0 Crashed:
0   frustvis.csbundle 	0x106c7c70 csRef<iShadowCaster>::operator=(iShadowCaster*) + 88 (ref.h:234)
1   frustvis.csbundle 	0x1069e4ec csFrustumVis::RegisterVisObject(iVisibilityObject*) + 704 (frustvis.cpp:262)
2   engine.csbundle   	0x0525e940 csSector::RegisterEntireMeshToCuller(iMeshWrapper*) + 212 (sector.cpp:164)
3   engine.csbundle   	0x0525f1cc csSector::SetVisibilityCullerPlugin(char const*, iDocumentNode*) + 704 (sector.cpp:267)
4   engine.csbundle   	0x0525cc30 csSector::GetVisibilityCuller() + 116 (sector.cpp:279)
5   engine.csbundle   	0x0521f578 csEngine::PrecacheDraw(iRegion*) + 1048 (engine.cpp:1804)
6   walktest          	0x0002f2b8 WalkTest::Initialize(int, char const* const*, char const*) + 8896 (walktest.cpp:1331)
7   walktest          	0x000301a0 main + 100 (walktest.cpp:1483)
8   walktest          	0x000026ac _start + 348 (crt.c:272)
9   walktest          	0x0000254c start + 60

Thread 1:
0   libSystem.B.dylib 	0x9002ca98 semaphore_wait_signal_trap + 8
1   libSystem.B.dylib 	0x9003127c pthread_cond_wait + 508
2   csjpgimg.csbundle 	0x0b46f1b4 csPosixCondition::Wait(csMutex*, unsigned) + 572 (cspthrd.cpp:322)
3   csjpgimg.csbundle 	0x0b46c124 csThreadJobQueue::QueueRunnable::Run() + 172 (threadjobqueue.cpp:181)
4   csjpgimg.csbundle 	0x0b46fcf4 csPosixThread::ThreadRun(void*) + 80 (cspthrd.cpp:480)
5   libSystem.B.dylib 	0x9002c3d4 _pthread_body + 96

Thread 0 crashed with PPC Thread State 64:
  srr0: 0x00000000106c7c70 srr1: 0x000000000200f030                        vrsave: 0x0000000000000000
    cr: 0x44000248          xer: 0x0000000000000004   lr: 0x000000001069e4ec  ctr: 0x000000000526adf0
    r0: 0x00000000ffffffff   r1: 0x00000000bffff220   r2: 0x00000000ffffffff   r3: 0x00000000105e1400
    r4: 0x00000000ffffffff   r5: 0x00000000108a7d30   r6: 0x00000000ffffffff   r7: 0x0000000000000000
    r8: 0x0000000000000003   r9: 0x000000000fbdf0d0  r10: 0x0000000010601c22  r11: 0x00000000105e10b0
   r12: 0x000000000526adf0  r13: 0x0000000000000000  r14: 0x0000000000000000  r15: 0x0000000000000000
   r16: 0x0000000000000000  r17: 0x0000000000000000  r18: 0x0000000000000000  r19: 0x0000000000000000
   r20: 0x0000000000000000  r21: 0x0000000000000000  r22: 0x0000000000000000  r23: 0x0000000000000000
   r24: 0x000000000000000a  r25: 0x00000000000e7908  r26: 0x000000000fbc1d78  r27: 0x00000000000b9abc
   r28: 0x000000001069e22c  r29: 0x00000000105e1400  r30: 0x00000000bffff220  r31: 0x000000001069e244

How do I begin to debug this? I also have the EXACT code running on another PPC and it's working fine. (Only difference is Desktop/Laptop and OS X Versions (10.3.9/10.4.x))
 
Use the debugger? There are major difference between 10.3.X and 10.4.X, make sure you're using code only compatible with 10.3.X if you're attempting to run it on both OS's.
 
lol - use the debugger - I don't know how that works in Mac OS X, but it's a place to start =) (didn't think it'd be that easy)

And the same code compiles and works fine in 10.3.9 (same code base)
 
If you're using Xcode to compile your program, and you have the project files on the computer that is crashing, go to Debug -> Debug Executable, and that will start the debugger and show you where your program crashes.
 
hmm... I've been using ./configure make combo from a terminal, maybe I need to put it into Xcode and test - Thanks! I'll see what I can Do! =)
 
If it is from the terminal, you can just run gdb straight from the command-line. Loads of information on the net on how to use gdb from the command-line.
 
Back
Top