Libc thread cancelation safety?

Florian Weimer fw@deneb.enyo.de
Fri Mar 20 20:10:00 GMT 2009


* Dean Anderson:

> I have noticed that printf in glibc (glibc 2.3.5, i386) is not pthread
> cancellation safe, though printf on Solaris is cancellation safe.  
> Specifically, canceling a thread in printf leads to deadlock.
>
> What should one expect regarding cancelation safety in standard
> libraries?  Is this a bug in glibc?

Asynchronous cancellation is inherently unsafe.  I can't find a full
list of functions which may be called from a thread which is subject
to asynchronous cancellation right now, but it is undoubtly very short
and does not include anything which touches the heap or uses the stdio
I/O facilities.  Most bare system calls (read, write, close, pipe)
should be fine, though.



More information about the Gcc-help mailing list