build openjdk with fsanitizer=thread

Jie He Jie.He at arm.com
Tue Feb 25 05:20:25 UTC 2020


Hi

I built openjdk with enabling fanitizer=thread recently, and got a lot of warning by tsan even a helloworld case.

Then I investigated around more than 15 warnings, found they could be divided into 3 classes:


  1.  Benign races, commonly, there is a comment to indicate why it is safe in MP.
  2.  Runtime atomic implementation, in x86, the atomic load and store will be translated to platformload/store.
  3.  Runtime function implement protected by MutexLocker/ThreadCritical, which finally implemented by pthread_mutex.

For 3, I couldn't understand why tsan couldn't recognize that it's safe and protected by a lock. In TSAN document, it said pthread functions are supported.
So I tried to add annotation(ANNOTATION_RWCLOCK_ACQUIRED/RELEASED) to mark, then got the warning, double of lock, it seems tsan knows MutexLocker is a lock.

Or because one of the conflicting threads lost its stack, in this kind of warning, there is one out of the two threads fails to restore its stack.
It may result that tsan only knows the thread calls read/write, but doesn't know the memory operation is protected by a lock.
These threads couldn't restore the stack are JIT threads/Java threads? I need to fix the tsan symbolizer function first for this situation?

Thanks
Jie He



More information about the tsan-dev mailing list