WasmCodegenTypes.h's InlinedCallerOffsetIndex bookkeeping is corrupted by the inliner
Categories
(Core :: JavaScript: WebAssembly, defect, P3)
Tracking
()
People
(Reporter: yury, Assigned: rhunt)
References
(Blocks 2 open bugs, Regression)
Details
(4 keywords)
Attachments
(1 file, 2 external files)
|
1.91 KB,
application/x-javascript
|
Details |
Found that in the NOTES.md of bug 2058673. It looks unrelated to the initial issue filling it separately:
Related metadata-corruption defect in the same feature (documented)
WasmCodegenTypes.h's InlinedCallerOffsetIndex bookkeeping is also corrupted by
the inliner: RootCompiler::finishInlineCall (WasmIonCompile.cpp:11093) pops
inlinedCallerOffsets_ but never restores inlinedCallerOffsetsIndex_, so every
TrapSiteDesc/CallSiteDesc created in the caller after an inlined call carries
the finished callee's inlined-caller-offsets index. Observable with the same
prefs:
const bin = wasmTextToBinary(`(module
(func $a (param i32) (result i32) (i32.add (local.get 0) (i32.const 1)))
(func $root (export "run") (param i32) (result i32)
(drop (call $a (local.get 0)))
(if (local.get 0) (then unreachable))
(i32.const 7)))`);
const inst = new WebAssembly.Instance(new WebAssembly.Module(bin));
for (let i = 0; i < 50; i++) inst.exports.run(0);
try { inst.exports.run(1); } catch (e) { print(e.stack); }
prints a phantom extra 'root' frame (the trap site in root code after the
inlined call reports the inlined-caller offsets of the earlier call to $a).'
Observation
root@…wasm-function[1]:0x34 ← the unreachable trap in $root
root@…wasm-function[1]:0x2d ← phantom frame (the earlier call $a site)
@…phantom-frame-testcase.js:38
Error: Assertion failed: got 2, expected 1 (exit 3)
Updated•3 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
RootCompiler stored inlinedCallerOffsetsIndex_ as a single shared field, but it
is really a per-inlined-function value. finishInlineCall popped
inlinedCallerOffsets_ without restoring the index, so TrapSiteDesc/CallSiteDesc
created in the caller after an inlined call carried the finished callee's index
and reported phantom inlined frames.
Move the index onto FunctionCompiler, which is already constructed and destroyed
per inline frame, and have startInlineCall hand it back for the callee compiler.
Updated•2 months ago
|
Comment 2•2 months ago
|
||
:rhunt, please update all release status flags to reflect the affected/unaffected/disabled state correctly. Which branches (beta, release, and/or ESR) are affected by this flaw?
Comment 3•2 months ago
|
||
Is this the same as bug 2036252?
| Assignee | ||
Comment 4•2 months ago
|
||
Yes this is a dupe. This isn't a security bug either.
Updated•2 months ago
|
| Assignee | ||
Updated•2 months ago
|
Comment 6•2 months ago
|
||
Set release status flags based on info from the regressing bug 1961915
Updated•2 months ago
|
Comment 9•2 months ago
|
||
:rhunt, should ESR153 be a wontfix, or should the fix be uplifted?
| Assignee | ||
Comment 10•2 months ago
|
||
This is a pretty simple patch that fixes the error stack when wasm functions are inlined. I think that's worth having in ESR. If it's not taken, that is okay too. It only fixes how the stack trace we report on JS exceptions, code should work as is.
Comment 11•2 months ago
|
||
firefox-esr153 Uplift Approval Request
- User impact if declined/Reason for urgency: Stack traces reported to scripts may be wrong when a wasm function is inlined.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing: N/A
- Risk associated with taking this patch: low
- Explanation of risk level: Simple patch to our stack trace reporting code.
- String changes made/needed?: None
- Is Android affected?: yes
| Assignee | ||
Comment 12•2 months ago
|
||
RootCompiler stored inlinedCallerOffsetsIndex_ as a single shared field, but it
is really a per-inlined-function value. finishInlineCall popped
inlinedCallerOffsets_ without restoring the index, so TrapSiteDesc/CallSiteDesc
created in the caller after an inlined call carried the finished callee's index
and reported phantom inlined frames.
Move the index onto FunctionCompiler, which is already constructed and destroyed
per inline frame, and have startInlineCall hand it back for the callee compiler.
Original Revision: https://phabricator.services.mozilla.com/D320554
Updated•2 months ago
|
Updated•2 months ago
|
Comment 13•2 months ago
|
||
| uplift | ||
Updated•2 months ago
|
Description
•