Think C: Troubleshooting Bus Errors



I'm programming with Think C on a Macintosh IIci. When I try to run a Menu
Management program, I get a bus error.

The source debugger that comes with Think C says that it's running into a bus
error at address 0x81BBAE. A bus error implies a hardware problem, since it's
trying to access memory that it doesn't have, and it is not wrapping around to
pick up the unused memory. The program seems to be initializing the windows OK
but crashes just before it creates the menu bar.

Can you help?

Actually, a bus error does not mean that you are having a hardware problem.

One of the most common causes of a bus error is a word or long word instruction
being executed on an odd address. Another common cause is a program accessing
an address in the range of addresses belonging to NuBus. Usually, the slot
owning this address will not have a card in it.

Check the calls being made to the Menu Manager -- if you suspect these calls.
Specifically, passing an invalid handle to one of the calls could definitely
cause this error.

Try stepping through the code using the debugger and the variable watcher.
Find the exact point where the error occurs and work your way back until
you find the culprit.


Published Date: Feb 18, 2012