Hit MOZ_CRASH(Bad type code) at /js/src/wasm/WasmValType.h:713 with Debugger
Categories
(Core :: JavaScript: WebAssembly, defect)
Tracking
()
People
(Reporter: decoder, Assigned: bvisness)
Details
(5 keywords, Whiteboard: [jsbugmon:update,bisect] [adv-main139+r] [adv-esr128.11+r])
Attachments
(2 files, 2 external files, 1 obsolete file)
The attached testcase crashes on mozilla-central revision 20250424-cdb7f526b187 (build with debug, run with --fuzzing-safe --ion-offthread-compile=off).
Backtrace:
received signal SIGSEGV, Segmentation fault.
0x000055555838f7a2 in js::wasm::Decoder::uncheckedReadValType(js::wasm::TypeContext const&) ()
#0 0x000055555838f7a2 in js::wasm::Decoder::uncheckedReadValType(js::wasm::TypeContext const&) ()
#1 0x000055555838f294 in js::wasm::DecodeValidatedLocalEntries(js::wasm::TypeContext const&, js::wasm::Decoder&, mozilla::Vector<js::wasm::PackedType<js::wasm::ValTypeTraits>, 16ul, js::SystemAllocPolicy>*) ()
#2 0x0000555558260a79 in js::wasm::DebugState::debugGetLocalTypes(unsigned int, mozilla::Vector<js::wasm::PackedType<js::wasm::ValTypeTraits>, 16ul, js::SystemAllocPolicy>*, unsigned long*, js::wasm::StackResults*) ()
#3 0x00005555573be9b6 in js::WasmFunctionScope::create(JSContext*, JS::Handle<js::Scope*>, unsigned int) ()
#4 0x00005555582bfdf9 in js::WasmInstanceObject::getFunctionScope(JSContext*, JS::Handle<js::WasmInstanceObject*>, unsigned int) ()
#5 0x00005555571bfb96 in GetFrameEnvironmentAndScope(JSContext*, js::AbstractFramePtr, unsigned char const*, JS::MutableHandle<JSObject*>, JS::MutableHandle<js::Scope*>) ()
#6 0x00005555571bf497 in js::DebugEnvironments::updateLiveEnvironments(JSContext*) ()
#7 0x00005555571c23b0 in js::GetDebugEnvironmentForFrame(JSContext*, js::AbstractFramePtr, unsigned char*) ()
#8 0x0000555557717ac4 in js::DebuggerFrame::getEnvironment(JSContext*, JS::Handle<js::DebuggerFrame*>, JS::MutableHandle<js::DebuggerEnvironment*>) ()
#9 0x000055555771d57d in js::DebuggerFrame::CallData::environmentGetter() ()
#10 0x00005555577213e3 in bool js::DebuggerFrame::CallData::ToNative<&js::DebuggerFrame::CallData::environmentGetter>(JSContext*, unsigned int, JS::Value*) ()
#11 0x0000555557054915 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) ()
#12 0x0000555557054020 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) ()
#13 0x00005555570555bc in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) ()
#14 0x00005555570566f4 in js::CallGetter(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::MutableHandle<JS::Value>) ()
#15 0x00005555572f4180 in bool GetExistingProperty<(js::AllowGC)1>(JSContext*, js::MaybeRooted<JS::Value, (js::AllowGC)1>::HandleType, js::MaybeRooted<js::NativeObject*, (js::AllowGC)1>::HandleType, js::MaybeRooted<JS::PropertyKey, (js::AllowGC)1>::HandleType, js::PropertyInfoBase<unsigned int>, js::MaybeRooted<JS::Value, (js::AllowGC)1>::MutableHandleType) ()
#16 0x00005555572f48fc in bool NativeGetPropertyInline<(js::AllowGC)1>(JSContext*, js::MaybeRooted<js::NativeObject*, (js::AllowGC)1>::HandleType, js::MaybeRooted<JS::Value, (js::AllowGC)1>::HandleType, js::MaybeRooted<JS::PropertyKey, (js::AllowGC)1>::HandleType, IsNameLookup, js::MaybeRooted<JS::Value, (js::AllowGC)1>::MutableHandleType) ()
#17 0x0000555556f2f944 in js::GetProperty(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, js::PropertyName*, JS::MutableHandle<JS::Value>) ()
#18 0x0000555557077c15 in js::GetProperty(JSContext*, JS::Handle<JS::Value>, JS::Handle<js::PropertyName*>, JS::MutableHandle<JS::Value>) ()
#19 0x00005555570606e2 in js::Interpret(JSContext*, js::RunState&) ()
#20 0x0000555557053572 in js::RunScript(JSContext*, js::RunState&) ()
#21 0x0000555557054046 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) ()
#22 0x00005555570555bc in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) ()
#23 0x000055555768d726 in js::Call(JSContext*, JS::Handle<JS::Value>, JSObject*, JS::Handle<JS::Value>, JS::MutableHandle<JS::Value>) ()
#24 0x00005555576d9f6b in js::Debugger::fireEnterFrame(JSContext*, js::ResumeMode&, JS::MutableHandle<JS::Value>) ()
#25 0x00005555576cf4df in js::DebugAPI::slowPathOnEnterFrame(JSContext*, js::AbstractFramePtr) ()
#26 0x000055555706dad5 in js::DebugAPI::onEnterFrame(JSContext*, js::AbstractFramePtr) ()
#27 0x0000555558246a30 in WasmHandleDebugTrap() ()
#28 0x000025886855224b in ?? ()
#29 0x00007fffffffc738 in ?? ()
#30 0x0000000000000000 in ?? ()
rax 0x0 0
rbx 0x6e 110
rcx 0x2c9 713
rdx 0x1 1
rsi 0x0 0
rdi 0x7ffff7bee7d0 140737349871568
rbp 0x7fffffffaa20 140737488333344
rsp 0x7fffffffaa00 140737488333312
r8 0x0 0
r9 0x3 3
r10 0x0 0
r11 0x0 0
r12 0x0 0
r13 0x1 1
r14 0x7fffffffaa98 140737488333464
r15 0x7ffff46a7700 140737294006016
rip 0x55555838f7a2 <js::wasm::Decoder::uncheckedReadValType(js::wasm::TypeContext const&)+1106>
=> 0x55555838f7a2 <_ZN2js4wasm7Decoder20uncheckedReadValTypeERKNS0_11TypeContextE+1106>: mov %rcx,(%rax)
0x55555838f7a5 <_ZN2js4wasm7Decoder20uncheckedReadValTypeERKNS0_11TypeContextE+1109>: callq 0x555556f5c840 <abort>
Likely sec-moderate at most due to Debugger being involved.
| Reporter | ||
Comment 1•1 year ago
|
||
| Reporter | ||
Comment 2•1 year ago
|
||
| Assignee | ||
Comment 3•1 year ago
|
||
This method is only called by the debugger, and was missing various
reference types.
Updated•1 year ago
|
| Assignee | ||
Comment 4•1 year ago
|
||
It seems that we simply had a method Decoder::uncheckedReadValType that had not been updated to include various types from the gc proposal. This method is seemingly only used in the debugger.
Because various types were missing, it fell back to ValType::fromNonRefTypeCode, which in debug asserts that the type is one of the WebAssembly number or vector types, not a reference type. This bug can be triggered by changing the type of the local in the wasm function to various reference types like anyref, nullref, eqref, etc.
Funny enough, all ValTypes (ref or otherwise) share the same underlying PackedTypeCode representation, and in release builds, ValType::fromNonRefTypeCode simply falls back to constructing a PackedTypeCode directly. So despite failing this debug assert, I believe that in release builds, it actually does return a valid RefType. The only bug, I think, is that RefType::fromTypeCode(TypeCode(code), true) will produce a nullable ref type, while PackedType(TypeCode(code)) will produce a non-nullable ref type. I'm not sure what the impact of this might be; cc'ing Yury. Hopefully it just reports a slightly wrong type to the debugger but doesn't affect its operation.
Comment 5•1 year ago
|
||
Updated•1 year ago
|
Comment 6•1 year ago
|
||
Likely sec-moderate at most due to Debugger being involved.
The only bug, I think, is that RefType::fromTypeCode(TypeCode(code), true) will produce a nullable ref type, while PackedType(TypeCode(code)) will produce a non-nullable ref type.... Hopefully it just reports a slightly wrong type to the debugger but doesn't affect its operation.
Let's keep it at sec-moderate, the worst case, the wrong type/value will likely be just a null or assert crash during debugger operations.
Comment 8•1 year ago
|
||
Backed out for failing own test:
https://hg.mozilla.org/integration/autoland/rev/9715bb5ae115e5f1de5e2519b3ac71a621ee66d8
Push with failures
Failure log
[task 2025-04-25T17:35:04.399Z] TEST-PASS | js/src/jit-test/tests/wasm/gc/bug-1962634.js | Success (code 59, args "--wasm-compiler=optimizing") [0.0 s]
[task 2025-04-25T17:35:04.400Z] /builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/gc/bug-1962634.js:32:13 CompileError: at offset 37: v128 not enabled
[task 2025-04-25T17:35:04.400Z] Stack:
[task 2025-04-25T17:35:04.400Z] @/builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/gc/bug-1962634.js:32:13
[task 2025-04-25T17:35:04.400Z] Exit code: 3
[task 2025-04-25T17:35:04.400Z] FAIL - wasm/gc/bug-1962634.js
[task 2025-04-25T17:35:04.400Z] TEST-UNEXPECTED-FAIL | js/src/jit-test/tests/wasm/gc/bug-1962634.js | /builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/gc/bug-1962634.js:32:13 CompileError: at offset 37: v128 not enabled (code 3, args "--ion-eager --ion-offthread-compile=off --ion-check-range-analysis --ion-extra-checks --no-sse3 --no-threads") [0.1 s]
[task 2025-04-25T17:35:04.400Z] INFO exit-status : 3
[task 2025-04-25T17:35:04.401Z] INFO timed-out : False
[task 2025-04-25T17:35:04.401Z] INFO stderr 2> /builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/gc/bug-1962634.js:32:13 CompileError: at offset 37: v128 not enabled
[task 2025-04-25T17:35:04.401Z] INFO stderr 2> Stack:
[task 2025-04-25T17:35:04.401Z] INFO stderr 2> @/builds/worker/checkouts/gecko/js/src/jit-test/tests/wasm/gc/bug-1962634.js:32:13
| Assignee | ||
Comment 9•1 year ago
|
||
Phooey, I say. Removing v128 from the test because it really wasn't necessary anyway.
Comment 10•1 year ago
|
||
Comment 11•1 year ago
|
||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 12•1 year ago
|
||
Please nominate this for ESR128 uplift. It grafts cleanly.
| Assignee | ||
Comment 13•1 year ago
|
||
This method is only called by the debugger, and was missing various
reference types.
Original Revision: https://phabricator.services.mozilla.com/D246752
Updated•1 year ago
|
Comment 14•1 year ago
|
||
firefox-esr128 Uplift Approval Request
- User impact if declined: Slightly incorrect types for WASM GC objects in dev tools (minor potential for crashes)
- Code covered by automated testing: yes
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing: n/a
- Risk associated with taking this patch: Low
- Explanation of risk level: It uses simple pre-existing logic in new cases that were added through wasm proposals.
- String changes made/needed: n/a
- Is Android affected?: no
| Assignee | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 15•1 year ago
|
||
| uplift | ||
Comment 16•1 year ago
|
||
| uplift | ||
Comment 17•1 year ago
|
||
Backed out for failing own test:
https://hg.mozilla.org/releases/mozilla-esr128/rev/a017238be1bae0007e1251a6fa3b497291b0c877
| Assignee | ||
Comment 18•1 year ago
•
|
||
ESR patch has been updated.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 19•1 year ago
|
||
| uplift | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•11 months ago
|
Comment 21•11 months ago
|
||
Verified bug as fixed on rev mozilla-central 20250426211843-53aaae152b1d.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.
Description
•