Re: What to do about "clobbered by `longjmp' or `vfork'" warnings?
Re: What to do about "clobbered by `longjmp' or `vfork'" warnings?
- Subject: Re: What to do about "clobbered by `longjmp' or `vfork'" warnings?
- From: Alastair Houghton <email@hidden>
- Date: Wed, 3 Dec 2003 11:30:33 +0000
On 3 Dec 2003, at 09:56, j o a r wrote:
> In our deployment builds we get a lot of warnings like this when we use
> NS_DURING exception handlers:
>
> "variable `xxx' might be clobbered by `longjmp' or `vfork'"
>
> I don't know if the code is really broken, or if GCC is just not able
> to interpret it correctly - but I think that the blame lies with GCC. I
> also don't know of any way we can reliably warp our code so that it no
> longer generate warnings. Using the "volatile" qualifier has been
> mentioned, but is probably not the right way to solve the problem (?).
Just to explain what the warning means... when the compiler generates
code, it is free to cache non-volatile variables in registers; now,
setjmp() will save the registers when it is called, so if you write
something like
int a;
a = 5;
if (!setjmp (jmpbuf)) {
a = 7;
longjmp (jmpbuf, 1);
}
the contents of the variable "a" are undefined (it could contain either
5 or 7, depending on when [and whether] the compiler decided to store
the value in memory).
> We are also not able to move to the new style of exception handling
> introduced with Panther, as we need to build for older versions of Mac
> OS X. As I see it, we probably need to disable these warnings.
You're right that GCC is warning conservatively. That's because it's
very hard for it to tell whether there will be a problem for any given
function that calls setjmp() (for one thing, it's near impossible to
match-up setjmp() and longjmp() calls without understanding the code
and even then you might not be able to tell when the longjmp() will
actually happen [e.g. if it's triggered from a signal handler]).
Having said that, you should probably fix your code; you don't
necessarily have to declare your variables volatile... it's normally
enough just to change their scope.
Kind regards,
Alastair.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.