We have a couple of bugs that show system libraries on linux have a
nasty habit of destroying the first TLS key, even if they don't own it.
This is due to using uninitialized global variables (which default to
zero). Rather than expose ourselves to the blame for such bugs,
let's just leak the key.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
#else
Bool success = pthread_key_create(&newKey,
&VThreadBaseSafeDeleteTLS) == 0;
+ if (success && newKey == 0) {
+ /*
+ * Leak TLS key 0. System libraries have a habit of destroying
+ * it. See bugs 702818 and 773420.
+ */
+
+ success = pthread_key_create(&newKey,
+ &VThreadBaseSafeDeleteTLS) == 0;
+ }
ASSERT_NOT_IMPLEMENTED(success);
#endif