Closed Bug 1141692 Opened 9 years ago Closed 9 years ago

TSan: data race xpcom/threads/nsThreadPool.cpp:153 Run

Categories

(Core :: XPCOM, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

References

(Blocks 1 open bug)

Details

(Whiteboard: [tsan])

Attachments

(2 files)

Attached file thread-pool-naming.txt
The attached logfile shows a thread/data race detected by TSan (ThreadSanitizer).

* Specific information about this bug

AFAICT, this race actually comes from this bit of code:

http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsThreadUtils.cpp#328

with unified sources contributing to the inlining of that function into nsThreadPool::Run, and inlined methods contributing to nsTSubstring::AppendInt getting dinged as the actual location of the race in the logfile.

Anyway, mCounter is |volatile|, which is just silly.  Let's fix that.
* 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
Marking a variable as volatile is never the right thing to do when
dealing with threads.  Use real atomic accesses instead.
Attachment #8575465 - Flags: review?(benjamin)
Comment on attachment 8575465 [details] [diff] [review]
use an actual Atomic for nsThreadPoolNaming::mCounter

Blech, I truly detest atomicity being only part of the type system and not explicitly visible at callsites :-(
Attachment #8575465 - Flags: review?(benjamin) → review+
https://hg.mozilla.org/mozilla-central/rev/421e7047df36
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: