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:12:39 -0600
I have had this sort of experience with Guard Malloc before a few times now. What was happening was that I was using an uninitialized value as an index to an array. With Guard Malloc disabled, the initial value of the index would be something random from memory, and when out of the array's allocated bounds, would cause a crash. However, whenever I ran my software with Guard Malloc enabled, the index variable would be initialized to 0. So I think that perhaps Guard Malloc zeroes out all memory allocations? Or maybe this is just how it's happened to work out for me on a few occasions...
excellent point. I'd forgotten about that. I've had this frequently as well, when compiling on OS X and linux. For some reason, gcc on OS X was initializing things to zero, and on linux it wasn't. So, when I ran on linux, and accessed a struct in an array, on OS X the struct told me it hadn't been used (0), while on linux it contained garbage values which fired assertions. From this we can learn:
1. Pay attention to "uninitialized" warnings! (though they don't help if you're allocating dynamically) 1. Assertions are good.
Yes, I know they're both labelled '1'!
M
|
_______________________________________________
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