[cpp-threads] Issue 1369 --- thread safety of std::rethrow_exception

Howard Hinnant howard.hinnant at gmail.com
Mon Nov 15 15:33:00 GMT 2010


On Nov 15, 2010, at 8:57 AM, Anthony Williams wrote:

>> The argument for this resolution is that it appears to be the only
>> thing implementable in the Itanium ABI, which I believe is commonly
>> used on other platforms, like X86-64.  Breaking the exception ABI
>> seems like a very high cost, so I think we'd need at least a more
>> solid example of breakage than I've seen so far.
> 
> I appreciate that there is a cost. Personally, I think it's worth it: introducing data races is a serious issue.

Here is an attempt to quantify the cost:

My best estimate is that for those platforms on the Itanium ABI (which Apple is one), current_exception() and rethrow_exception() will not make a copy of the referenced exception no matter what the standard says.  And so this:

> Worse, this code may be race free when compiled with one compiler (e.g. MSVC 2010) and acquire a data race when recompiled with a different compiler (e.g. gcc).

is going to be true regardless of what we do.  The reason for me to make such a strong statement is that Apple (and I assume other platforms) regularly allow for applications and dynamic libraries to be migrated from one OS version to another without the need for recompilation.  We of course recompile our own code for new OS's, but not 3rd party dyld's and applications.

Without a recompilation, the Itanium ABI literally does not have the information to copy the exception at the point of current_exception() and rethrow_exception().

For such platforms to make such a change, I believe we would have to create two ABI's:  A C++03 ABI and a C++0x ABI, which could not be intermixed.  This would mean that an application could not move to C++0x until all of its dyld's moved, and those dyld's could not move until all of their dependent dyld's moved.  Ultimately you get down to the OS dyld's, which would all have to be supplied in both ABI's, effectively doubling the size of the OS.

I do not believe that this is a migration strategy that many platforms are going to buy into.

If platforms do not have a practical migration strategy, then they are just not going to migrate.  And then you've got another export.

That is a very high cost with little or no benefit to the end user.

-Howard




More information about the cpp-threads mailing list