[TSan RTL] Cannot suppress some Mutex-related errors
| 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.
Fixed by commit 207218
Filed https://code.google.com/p/thread-sanitizer/issues/detail?id=45
Makes sense. I agree that suppressions need to work for all reports.
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.
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.
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.
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?
Test case? BTW, we prefer tsan rtl bugs to be filed here: code.google.com/p/thread-sanitizer/