[comp.sys.mac.programmer] Why am I getting bus-error in think C debugger?

bach@vax1.acs.udel.EDU (Baskaran Subramaniam) (11/19/90)

I am new to programming in Think C.  Could someone tell me what a bus-error
means?  When I try to step through a test program (which runs without
giving any error outside the debugger) I get a bus-error. Why?     

Thanks

Baskaran.

stevec@Apple.COM (Steve Christensen) (11/20/90)

bach@vax1.udel.edu (Baskaran Subramaniam) writes:
>I am new to programming in Think C.  Could someone tell me what a bus-error
>means?  When I try to step through a test program (which runs without
>giving any error outside the debugger) I get a bus-error. Why?     

You get a bus error when a program references an "unused" address, i.e., one
that doesn't contain RAM, ROM, or an I/O device.  You may have an uninitialized
pointer or handle somewhere.  Or perhaps you're not checking that a returned
handle or pointer is valid before you use it.  just a guess...

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  whoami?     Steve Christensen
  snail:      Apple Computer, 20525 Mariani Ave, MS-81CS, Cupertino, CA 95035
  internet:   stevec@apple.com
  AppleLink:  stevec
  CompuServe: 76174,1712

Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) (11/20/90)

bach@vax1.acs.udel.EDU (Baskaran Subramaniam) writes:

> I am new to programming in Think C.  Could someone tell me what a bus-error
> means?  When I try to step through a test program (which runs without
> giving any error outside the debugger) I get a bus-error. Why?

Bus error means trying to read or write something from an address
without real memory. Your probobly trying to look at something
that referenced by pointer before the pointer is initialized.

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker
Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org

CAH0@bunny.gte.com (Chuck Hoffman) (11/20/90)

In article <7022@vax1.acs.udel.EDU> bach@vax1.acs.udel.EDU (Baskaran 
Subramaniam) writes:
> Could someone tell me what a bus-error
> means?  When I try to step through a test program (which runs without
> giving any error outside the debugger) I get a bus-error. Why?

Could be that you trying to open a resource which is not visible to the 
debugger.  The debugger assembles code and puts it into the project file, 
named something like name.pi, where pi is the Greek character you get with 
option-p.  If you have other resources, they must be put into 
name.pi.rsrc (not name.rsrc); the naming convention is rigid.
If the resource is 
somewhere else, you will get a bus error before you can check for a good 
handle.  You also can get bus errors if you mix stdio calls, like printf, 
with QuickDraw routines, like DrawString.  Good luck.  I'm new, too, and 
the bus error problems were very frustrating.


- Chuck Hoffman, GTE Laboratories, Inc.  |  I'm not sure why we're here,
cah0@bunny.gte.com                       |  but I am sure that while we're
Telephone (U.S.A.) 617-466-2131          |  here, we're supposed to help
GTE VoiceNet: 679-2131                   |  each other.
GTE Telemail: C.HOFFMAN                  |

peltz@cerl.uiuc.edu (Steve Peltz) (11/28/90)

In article <7022@vax1.acs.udel.EDU> bach@vax1.udel.edu (Baskaran Subramaniam) writes:
>I am new to programming in Think C.  Could someone tell me what a bus-error
>means?  When I try to step through a test program (which runs without
>giving any error outside the debugger) I get a bus-error. Why?     

If it doesn't give any errors outside the debugger, then it is unlikely to
be a problem with resources not being found or invalid pointers (though still
possible). One guess, though. Are you using Macsbug?

Trying to use a newer version of Macsbug than what came with THINK C 3.0 didn't
work when using the THINK C Debugger. I forget the details, but either tracing
or breakpoints would trap out to Macsbug rather than the THINK C Debugger. No
such problems when using the version that came with it (Macsbug 5.4, I believe,
that plots a fractal if run as an application).
--
Steve Peltz
Internet: peltz@cerl.uiuc.edu	PLATO/NovaNET: peltz/s/cerl