Assertion failure: numDelayed_ == 0, vm/OffThreadPromiseRuntimeState.cpp:257
Categories
(Core :: JavaScript Engine, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox146 | --- | fixed |
People
(Reporter: x0e, Assigned: arai)
References
Details
(Keywords: reporter-external)
Attachments
(1 external file)
Steps to reproduce:
Version: 48f8a74041be2973d7df8ded3ad5e64c2c00e8dd
Args: js --fuzzing-safe <test-case>
Test case:
for (a = 0;
a < 25;
a++) {
function b() {
c = new SharedArrayBuffer(16)
d = new Int32Array(c)
Atomics.waitAsync(d, d, SharedArrayBuffer, 4294967297)
}
new b
}
quit()
Actual results:
ASan report:
[1468034] Assertion failure: numDelayed_ == 0, at js/src/vm/OffThreadPromiseRuntimeState.cpp:257
#01: ???[reproducebuild/dist/bin/js +0x228184e]
#02: JSRuntime::~JSRuntime()[reproducebuild/dist/bin/js +0x22f5ee3]
#03: ???[reproducebuild/dist/bin/js +0x20c6754]
#04: ???[reproducebuild/dist/bin/js +0x1ccec50]
#05: ???[/lib/x86_64-linux-gnu/libc.so.6 +0x2a1ca]
#06: __libc_start_main[/lib/x86_64-linux-gnu/libc.so.6 +0x2a28b]
#07: ???[reproducebuild/dist/bin/js +0x1c95f69]
#08: ??? (???:???)
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==1468034==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x55bee1626866 bp 0x7ffcf98f4290 sp 0x7ffcf98f4280 T1468034)
==1468034==The signal is caused by a WRITE memory access.
==1468034==Hint: address points to the zero page.
#0 0x55bee1626866 in MOZ_CrashSequence(void*, long) reproducebuild/dist/include/mozilla/Assertions.h:237:3
#1 0x55bee1626866 in js::OffThreadPromiseRuntimeState::~OffThreadPromiseRuntimeState() js/src/vm/OffThreadPromiseRuntimeState.cpp:257:3
#2 0x55bee169aee2 in js::ProtectedData<js::CheckUnprotected, js::OffThreadPromiseRuntimeState>::~ProtectedData() js/src/threading/ProtectedData.h:78:7
#3 0x55bee169aee2 in JSRuntime::~JSRuntime() js/src/vm/Runtime.cpp:176:1
#4 0x55bee146b753 in void js_delete_poison<JSRuntime>(JSRuntime const*) reproducebuild/dist/include/js/Utility.h:588:9
#5 0x55bee146b753 in js::DestroyContext(JSContext*) js/src/vm/JSContext.cpp:236:3
#6 0x55bee1073c4f in main::$_1::operator()() const js/src/shell/js.cpp:12702:41
#7 0x55bee1073c4f in mozilla::ScopeExit<main::$_1>::~ScopeExit() reproducebuild/dist/include/mozilla/ScopeExit.h:106:7
#8 0x55bee1073c4f in main js/src/shell/js.cpp:12795:1
#9 0x7f71d9c7e1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#10 0x7f71d9c7e28a in __libc_start_main csu/../csu/libc-start.c:360:3
#11 0x55bee103af68 in _start (reproducebuild/dist/bin/js+0x1c95f68) (BuildId: c875546539f61038464f7a3e9e0cf666)
Updated•1 year ago
|
Comment 1•1 year ago
|
||
Thanks for the report. This looks like an Atomics.waitAsync regression.
Updated•1 year ago
|
Comment 2•1 year ago
|
||
Thanks for the report!
It looks like this is just an unfortunate interaction between the quit() function in the shell and the assertions we added in bug 1963067 to track in-flight tasks in the shell-only internal job queue. This doesn't affect the browser, and isn't security-sensitive.
It looks like what's happening is we're calling waitAsync several times with a very short timeout. The timeout fires, enqueuing a WaitAsyncTimeoutTask onto the internalDispatchQueue and incrementing numDelayed. numDelayed should be decremented when we drain the internalDispatchQueue and pop this task. However, calling quit() stops execution forcefully without draining the queue, causing this assertion to fire in the OffThreadPromiseRuntimeState destructor.
Arai, you and Yulia collaborated on adding these assertions. Do you have any thoughts about the best way to fix this?
Comment 3•1 year ago
|
||
Here's a simplified testcase:
let c = new SharedArrayBuffer(16);
let d = new Int32Array(c);
// The number of iterations here has to be high enough for at least one 1 ms timeout to fire.
for (var i = 0; i < 200; i++) {
Atomics.waitAsync(d, 0, 0, 1);
}
quit();
| Assignee | ||
Comment 4•1 year ago
|
||
Given that this is really specific to JS shell's quit behavior, where we want to forcibly quit, we can just skip the assertion in that case.
| Assignee | ||
Comment 5•1 year ago
|
||
Comment 7•1 year ago
|
||
| bugherder | ||
Updated•1 year ago
|
Description
•