Re: gmalloc prevents a "Bus error"
Re: gmalloc prevents a "Bus error"
- Subject: Re: gmalloc prevents a "Bus error"
- From: "Corey O'Connor" <email@hidden>
- Date: Mon, 3 Oct 2005 18:22:25 -0700
On 10/3/05, Justin C. Walker <email@hidden> wrote:
>
> On Oct 3, 2005, at 15:16 , Craig Maloney wrote:
>
> > I have a situation where running code from the command line give
> > "Bus error" (I'm probably going out-of-bounds on an array), running
> > in gdb (from xcode or manually from a shell) gets a
> > "EXC_BAD_ACCESS" signal. But then if I want to turn on aggressive
> > debugging and select the "Enable Guard Malloc" option from the
> > debug menu, the error completely goes away and the program
> > terminates normally.
> >
> > Could someone explain to me in simple terms how turning on the most
> > aggressive memory checking could make the error disappear
> > altogether? Sorry if this is a bit elementary.
>
> The simplest explanation, in the absence of real data, is the classic
> "good garbage vs. bad garbage" scenario: presumably, you have
> something like an uninitialized pointer, or (as you say) aggressive
> use of indexing for array access :-}; when you change the address
> space, which I believe you do when enabling the guard malloc stuff,
> you just might get lucky in that what used to be "thin air" is now
> valid real estate. Thus, what used to be a "bad access" is now just
> access to junk.
I think Guard Malloc also adds a buffer space to each side of an
allocated block of memory. This buffer area is regularly checked to
see if it has been modified from it's initial values (Which is
probably a bunch of suitable magic values like: 0xDECAFBAD ;-) ). if
the buffer had been modified the malloc debug system should report
which memory segment the overflow occured in.
I have no idea when this check is performed though. Is it on
de-allocate? Every allocation? Just ocassianally? Or am I just
dreaming Guard Malloc works like MFCs malloc debugging feature? ;-)
In Craig's case, if Guard Malloc works like I say he should be able to
find out if he stepped beyond the range of his array easy enough.
--
-Corey O'Connor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden