Skip to content
Memory corruption Disclosed report Advanced

Assertion failure: (offset % sizeof(FloatRegisters::RegisterContent)) == 0, at jit/JitFrames.cpp:2293

Gary Kwong Follow

Originally disclosed on Mozilla

  • Fixed in 2 days
  • Paid in 9 days
  • Disclosed after 2 days
Text
'''js
function f(x) {
    return (
        Math.min(
            Math.fround(Math.fround(false)),
            x ? Math.fround(x) : Math.fround(x)
        ) >>> 0
    )
}
for (let i = 0; i < 1; i++) {
    for (let j = 0; j < 99; j++) {
        f(Infinity);
    }
    f(-1);
}
'''

'''
(gdb) bt
#0  0x598039ee in js::jit::MachineState::read<float> (this=0xffff86e8, reg=...) at /home/skygentoo/trees/mozilla-central/js/src/jit/JitFrames.cpp:2293
#1  0x597f7c90 in js::jit::SnapshotIterator::fromRegister<float> (this=0xffff85f0, reg=...) at /home/skygentoo/trees/mozilla-central/js/src/jit/JSJitFrameIter.h:409
#2  0x597de6cb in js::jit::SnapshotIterator::allocationValue (this=0xffff85f0, alloc=..., rm=js::jit::SnapshotIterator::RM_Normal) at /home/skygentoo/trees/mozilla-central/js/src/jit/JitFrames.cpp:1684
#3  0x5927d863 in js::jit::SnapshotIterator::read (this=0xffff85f0) at /home/skygentoo/trees/mozilla-central/js/src/jit/JSJitFrameIter.h:511
#4  0x5924b570 in BaselineStackBuilder::buildExpressionStack (this=0xffff8520) at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineBailouts.cpp:894
#5  0x5924e406 in BaselineStackBuilder::buildOneFrame (this=0xffff8520) at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineBailouts.cpp:1547
#6  0x59247e28 in js::jit::BailoutIonToBaseline (cx=0xf6a16100, activation=0xffff90e0, iter=..., bailoutInfo=0xf68ffc08, excInfo=0x0) at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineBailouts.cpp:1729
#7  0x59247147 in js::jit::Bailout (sp=0xf68ffc10, bailoutInfo=0xf68ffc08) at /home/skygentoo/trees/mozilla-central/js/src/jit/Bailouts.cpp:67
#8  0x594ad19a in js::jit::Simulator::softwareInterrupt (this=0xf6a24200, instr=0xf6a27244) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:2519
#9  0x594b64a3 in js::jit::Simulator::decodeType7 (this=0xf6a24200, instr=0xf6a27244) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:4155
#10 0x594a8caa in js::jit::Simulator::instructionDecode (this=0xf6a24200, instr=0xf6a27244) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5185
#11 0x594ebd4a in js::jit::Simulator::execute<false> (this=0xf6a24200) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5241
#12 0x594bbc75 in js::jit::Simulator::callInternal (this=0xf6a24200, entry=0x3a9c9870 "\360O-\351\004\320M\342\020\212-\355\r\200\240\341h\220\235\345\r\260\240\341t\240\235", <incomplete sequence \345>) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5319
#13 0x594bcb54 in js::jit::Simulator::call (this=0xf6a24200, entry=0x3a9c9870 "\360O-\351\004\320M\342\020\212-\355\r\200\240\341h\220\235\345\r\260\240\341t\240\235", <incomplete sequence \345>, argument_count=8) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5407
#14 0x597d3a7e in EnterJit (cx=0xf6a16100, state=..., code=0x3aa0b118 "\004\340-\345\a") at /home/skygentoo/trees/mozilla-central/js/src/jit/Jit.cpp:107
#15 0x597d31c6 in js::jit::MaybeEnterJit (cx=0xf6a16100, state=...) at /home/skygentoo/trees/mozilla-central/js/src/jit/Jit.cpp:205
#16 0x5819594f in js::RunScript (cx=0xf6a16100, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:379
#17 0x581b29b7 in js::InternalCallOrConstruct (cx=0xf6a16100, args=..., construct=js::NO_CONSTRUCT, reason=js::CallReason::Call) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:539
#18 0x581b3035 in InternalCall (cx=0xf6a16100, args=..., reason=js::CallReason::Call) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:574
#19 0x581b2e05 in js::CallFromStack (cx=0xf6a16100, args=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:578
#20 0x591c750f in js::jit::DoCallFallback (cx=0xf6a16100, frame=0xf68fff00, stub=0xf55fea84, argc=1, vp=0xf68ffeb0, res=...) at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineIC.cpp:1582
#21 0x594ad46b in js::jit::Simulator::softwareInterrupt (this=0xf6a24200, instr=0xf6a27ee4) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:2557
#22 0x594b64a3 in js::jit::Simulator::decodeType7 (this=0xf6a24200, instr=0xf6a27ee4) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:4155
#23 0x594a8caa in js::jit::Simulator::instructionDecode (this=0xf6a24200, instr=0xf6a27ee4) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5185
#24 0x594ebd4a in js::jit::Simulator::execute<false> (this=0xf6a24200) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5241
#25 0x594bbc75 in js::jit::Simulator::callInternal (this=0xf6a24200, entry=0x3a9c9870 "\360O-\351\004\320M\342\020\212-\355\r\200\240\341h\220\235\345\r\260\240\341t\240\235", <incomplete sequence \345>) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5319
#26 0x594bcb54 in js::jit::Simulator::call (this=0xf6a24200, entry=0x3a9c9870 "\360O-\351\004\320M\342\020\212-\355\r\200\240\341h\220\235\345\r\260\240\341t\240\235", <incomplete sequence \345>, argument_count=8) at /home/skygentoo/trees/mozilla-central/js/src/jit/arm/Simulator-arm.cpp:5407
#27 0x591d14fb in EnterBaseline (cx=0xf6a16100, data=...) at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineJIT.cpp:143
#28 0x591d0edf in js::jit::EnterBaselineInterpreterAtBranch (cx=0xf6a16100, fp=0xf6a15010, pc=0xf5418794 "\220\002") at /home/skygentoo/trees/mozilla-central/js/src/jit/BaselineJIT.cpp:203
#29 0x58196c79 in Interpret (cx=0xf6a16100, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:2193
#30 0x581959ca in js::RunScript (cx=0xf6a16100, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:389
#31 0x581b48a6 in js::ExecuteKernel (cx=0xf6a16100, script=..., envChainArg=..., evalInFrame=..., result=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:781
#32 0x581b4cc4 in js::Execute (cx=0xf6a16100, script=..., envChain=..., rval=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:813
#33 0x583e3be9 in ExecuteScript (cx=0xf6a16100, envChain=..., script=..., rval=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/CompilationAndEvaluation.cpp:509
#34 0x583e3d19 in JS_ExecuteScript (cx=0xf6a16100, scriptArg=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/CompilationAndEvaluation.cpp:533
#35 0x57feb84f in RunFile (cx=0xf6a16100, filename=0xffffcdd1 "testcase.js", file=0xf781b540, compileMethod=CompileUtf8::DontInflate, compileOnly=false) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:1063
#36 0x57feb072 in Process (cx=0xf6a16100, filename=0xffffcdd1 "testcase.js", forceTTY=false, kind=FileScript) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:1652
#37 0x57fbc4bb in ProcessArgs (cx=0xf6a16100, op=0xffffc958) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:10919
#38 0x57fad7b1 in Shell (cx=0xf6a16100, op=0xffffc958) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:11656
#39 0x57fa7e61 in main (argc=5, argv=0xffffcaf4) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:12692
(gdb)
'''

Run with `--fuzzing-safe --ion-offthread-compile=off --fast-warmup testcase.js`, compile with `'CC="clang -msse2 -mfpmath=sse"' 'CXX="clang++ -msse2 -mfpmath=sse"' PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig AR=ar sh ./configure --host=x86_64-pc-linux-gnu --target=i686-pc-linux --enable-simulator=arm --enable-debug --disable-optimize --with-ccache --enable-gczeal --enable-debug-symbols --disable-bootstrap --disable-tests`, tested on m-c rev c59c06e50b89.

'''
autobisectjs shows this is probably related to the following changeset:

The first bad revision is:
changeset:   https://hg.mozilla.org/mozilla-central/rev/23ffbe755133
parent:      b360d0fa4d48
user:        Jan de Mooij
date:        Thu Apr 14 12:35:49 2022 +0000
summary:     Bug 1764366 part 3 - Shrink MachineState. r=nbp,iain
'''

Not sure if this is s-s, I'd leave it to Jan.

The original report as published on Mozilla's Bugzilla, by Gary Kwong. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity memory corruption bug in JavaScript Engine: JIT. Mozilla made it public on 17 May 2022.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Gary Kwong

View all

42 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.