Re: gmalloc prevents a "Bus error"
Re: gmalloc prevents a "Bus error"
- Subject: Re: gmalloc prevents a "Bus error"
- From: Markian Hlynka <email@hidden>
- Date: Wed, 5 Oct 2005 12:03:45 -0600
Hi, Craig.
Just to add my two cents, everyone else is quite right, AFAIK. If
you're getting a bus error, as opposed to a segmentation fault,
you're probably accessing an address that doesn't physically exist,
though it could also me a byte alignment issue. In contrast, a
segfault is when your process tries to access memory not allocated to
it (ie outside its segment). Thus, if you segfault, you probably have
a valid address, but it doesn't belong to you. For a bus error, your
address is just plain bad. ;-) That said, I think people were correct
in saying that guardmalloc is changing the allocation structure, thus
no error. So, I'm not 100% sure why you get a bus error and not a
segfault. If I had to hazard a guess, It would be that the memory
page you asked for is not allocated, and thus the bus error. I think
that if the memory page were allocated by another process, then you'd
get a segfault. With guard malloc, extra guard pages will be
allocated, and so it goes away (the memory now being allocated _and
yours).
How close can you pin down where this is occurring? I hate this kind
of error, and it has led me to program with an abundance of
assertions! So, if you can narrow it down, then you'll probably find
it fairly soon. Consider this a good thing. Far more insidious is the
memory error which does not produce one of these faults, but instead
overwrites memory which is allocated and valid (or was until you
wrote over it!). I will make a follow-up post about this...
Markian
On Oct 3, 2005, at 16:16, Craig Maloney wrote:
Hi all.
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.
Thanks,
Craig
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40cs.ualberta.ca
This email sent to email@hidden
----
Early to bed and early to rise, makes a man stupid and blind in the
eyes.
--Mazer Rackham
_______________________________________________
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