question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ThreadSanitizer detected data race in EpollEventLoop

See original GitHub issue

Expected 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:closed
  • Created 2 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ejona86commented, Apr 27, 2022

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 .

1reaction
normanmaurercommented, May 4, 2021

@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 ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found