Closed Bug 1190985 Opened 9 years ago Closed 9 years ago

TSan: data race netwerk/base/nsSocketTransportService2.cpp:70 DebugMutexAutoLock

Categories

(Core :: Networking, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: froydnj, Assigned: u408661)

References

(Blocks 1 open bug)

Details

(Whiteboard: [tsan])

Attachments

(1 file, 1 obsolete file)

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

* Specific information about this bug

TSan is unhappy about DebugMutexAutoLock::sDebugOwningThread because it gets read outside of a lock on the main thread while being written (inside a lock) on a non-main thread.

I think this is actually safe, but it'd be reasonable to make sDebugOwningThread an Atomic<PRThread*, Relaxed> to convince TSan we really know what we're doing here.
* 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
Assignee: nobody → hurley
This should do the trick.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=418c431c5d44
Attachment #8643816 - Flags: review?(mcmanus)
Comment on attachment 8643816 [details] [diff] [review]
Fix data race in DebugMutexAutoLock

Review of attachment 8643816 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great, thank you!

::: netwerk/base/nsSocketTransportService2.cpp
@@ +54,5 @@
>  {
>  public:
>      explicit DebugMutexAutoLock(Mutex& mutex);
>      ~DebugMutexAutoLock();
> +    static void Init() { sDebugOwningThread = nullptr; }

FWIW, this is unnecessary because...

@@ +63,3 @@
>  };
>  
> +Atomic<PRThread *, Relaxed> DebugMutexAutoLock::sDebugOwningThread;

...this is automatically initialized to null.
Update with :froydnj's comments (thanks!)
Attachment #8643825 - Flags: review?(mcmanus)
Attachment #8643816 - Attachment is obsolete: true
Attachment #8643816 - Flags: review?(mcmanus)
Comment on attachment 8643825 [details] [diff] [review]
Fix data race in DebugMutexAutoLock

Review of attachment 8643825 [details] [diff] [review]:
-----------------------------------------------------------------

thanks nathan, thanks nick
Attachment #8643825 - Flags: review?(mcmanus) → review+
https://hg.mozilla.org/mozilla-central/rev/8b893803cc40
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Nice work, all y'all.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: