TestNativeNt broken in local build due to thread local storage pointer caching optimization
Categories
(Core :: mozglue, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox109 | --- | fixed |
People
(Reporter: yannis, Assigned: yannis)
References
Details
Attachments
(1 file)
On my local machine, TestNativeNt
is broken:
$ ./obj-x86_64-pc-mingw32/dist/bin/TestNativeNt.exe
sTlsData#1 = 00000000
Segmentation fault
The reason seems to be the same as what's mentioned in the comment above SwapThreadLocalStoragePointer
:
// Need a non-inline function to bypass compiler optimization that the thread
// local storage pointer is cached in a register before accessing a thread-local
// variable.
In my case, it seems that the new nullptr
value for the thread-local storage pointer gets cached when we call sTlsData.set(~kTlsDataValue);
inside MOZ_SEH_TRY
, resulting in the next call to sTlsData.get()
to dereference a null pointer. Replacing the set
line by a call to a non-inlinable variant fixes the local test:
MOZ_NEVER_INLINE void setTlsData(unsigned x) { sTlsData.set(x); }
I believe that in all functions that change the thread-local storage pointer value using SwapThreadLocalStoragePointer
, we should use non-inlinable variants of our thread-local storage helpers to make sure that it is never cached at any point of the test. That would be TestNativeNt
and also TestSafeThreadLocal
.
This may also fix bug 1784210?
Assignee | ||
Comment 1•1 year ago
|
||
Pushed by yjuglaret@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9615b6d6fc0b Use non-inlinable thread-local helpers in TestNativeNt and TestSafeThreadLocal. r=glandium
Comment 4•1 year ago
|
||
bugherder |
Description
•