Re: sscanf threadsafe
Re: sscanf threadsafe
- Subject: Re: sscanf threadsafe
- From: "Chris Suter" <email@hidden>
- Date: Wed, 24 Sep 2008 16:08:23 +1000
Hi Joe,
On Wed, Sep 24, 2008 at 2:51 PM, Joseph Kelly <email@hidden> wrote:
> The fact that its arguments are const is a semantic / compile time thing,
> and means nothing at runtime.
You try changing a c string literal at runtime and then tell me it
means nothing. :-)
$ cat | gcc -x c - -o test -W -Wall ; ./test
int main () {
char *x = "1234";
x[2] = 1;
return 0;
}
Bus error
> If the first argument -- the string to scan -- is shared by two threads,
> they must be protected by the caller.
Why? You're just reading it.
> Same could be said of the second
> argument, but typically this would be a true constant. Likewise, if any of
> the pointers you pass in as variable args point at members of a structure
> shared between threads, this structure would need to be protected.
Eh? Obviously sscanf can't protect things it doesn't know about.
> What I suspect is happening is the switch from 10.4 to 10.5 has revealed a
> latent thread bug in the code. I'm fairly certain that 10.5 has slightly
> different timing/scheduling characteristics than its predecessor.
But there aren't any threads involved. Have a look at the source; it's
open source.
Send me a code sample (privately). This really is off-topic for the
Xcode users list.
-- Chris
_______________________________________________
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