Subj : Re: I write a multithread program with pthread, and meet a program To : comp.programming.threads From : David Butenhof Date : Tue Apr 19 2005 07:32 pm Giancarlo Niccolai wrote: > Loic Domaigne wrote: > >>It's only a theory at that point... But it looks like a bug in the >>libstdc++ or the libpthread, when a thread is being cancelled while >>writting on cout. >> > Uhm, AFAIK write() system call is a cancellation point, and cout << is > supposed to write somewhere. So it *ought* to be a cancellation point > unless posix or c++ standards states otherwise. There is not any statement > in this sense to may knowledge, but I may be outdated... There is no standard anywhere that says whether cout operations shall or shall not be cancellation points, because POSIX doesn't talk about C++ and C++ doesn't talk about threads. This is completely open and unspecified. Any assumptions about this sort of issue is completely nonstandard and nonportable. The problem is that a C++ library that's not written with consideration for the fact that it might be running in a threaded process is that write() IS a cancellation point (on a conforming POSIX system) unless the caller disables cancelability around it. So this may well be what's happening. Whether it's a "bug" in C++ or just a fact of life you need to survive depends on the intent of the C++ developers with respect to thread compatibility. That is, they may intend that you disable cancelability around any area of code that might do this; and while you can argue which makes most sense there's no objective authority to say they're wrong. -- Dave Butenhof, David.Butenhof@hp.com HP Utility Pricing software, POSIX thread consultant Manageability Solutions Lab (MSL), Hewlett-Packard Company 110 Spit Brook Road, ZK2/3-Q18, Nashua, NH 03062 .