ThreadSanitizer detected data race in EpollEventLoop
See original GitHub issueExpected behavior
ThreadSantizer doesn’t find any race conditions
Actual behavior
ThreadSanitizer found data race as follows:
Code in io.netty.channel.epoll.EpollEventLoop.java:521
try {
eventFd.close();
} catch (IOException e) {
logger.warn("Failed to close the event fd.", e);
}
Code in io.netty.channel.epoll.EpollEventLoop.java:183
protected void wakeup(boolean inEventLoop) {
if (!inEventLoop && nextWakeupNanos.getAndSet(AWAKE) != AWAKE) {
// write to the evfd which will then wake-up epoll_wait(...)
Native.eventFdWrite(eventFd.intValue(), 1L);
}
}
Access to eventFd
(which is a FileDescriptor
) should be protected with a lock.
Steps to reproduce
Run a bigtable test with TSAN enabled for 100 runs.
Minimal yet complete reproducer code (or URL to code)
Netty version
4.1.52.Final
JVM version (e.g. java -version
)
JDK11
OS version (e.g. uname -a
)
Not known
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
ThreadSanitizer: data race detection in practice
This pa- per presents ThreadSanitizer – a dynamic detector of data races. We describe the hybrid algorithm (based on happens- before and locksets)...
Read more >Thread Sanitizer explained: Data Races in Swift - SwiftLee
Using the Thread Sanitizer to detect Data Races. The above examples show us that a Data Race can easily occur. In small pieces...
Read more >ThreadSanitizerCppManual · google/sanitizers Wiki - GitHub
ThreadSanitizer (aka TSan) is a data race detector for C/C++. Data races are one of the most common and hardest to debug types...
Read more >ThreadSanitizer — Clang 16.0.0git documentation
ThreadSanitizer is a tool that detects data races. It consists of a compiler instrumentation module and a run-time library. Typical slowdown introduced by ......
Read more >ThreadSanitizer detects a data race, where is the problem?
You are passing a reference to the function-local f to the lambda body , which is invoked by the thread constructor.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tracked this down and confirmed a false positive in TSAN. A test suddenly started triggering TSAN more frequently which made it easier to toy with and I confirmed that TSAN didn’t detect epoll waking as a form of synchronization. I was able to create a minimal C reproduction which was handled quickly by some TSAN folks to produce https://reviews.llvm.org/D124518 .
@sanjaypujare actually I think this is a false postive and harmless. Using the eventFD in a multi-threaded environment is actually valid and expected. @ejona86 WDYT ?