summaryrefslogtreecommitdiff
path: root/src/thread/pthread_key_delete.c
AgeCommit message (Collapse)AuthorLines
2018-09-18fix deletion of pthread tsd keys that still have non-null values storedRich Felker-0/+14
per POSIX, deletion of a key for which some threads still have values stored is permitted, and newly created keys must initially hold the null value in all threads. these properties were not met by our implementation; if a key was deleted with values left and a new key was created in the same slot, the old values were still visible. moreover, due to lack of any synchronization in pthread_key_delete, there was a TOCTOU race whereby a concurrent pthread_exit could attempt to call a null destructor pointer for the newly orphaned value. this commit introduces a solution based on __synccall, stopping the world to zero out the values for deleted keys, but only does so lazily when all key slots have been exhausted. pthread_key_delete is split off into a separate translation unit so that static-linked programs which only create keys but never delete them will not pull in the __synccall machinery. a global rwlock is added to synchronize creation and deletion of keys with dtor execution. since the dtor execution loop now has to release and retake the lock around its call to each dtor, checks are made not to call the nodtor dummy function for keys which lack a dtor.
2011-04-03simplify pthread tsd key handlingRich Felker-7/+0
2011-03-31simplify pthread_key_deleteRich Felker-1/+1
calling this function on an uninitialized key value is UB, so there is no need to check that the table pointer was initialized.
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+7