[cpp-threads] Issue 1369 --- thread safety of std::rethrow_exception
N.M. Maclaren
nmm1 at cam.ac.uk
Fri Nov 12 12:18:22 GMT 2010
On Nov 12 2010, Anthony Williams wrote:
>
>I am very much concerned about the proposed resolution of this issue.
>Prior to the introduction of std::exception_ptr it was never possible to
>transfer exceptions between threads, and thread safety of exception
>types was not an issue.
It's FAR more serious than what is nowadays called 'thread safety'!
>With the introduction of exception_ptr and rethrow_exception, it is
>possible to transfer exceptions between threads. In itself, this is a
>good thing. However, exceptions are not local. The code that handles the
>exception may not know that this is an exception that has been transferred.
That's horrific! It is also a stake through the coffin (not just a nail)
of any implementation that attempts to support system-generated exceptions
as C++ exceptions, or even the cleanup of any system state during handlers.
The point is that genuine exceptions often include thread-specific data,
often of a form that CANNOT be transferred between threads.
C++ doesn't support resumption, which is something that REALLY can't be
done if you pass exceptions between threads, but what about cleanup of
(say) attached GPUs? I am involved with a course where the students are
being taught to use GPUs from C++, so it's a real-life problem. Passing
exceptions between threads is a classic no-no - when I queried it at some
WG21 meeting, I was told that it had been positively decided against.
Please rethink. Forbidding that practice is the only sane solution.
Regards,
Nick Maclaren.
More information about the cpp-threads
mailing list