This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Allow memchr interceptor to be used before initialization on OS X
ClosedPublic

Authored by kubamracek on Nov 3 2015, 7:00 AM.

Details

Summary

On OS X, memchr is called on a newly created thread even before __tsan_thread_start_func is invoked, which means that the ThreadState object for that thread will not yet be initialized. Let's add COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED into the interceptor to simply call the original memchr in these cases.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek updated this revision to Diff 39057.Nov 3 2015, 7:00 AM
kubamracek retitled this revision from to [tsan] Allow memchr interceptor to be used before initialization on OS X.
kubamracek updated this object.
kubamracek added reviewers: samsonov, kcc, glider, dvyukov.
dvyukov added inline comments.Nov 3 2015, 7:14 AM
lib/sanitizer_common/sanitizer_common_interceptors.inc
445 ↗(On Diff #39057)

This is fragile (even if works for you). REAL interceptors are also initializes, so if nothing is initialized REAL(memchr) == 0. Call internal_memchr instead, like other cases do.

kubamracek updated this revision to Diff 39062.Nov 3 2015, 7:31 AM

Updating patch.

dvyukov accepted this revision.Nov 3 2015, 7:40 AM
dvyukov edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 3 2015, 7:40 AM
This revision was automatically updated to reflect the committed changes.