summaryrefslogtreecommitdiff
path: root/src/thread/pthread_rwlockattr_destroy.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-09-17 23:33:03 -0400
committerRich Felker <dalias@aerifal.cx>2018-09-18 11:44:27 -0400
commit84d061d5a31c9c773e29e1e2b1ffe8cb9557bc58 (patch)
tree0a6fa37b96ab804138d55c3da37f2dfe44420d90 /src/thread/pthread_rwlockattr_destroy.c
parent0db393d3a77bb9f300a356c6a5484fc2dddb161d (diff)
downloadmusl-84d061d5a31c9c773e29e1e2b1ffe8cb9557bc58.tar.gz
fix deletion of pthread tsd keys that still have non-null values stored
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.
Diffstat (limited to 'src/thread/pthread_rwlockattr_destroy.c')
0 files changed, 0 insertions, 0 deletions