Re: Booleans not being set
Re: Booleans not being set
- Subject: Re: Booleans not being set
- From: Howard Moon <email@hidden>
- Date: Mon, 9 Feb 2009 08:54:01 -0800
The return value changing after returning from a function could
indicate a corrupted stack.
I notice you're passing a char*. One easy way to corrupt the stack
and cause "all kinds of weird behavior" is if you write beyond that
char* buffer's allocated endpoint. An easy test for this would be to
comment out all the code that deals with this buffer, and step
through to see if you still get that behavior.
You say it "works perfectly" on Intel machines and in 10.5, but there
could still be a bug. Perhaps you're always overwriting the alloted
buffer, but it's only causing a problem in that one case, due to the
way your memory is being laid out. Perhaps in 10.5 and in Intel
machines, the place you're writing to beyond the buffer just isn't
important at that time, but in your 10.4ppc tests, it is.
This kind of error is difficult to find by debugging, but keep
looking. I'm pretty sure the problem is there in your code.
-Howard
On Feb 7, 2009, at 1:43 AM, Erg Consultant wrote:
I have a simple C routine which looks roughly like this:
Boolean IsOnline( char *host, Boolean checkConnection )
{
Boolean result = false;
// 10 other locals here..
// Do some network stuff....
return result;
}
I am using Xcode 2.5. The code works fine on 10.5/10.4 on Intel
machines and 10.5 on PowerPC machines. However, when I run this
code on 10.4.11/PowerPC, I get all kinds of weird behavior. This
routine returns true no matter what I do - even if the network
cable is unplugged and there is no net connection. Even when my
return code is set to false it still returns true. I step through
it in the debugger and result is always set to YES even on the
first line. Futhermore, many of my locals don't show up at all in
the debugger or the debugger doesn't execute their assignments on
entry to the routine. Some it does, some it skips. The logic in the
routine works because I've tested it on all the other machines
mentioned and it works perfectly. I have turned off all
optimizations and am using the Debug configuration. I've also
turned on full symbols.
I'd like to know why this is happening as a routine returning true
even when I set the return value to false is not the way code nor a
compiler should behave.
Thanks.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40antarestech.com
This email sent to email@hidden
_______________________________________________
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