This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Intercept __pthread_mutex_lock and __pthread_mutex_unlock
ClosedPublic

Authored by vitalybuka on May 11 2018, 9:23 PM.

Diff Detail

Event Timeline

vitalybuka created this revision.May 11 2018, 9:23 PM

Interesting. Who calls these functions? Why? Can we change them to call normal functions instead?

In pthread they are no more than aliases to normal functions, can we do it with aliases too? like we do it for __libc_mutex_lock:

sanitizer_common/sanitizer_common_interceptors.inc-INTERCEPTOR(int, __libc_mutex_lock, void *m) \
sanitizer_common/sanitizer_common_interceptors.inc: ALIAS(WRAPPER_NAME(pthread_mutex_lock));

Interesting. Who calls these functions? Why? Can we change them to call normal functions instead?

I've cc'd you on the internal bug.

In pthread they are no more than aliases to normal functions, can we do it with aliases too? like we do it for __libc_mutex_lock:

sanitizer_common/sanitizer_common_interceptors.inc-INTERCEPTOR(int, __libc_mutex_lock, void *m) \
sanitizer_common/sanitizer_common_interceptors.inc: ALIAS(WRAPPER_NAME(pthread_mutex_lock));

Alias version works.

dvyukov accepted this revision.May 13 2018, 1:38 AM
This revision is now accepted and ready to land.May 13 2018, 1:38 AM
This revision was automatically updated to reflect the committed changes.
vitalybuka reopened this revision.May 14 2018, 1:05 PM
This revision is now accepted and ready to land.May 14 2018, 1:05 PM

Fix tsan tests

I need to fall back to "return WRAP(pthread_mutex_lock)(m)"
I've forgot to rerun tsan tests with ALIAS. With ALIAS stacks became __pthread_mutex_lock for regular pthread_mutex_lock calls which breaks some tests.

eugenis accepted this revision.May 14 2018, 1:42 PM

LGTM

This revision was automatically updated to reflect the committed changes.
Herald added a subscriber: Restricted Project. · View Herald TranscriptMay 14 2018, 6:43 PM