TSan: data race dom/base/ScriptSettings.cpp:103 sScriptSettingsTLSInitialized
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: terrence, Assigned: tromey)
References
(Blocks 1 open bug)
Details
(Whiteboard: dom-triaged)
Attachments
(3 files)
Reporter | ||
Updated•9 years ago
|
Comment 3•9 years ago
|
||
Comment 5•9 years ago
|
||
Updated•9 years ago
|
Assignee | ||
Comment 6•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Assignee | ||
Comment 7•9 years ago
|
||
Assignee | ||
Comment 8•9 years ago
|
||
![]() |
||
Comment 9•9 years ago
|
||
Assignee | ||
Comment 10•9 years ago
|
||
Reporter | ||
Comment 11•9 years ago
|
||
Updated•6 years ago
|
Comment 12•6 years ago
|
||
I just hit exactly the same race when running ./mach test firefox-ui-functional
on a local TSan build. The race is on the global mozilla::dom::sScriptSettingsTLSInitialized
. I will add a runtime suppression for now.
![]() |
||
Comment 13•6 years ago
|
||
Yeah, so I don't understand how sScriptSettingsTLSInitialized can possibly work. It's a single global, but presumably we need to initialize the TLS thing on very thread that uses ScriptSettings, right?
The comment at https://searchfox.org/mozilla-central/rev/5e830ac8f56fe191cb58a264e01cdbf6b6e847bd/dom/script/ScriptSettings.h#34-35 about only doing it once is just wrong; init and destroy happen on a per-thread basis.
That said, we only have one consumer of ScriptSettingsInitialized()
, and I don't understand why it's there. If we're on the main thread and running nontrivial code like MessageChannel::DispatchMessage
, I'd really hope things are initialized, yes... Bobby, do you recall why you added that check?
Comment 14•6 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #13)
Yeah, so I don't understand how sScriptSettingsTLSInitialized can possibly work. It's a single global, but presumably we need to initialize the TLS thing on very thread that uses ScriptSettings, right?
It was correct when it landed: https://hg.mozilla.org/mozilla-central/rev/96dbd5483c05#l1.22
Looks like it became incorrect in bug 757969. Maybe the thinking there was that the only consumer is effectively main-thread-only, and so it's kinda-sorta-ok, despite the value being read and written on arbitrary threads?
The comment at https://searchfox.org/mozilla-central/rev/5e830ac8f56fe191cb58a264e01cdbf6b6e847bd/dom/script/ScriptSettings.h#34-35 about only doing it once is just wrong; init and destroy happen on a per-thread basis.
Yes, that comment does seem wrong. Would be good to fix it.
That said, we only have one consumer of
ScriptSettingsInitialized()
, and I don't understand why it's there. If we're on the main thread and running nontrivial code likeMessageChannel::DispatchMessage
, I'd really hope things are initialized, yes... Bobby, do you recall why you added that check?
I don't recall, but looks like Bill and I added it in bug 1103324 comment 5 (the patch in comment 4 didn't have it). So it was presumably in response to some kind of try failure - probably something very early in startup.
I think the simplest fix for this bug is to eliminate the boolean, and replace the check with CycleCollectedJSContext::Get() != nullptr, which should have identical lifetime characteristics.
I'll attach a patch.
Comment 15•6 years ago
|
||
Comment 16•6 years ago
|
||
![]() |
||
Comment 17•6 years ago
|
||
bugherder |
Updated•5 years ago
|
Description
•