C++ exceptions: pthread key allocation error for __gthread_key_create

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


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

An error would be nice. I have raised:


to see what the GCC developers think.


More information about the devel mailing list