Thread Sanitizer reporting "failed to intercept clock_gettime"

Hi all,

We have been trying out Thread Sanitizer lately (on ubuntu 12.10, with clang trunk) and just ran into a problem where it outputs:

FATAL: ThreadSanitizer: failed to intercept clock_gettime

We do indeed use the clock_gettime() API (via a 3rd party library, but whatever).

What does this error message mean? Is this a tsan bug? Or something that's our fault?

Thanks,

Hi Sean!

A couple of random guesses:

  1. do you link with “-lrt”? clock_gettime is the function in librt, and you should link against it explicitly.
  2. if yes, do you use -Wl,–as-needed? We think it may be sanitizer-hostile, see http://llvm.org/bugs/show_bug.cgi?id=15823

Background:
Normally if you call “clock_gettime” this symbol is undefined in your library and is taken from librt.so
But if you build your code with -fsanitize=thread, “clock_gettime” is resolved to a replacement provided by sanitizer
runtime, while the “real” clock_gettime is obtained by the call to dlsym(“clock_gettime”)

Hi Alexey,

I just update bug 15823 with some of my test
http://llvm.org/bugs/show_bug.cgi?id=15823

Hope this could help.

Thanks,

_KA_