Re: Anything I should know about thread safety and fprintf?
Re: Anything I should know about thread safety and fprintf?
- Subject: Re: Anything I should know about thread safety and fprintf?
- From: Jonas Maebe <email@hidden>
- Date: Wed, 23 Jan 2008 21:01:16 +0100
On 23 Jan 2008, at 20:48, Jonathan del Strother wrote:
I keep running into an apparent deadlock within fprintf. I can
semi-reliably reproduce it within my application, but have been
totally unable to reduce the problem to a smaller test case.
In a nutshell, I have two threads calling this -
fprintf(stderr, "%s:%d - %s\n", [fileBaseName
cStringUsingEncoding:NSASCIIStringEncoding], lineNumber,
[formattedMessage cStringUsingEncoding:NSASCIIStringEncoding]);
resulting in the following stack trace. The first thread just sits in
write$NOCANCEL$UNIX2003() for ever.
Do you change stderr to point somewhere specific, and if not, do you
pipe the output of your program to some other program? (e.g. a pipe
has a buffer of 4KB and once it is full, your program will block
writing until the other side empties the pipe). Also, if this is a GUI
app (or a daemon?), the stderr stuff may go by default to the console
or system log, filling up some disk (although I assume that's unlikely
in this case).
Anyway, the problem you have is most likely not caused by fprintf not
being thread safe, but by the write operation blocking for some reason.
Jonas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden