llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[TSan RTL] Cannot suppress some Mutex-related errors

Open llvmbot opened this issue 12 years ago • 8 comments

Bugzilla Link 18378
Resolution FIXED
Resolved on Apr 25, 2014 05:10
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @KernelAddress,@kcc

Extended Description

The instrumented MutexLock/MutexUnlock code prints errors without going through the normal error report process. This means, if I'm not mistaken, that there is no way to suppress these warnings using the normal runtime suppression mechanisms.

llvmbot avatar Jan 04 '14 06:01 llvmbot

Fixed by commit 207218

KernelAddress avatar Apr 25 '14 12:04 KernelAddress

Filed https://code.google.com/p/thread-sanitizer/issues/detail?id=45

KernelAddress avatar Jan 09 '14 18:01 KernelAddress

Makes sense. I agree that suppressions need to work for all reports.

KernelAddress avatar Jan 07 '14 19:01 KernelAddress

I understand your point, but still think that any tool needs the ability to add suppressions. In large existing software projects, there are often issues you know about that you want to suppress until you have time to fix them. I described a somewhat simplified version of my use case - in practice a semaphore isn't a drop-in replacement for me, so will be some time before we can rewrite portions of code to solve this.

Meanwhile, it would be nice to suppress these errors in TSAN so that we can continue to look for and prevent other threading errors from creeping into the software.

llvmbot avatar Jan 07 '14 19:01 llvmbot

This does not work with mutexes, you need some kind of semaphore for this use case. Implementations of pthread will start switching to transactional memory by default soon, and this will break unrepairably.

KernelAddress avatar Jan 07 '14 19:01 KernelAddress

My case isn't unlocking an unlocked mutex. Rather, it's a case where one thread locks a mutex and then it gets unlocked by a different thread. This happens because we have some control flow like:

  • Thread A receives an RPC and obtains some lock on some data related to its request.
  • Thread B receives an RPC and obtains some lock on some different data for its own request.
  • Both threads need to log the transaction to disk before responding to the RPC. So, they put themselves on a queue. They cannot release the lock until after the logging has completed.
  • A third thread (C) picks up both A and B's transactions off the queue and logs on their behalf. This may take a while, so A and B don't want to block while the logging is under way. Instead, they move on to processing new RPCs.
  • When C is done logging, it wants to unlock the resources before responding to the RPCs.

In general, this situation arises when you have a SEDA-like architecture where different parts of a request are handled by different thread pools, but where there are some small portions that aren't implemented entirely lock-free.

llvmbot avatar Jan 07 '14 19:01 llvmbot

Unlock of a non-locked mutex is a very serious error. It's better to fix it asap. We never had a need to suppress it. What is your use case?

KernelAddress avatar Jan 07 '14 15:01 KernelAddress

Test case? BTW, we prefer tsan rtl bugs to be filed here: code.google.com/p/thread-sanitizer/

kcc avatar Jan 07 '14 12:01 kcc