Closed Bug 1190969 Opened 9 years ago Closed 8 years ago

TSan: data race netwerk/cache2/CacheIOThread.cpp:148 CacheIOThread::Target

Categories

(Core :: Networking: Cache, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1222782

People

(Reporter: froydnj, Assigned: mayhemer)

References

(Blocks 1 open bug)

Details

(Whiteboard: [tsan])

The attached logfile shows a thread/data race detected by TSan (ThreadSanitizer).

* Specific information about this bug

What's happening here is:

- We startup the cache IO thread as a PRThread;
- We initialize the nsIThread for the cache IO thread on the IO thread;
- We then hand out references to the nsIThread for the cache IO thread on the main thread.

So we're writing a reference on the cache IO thread and reading it on the main thread without intervening locks.

There ought to be a better way to do this.  We could reverse who initializes what by setting CacheIOThread::mXPCOMThread with nsThreadManager::GetThreadFromPRThread on the main thread.  It's not clear to me that avoids races, because the cache IO thread still needs to access mXPCOMThread.  So some extra cleverness is required.

* General information about TSan, data races, etc.

Typically, races reported by TSan are not false positives, but it is possible that the race is benign. Even in this case though, we should try to come up with a fix unless this would cause unacceptable performance issues. Also note that seemingly benign races can possibly be harmful (also depending on the compiler and the architecture) [1][2].

If the bug cannot be fixed, then this bug should be used to either make a compile-time annotation for blacklisting or add an entry to the runtime blacklist.

[1] http://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
[2] _How to miscompile programs with "benign" data races_: https://www.usenix.org/legacy/events/hotpar11/tech/final_files/Boehm.pdf
Similar atomic flag mHasXPCOMTarget?
Flags: needinfo?(nfroyd)
See bug 1121672 comment 6.  In short, no.
Flags: needinfo?(nfroyd)
Assignee: nobody → honzab.moz
Nathan, please feel free to reopen if this is still not fixed by that bug.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.