Re: sscanf threadsafe
Re: sscanf threadsafe
- Subject: Re: sscanf threadsafe
- From: Joseph Kelly <email@hidden>
- Date: Tue, 23 Sep 2008 21:51:03 -0700
sscanf() is NOT "entirely" thread safe. By this I mean, it makes no
guarantees about thread safety, by virtue as you describe that it
maintains no global state, and hence has no need to implement
synchronization, nor do any of the things you can pass in to it have
any inherent say about their safety.
The fact that its arguments are const is a semantic / compile time
thing, and means nothing at runtime.
If the first argument -- the string to scan -- is shared by two
threads, they must be protected by the caller. 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.
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.
Joe K.
On Sep 23, 2008, at 1:21 PM, Chris Suter wrote:
On Wed, Sep 24, 2008 at 6:13 AM, Sean McBride <sean@rogue-
research.com> wrote:
On 9/23/08 3:41 PM, email@hidden said:
upon using Xcode 3.1 and 10.5 i see some strange behaviour of my
code
could it be the case that 'sscanf' is NOT threadsafe (anymore)?
anymore? Was it ever documented to be threadsafe? Its man page does
not contain the word 'thread'.
Why wouldn't sscanf be thread safe? It doesn't use any global state
and the strings are constant.
-- 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