$Id: index.xml 1445 2006-05-04 21:57:43Z slamb $
POSIX thread cancellation (a.k.a. pthread cancellation) is a fairly new feature that so far is implemented extremely badly in most systems. These are a bunch of test programs I've written for checking behavior on different systems and submitting bug reports.
Please note that I'm not sure about all of these tests, so it's possible a platform may have correct behavior and still fail a test. But these test for the behavior my software currently expects. If you disagree with a test, please let me know.
These are all the platforms I have tested to date:
- Linux + NPTL: I used CentOS 4.2 with kernel-smp-2.6.9-22.0.2.EL and glibc-2.3.4-2.13. (Older glibc releases do not fare as well.)
- LinuxThreads: I tested with the same CentOS 4.2 system with LD_ASSUME_KERNEL=2.4.1 set in the test programs' environment.
- OS X: I tested OS X 10.3.2 Panther.
- HP Tru64 (a.k.a OSF/1, a.k.a Digital UNIX): I used version 5.1B on one of HP's test drive systems.
- HP-UX: I used 11.23 on another HP test drive system.
- FreeBSD: I used 5.1 on another HP test drive system (alpha).
- Solaris: I used Solaris 9 on SPARC with the SUNWspro compiler suite.
- cygwin: I used cygwin 1.5.7-1 on Windows 2000
|test||Linux + NPTL||LinuxThreads||OS X||Digital Tru64||HP-UX||FreeBSD||Solaris||cygwin|
|This basic behavior is absolutely mandated by the Single UNIX Specification version 3. it should pass on every platform.|
|These are not required by any specification, but are necessary to pass for usable C++ support. C++ should be the language of choice for using thread cancellation, since most code uses exception safety patterns that make cancellation safety trivial.|
|These are loosely described by the standards. For code to be able to receive both cancellation requests and signals safely, it should implement kqueue() or pass at least one of these tests.|
|The behavior here is not mentioned by the Single UNIX Specification version 3. It is useful for writing cancelable exception-safe C++ code around non-cancelable C libraries such as OpenSSL. See my atoms code for a thorough example.|
|Mandatory cancellation points|
|The Single UNIX Specification version 3 specifies a number of mandatory cancellation points; essentially every standardized blocking system call, as it is not possible to use cancellation well without support in these calls.|
 - Previous versions failed this test.
 - It would be very surprising if this failed, given that this platform does not implement cancellation requests as C++ exceptions.
 - This test sometimes passes; the platform contains a race condition.
 - This test requires a feature which is not implemented on this platform.
 - The write() test on OS X passes, but this is almost certainly a false report caused by the test_cancellation_enable failure.
 - Solaris with the -mt compiler option appears to invoke C++ destructors but not catch clauses.
 - Solaris/sparc fails to compensate for the stack growing down, but this is easily worked around.
 - FreeBSD returns error from getcontext(), before I do anything interesting with cancellation. It appears the ucontext functions are totally broken on FreeBSD/alpha.
Don't use thread cancellation. It doesn't work, and it isn't likely to any time soon. If you need a thread cancellation mechanism, I recommend implementing one with sigsafe rather than using the (poorly) standardized mechanism.
You can download the entire suite of tests here: cancellation-tests-0.1.0.tar.gz.