C++ exceptions: pthread key allocation error for __gthread_key_create

Chris Johns chrisj at rtems.org
Mon Dec 5 06:57:53 UTC 2016


Hi,

Is it the user who needs to account for the gthread key if using C++?

The cdtest does not account for the key used in gcc thread support and I
suspect other C++ tests do not. A key is needed for correct exception
handling in a threaded environment.

The unfortunate side effect of not enough POSIX keys being allocated is
gcc silently switches from being thread specific exception handling to a
single global exception variable which could result in race conditions.
If a key cannot be created GCC defaults to the global variable init
(/libstdc++-v3/libsupc++/eh_globals.cc).

An error would be nice. I have raised:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78677

to see what the GCC developers think.

Chris


More information about the devel mailing list