This is an archive of the discontinued LLVM Phabricator instance.

asan/tsan/msan: properly intercept pthread_cond_xxx
AbandonedPublic

Authored by dvyukov on Apr 7 2014, 9:08 AM.

Details

Summary

NPTL implementation of pthread_cond has 2 versions -- 2.2.5 and 2.3.2. pthread_cond_t has different sizes in these versions, so we can't simply always call real 2.3.2 functions. Previously we struggled with this by means of various hacks (always call new version; allocate a satellite object large enough for new version; added flag that enables/disables the previous behavior; and probably other options).
This is an attempt to solve this problem once and for all. The patch adds 2 versions of interceptors, so that we know when to call old real functions and when to call new real function.
The main downside is that linking of shared libraries with xsan runtime now requires version script. This mode (linking of xsan runtime into shared libs) is generally unsupported, but we use it in some custom setups (e.g. build an instrumented shared C++ library and load it into Python/R/Java process). That usages will require the provided version script.
Better suggestions are welcome.

Diff Detail

Event Timeline

dvyukov updated this revision to Unknown Object (????).Apr 7 2014, 9:09 AM

added missing sanitizer.ver file

glider added a comment.Apr 8 2014, 6:40 AM

This patch doesn't seem to fix Chromium GPU hangs for me. Will double-check.

lib/asan/CMakeLists.txt
167

Is this condition true for OSX? You don't need your version script there.

lib/interception/interception_linux.h
38

It's unclear what does "single" stand for here. Can you please add comments for both INTERCEPT_FUNCTION_VER_SINGLE and INTERCEPT_FUNCTION_VER?

lib/sanitizer_common/sanitizer.ver
1

Can you please add a comment describing what this script is for and who needs to use it?
It may also need a license header, as this is something you're going to ship to the users.

2

How about naming the file "sanitizer_linux.ver"? It's Linux-only, right?
Another idea is to name it "sanitizer_pthread.ver" to reflect the fact it fixes a specific problem with pthreads.

6

nit: spare newline

lib/sanitizer_common/sanitizer_common_interceptors.inc
2667

I suggest putting the function parameter on a separate line and/or adding a typedef for it (here and below)

lib/sanitizer_common/sanitizer_internal_defs.h
151

RHS of definitions in this file aren't horizontally aligned, except for thread and builtin_expect.
I suggest to make this line consistent with the rest of the file.

lib/tsan/Makefile.old
2

Is -lrt related to this CL? If no, please commit separately.

test/tsan/runtime_in_shared_lib.cc
29

nit: spare newline

dvyukov abandoned this revision.Apr 23 2014, 6:01 AM

We've decided to abandon this.
There is no way to have versioned symbols in executable. See:
https://code.google.com/p/thread-sanitizer/issues/detail?id=58