This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Fix an assertion failure in FindThreadByUidLocked with recycled threads
ClosedPublic

Authored by kubamracek on Nov 25 2015, 5:23 AM.

Details

Summary

When a race on file descriptors is detected, FindThreadByUidLocked() is called to retrieve ThreadContext with a specific unique_id. However, this ThreadContext might not exist in the thread registry anymore (it may have been recycled), in which case FindThreadByUidLocked will cause an assertion failure in GetThreadLocked. Adding a test case that reproduces this, producing:

FATAL: ThreadSanitizer CHECK failed: sanitizer_common/sanitizer_thread_registry.h:92 "((tid)) < ((n_contexts_))" (0x34, 0x34)

This patch fixes this by replacing the loop with FindThreadContextLocked.

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 41133.Nov 25 2015, 5:23 AM
kubamracek retitled this revision from to [tsan] Fix an assertion failure in FindThreadByUidLocked with recycled threads.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, samsonov, glider, kcc.
dvyukov accepted this revision.Nov 26 2015, 7:45 AM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Nov 26 2015, 7:45 AM
This revision was automatically updated to reflect the committed changes.