Re: The bug where terminal and xcode ran "different"
Re: The bug where terminal and xcode ran "different"
- Subject: Re: The bug where terminal and xcode ran "different"
- From: "Theodore H. Smith" <email@hidden>
- Date: Sat, 10 Feb 2007 21:45:30 +0000
On 10 Feb 2007, at 21:37, Rick Altherr wrote:
On Feb 10, 2007, at 1:12 PM, Theodore H. Smith wrote:
I finally figured out the bug.
Xcode was using a different kind of malloc that would fill my data
with certain values that somehow allowed my code to work properly.
Running my app from the terminal used a different version of
malloc that used some garbage values.
Obviously, this is an error in my app. A classic memory management
error :( Shame, I really hate those things. But they are
unavoidable when you are writing high performance stuff, because
in these cases you can't rely on vectors or other easy stuff to
"do the right thing", speedwise.
Anyhow, I did solve this problem. The answer to my question was
that Xcode was linking to a different version of malloc.
No bug in Xcode, just a bug in my code that the terminal
(strangely) was better at uncovering.
If you didn't zero out the memory you got from malloc(), then
expect it to always be some form of garbage. When you run under
gdb, things can happen in a slightly different order and cause
different garbage to be in place than when you run normally.
Different optimization levels can also cause slightly different
behaviors since at higher optimization levels, more things will be
in registers rather than memory and the garbage values will be
different.
I've solved the problem anyhow. I'm now using my own function,
sentialloc, which always fills it with garbage during debug builds.
Whether or not malloc garbaged it or not. It's using the good old
deadbeef code :)
Of course for release, it's not deadbeef anymore, and sentialloc is
just a define for malloc.
This will assure I'm getting consistant behaviour across terminal and
Xcode environments, which is a plus in my mind.
40 years on and we are still getting basic memory management issues,
what a shame.
_______________________________________________
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