This is an archive of the discontinued LLVM Phabricator instance.

[XRay][compiler-rt] Refactor recursion guard for Basic and FDR Mode
ClosedPublic

Authored by dberris on Jun 3 2018, 11:06 PM.

Details

Summary

This change extracts the recursion guard implementation from FDR Mode
and updates it to do the following:

  • Do the atomic operation correctly to be signal-handler safe.
  • Make it usable in both FDR and Basic Modes.

Before this change, the recursion guard relied on an unsynchronised read
and write on a volatile thread-local. A signal handler could then run in
between the read and the write, and then be able to run instrumented
code as part of the signal handling. Using an atomic exchange instead
fixes that by doing a proper mutual exclusion even in the presence of
signal handling.

Event Timeline

dberris created this revision.Jun 3 2018, 11:06 PM
dberris updated this revision to Diff 149904.Jun 4 2018, 9:41 PM
  • fixup: remove sanitizer:: and xray:: in places
dberris updated this revision to Diff 149912.Jun 5 2018, 1:31 AM

Rebase after minor refactorings have landed upstream.

dberris updated this revision to Diff 149918.Jun 5 2018, 2:12 AM
  • fixup: clean-up a bit
dberris updated this revision to Diff 149926.Jun 5 2018, 3:37 AM

Rebase, now ready for another look.

dberris updated this revision to Diff 149929.Jun 5 2018, 3:38 AM
dberris edited the summary of this revision. (Show Details)
dberris removed a subscriber: mgorny.

Reword

eizan added a comment.Jun 5 2018, 7:56 PM

Can you comment for posterity on why the change you're making to the RecursionGuard -> Guard variable is more correct?

dberris updated this revision to Diff 150068.Jun 5 2018, 10:09 PM
dberris edited the summary of this revision. (Show Details)

Reword.

eizan accepted this revision.Jun 5 2018, 10:53 PM
This revision is now accepted and ready to land.Jun 5 2018, 10:53 PM
This revision was automatically updated to reflect the committed changes.