ThreadSanitizer: data race [@ nssSlot_GetToken] vs. [@ nssToken_Destroy] with potential use-after-free during shutdown
Categories
(Core :: Security: PSM, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox100 | --- | fixed |
People
(Reporter: decoder, Unassigned)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [nss-fx][nss-monitor])
Crash Data
Attachments
(5 files)
The attached crash information was detected while running CI tests with ThreadSanitizer on mozilla-central revision bc5880b621d5.
This is a race I saw during the security/manager/ssl/tests/unit/test_nss_shutdown.js
test. It looks like a use-after-free on an nssToken
. The main thread has ShutdownNSS()
on the stack, so I assume this could be a shutdown problem, but it is unclear to me if this is test-only or if the same can happen in production. At most, this could cause intermittent test failures (crashes) of the particular test. And indeed we have bug 1563837 and bug 1546720 on file for intermittent crashes of this particular test.
General information about TSan reports
Why fix races?
Data races are undefined behavior and can cause crashes as well as correctness issues. Compiler optimizations can cause racy code to have unpredictable and hard-to-reproduce behavior.
Rating
If you think this race can cause crashes or correctness issues, it would be great to rate the bug appropriately as P1/P2 and/or indicating this in the bug. This makes it a lot easier for us to assess the actual impact that these reports make and if they are helpful to you.
False Positives / Benign Races
Typically, races reported by TSan are not false positives [1], but it is possible that the race is benign. Even in this case it would be nice to come up with a fix if it is easily doable and does not regress performance. Every race that we cannot fix will have to remain on the suppression list and slows down the overall TSan performance. Also note that seemingly benign races can possibly be harmful (also depending on the compiler, optimizations and the architecture) [2][3].
[1] One major exception is the involvement of uninstrumented code from third-party libraries.
[2] http://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
[3] How to miscompile programs with "benign" data races: https://www.usenix.org/legacy/events/hotpar11/tech/final_files/Boehm.pdf
Suppressing unfixable races
If the bug cannot be fixed, then a runtime suppression needs to be added in mozglue/build/TsanOptions.cpp
. The suppressions match on the full stack, so it should be picked such that it is unique to this particular race. The bug number of this bug should also be included so we have some documentation on why this suppression was added.
Reporter | ||
Comment 1•4 years ago
|
||
Comment 2•4 years ago
|
||
I spent some time this morning going through this code comparing to prior notes for NSS shutdown. It's good that we do have finally an exact case of what's happening during this race, but sadly we already knew the final culprits, and the ultimate cause being that NSS is synchronizing the wrong things during slot destruction... which is rough to fix.
I'm marking this P2 because it's worth a few hours searching before we decide P1 or P3.
Comment 3•4 years ago
|
||
Depends on D94852
Pushed by abeingessner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ac0770d9bdfa Remove supression for seemingly fixed issue. r=decoder
Comment 5•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Updated•4 years ago
|
Comment 6•3 years ago
|
||
I hit this again while turning on firefox's full shutdown code for tsan.
vs
Updated•3 years ago
|
Updated•3 years ago
|
Comment 7•3 years ago
|
||
Depends on D100264
Updated•3 years ago
|
Pushed by abeingessner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e17a24cf19c8 add back supression for code that gets stressed more in a full shutdown. r=decoder
Comment 9•3 years ago
|
||
bugherder |
Comment hidden (Intermittent Failures Robot) |
Updated•3 years ago
|
Comment 11•3 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:beurdouche, maybe it's time to close this bug?
Updated•3 years ago
|
Comment 12•2 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:beurdouche, maybe it's time to close this bug?
Comment 13•2 years ago
|
||
Updated•2 years ago
|
Comment 14•2 years ago
|
||
Pushed by jschanck@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/51dfe326a194 Remove suppression for NSS shutdown race. r=decoder
Comment 15•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Updated•2 years ago
|
Description
•