This is an archive of the discontinued LLVM Phabricator instance.

[tsan] dispatch_once interceptor will cause a deadlock when the original dispatch_once is used
ClosedPublic

Authored by kubamracek on Jul 4 2016, 8:49 AM.

Details

Summary

Because we use SCOPED_TSAN_INTERCEPTOR in the dispatch_once interceptor, the original dispatch_once can also be sometimes called (when ignores are enabled or when thr->is_inited is false). However the original dispatch_once function doesn’t expect to find “2” in the storage and it will spin forever (but we use “2” to indicate that the initialization is already done, so no waiting is necessary). We should never call the original dispatch_once.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek updated this revision to Diff 62687.Jul 4 2016, 8:49 AM
kubamracek retitled this revision from to [tsan] dispatch_once interceptor will cause a deadlock when the original dispatch_once is used.
kubamracek updated this object.
kubamracek added reviewers: dvyukov, kcc, glider.
kubamracek added a project: Restricted Project.
kubamracek added subscribers: zaks.anna, dcoughlin.
kubamracek updated this revision to Diff 62707.Jul 4 2016, 12:39 PM

Adding a testcase. Without the patch, the test doesn’t deadlock but only crashes, so I didn’t add a timeout.

dvyukov accepted this revision.Jul 5 2016, 6:26 AM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Jul 5 2016, 6:26 AM
This revision was automatically updated to reflect the committed changes.