Closed Bug 1893554 Opened 1 year ago Closed 1 year ago

Assertion failure: rematFrame->script() == frame->script(), at jit/BaselineBailouts.cpp:1783

Categories

(Core :: JavaScript Engine: JIT, defect, P1)

x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
127 Branch
Tracking Status
firefox127 --- fixed

People

(Reporter: gkw, Assigned: jandem)

References

(Blocks 3 open bugs)

Details

(Keywords: reporter-external, testcase)

Attachments

(1 file)

g = newGlobal({ newCompartment: true });
g.parent = this;
g.eval(
  "(" +
    function () {
      Debugger(parent).onExceptionUnwind = function (frame) {
        frame.older;
      };
    } +
    ")()"
);
function f(x, y) {
  try {
    Object.setPrototypeOf(
      y,
      new Proxy(Object.getPrototypeOf(y), {
        get(aaaaaa, bbb, ccccccc) {
          return undefined;
        },
      })
    );
  } catch (e) {}
}
function h(x, y) {
  f(x, y);
}
oomTest(function () {
  h("", undefined);
  h("", "");
  "".replaceAll();
});
1783      MOZ_ASSERT(rematFrame->script() == frame->script());
(gdb) bt
#0  CopyFromRematerializedFrame (cx=0x7ffff7640600, act=0x7fffffffc170, fp=0x7fffffffc030 "p\300\377\377\377\177", inlineDepth=0, frame=<optimized out>) at /home/ubumain/trees/mozilla-central/js/src/jit/BaselineBailouts.cpp:1783
#1  js::jit::FinishBailoutToBaseline (bailoutInfoArg=0x0) at /home/ubumain/trees/mozilla-central/js/src/jit/BaselineBailouts.cpp:1949
#2  0x000020c9f309e1ba in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb)

Run with --fuzzing-safe --ion-eager, compile with AR=ar sh ../configure --enable-debug --enable-debug-symbols --with-ccache --enable-nspr-build --enable-ctypes --enable-gczeal --enable-rust-simd --disable-tests, tested on m-c rev 66b11776bfaa.

Setting s-s as a start. This testcase is quite intermittent, probably once in 50/100 tries.

(EDIT: This bisection comment is not right) Bisection is currently pointing to late-Aug 2023 to late-Oct 2023...

Flags: sec-bounty?
Group: core-security → javascript-core-security

Bisection is currently pointing to late-Aug 2023 to late-Oct 2023...

This is not right, it gets even more intermittent in past revs. It still seems to occur in m-c rev 443c7bf9d76b (Aug 2023) though.

Setting needinfo? from Jan as a start, Iain is also on cc as this involves Debugger and the JIT.

Flags: needinfo?(jdemooij)

I've also found that reproduction helps with fuzzing running in the background to use up system resources.

I've been unable to reproduce this so far. I also tried about 500 runs with rr chaos mode.

Do you also see this with ASan builds?

Nevermind, I got a failure after ~700 runs under rr :)

DebuggerFrame::getOlder has this code:

      if (dbg->observesFrame(iter)) {
        if (iter.isIon() && !iter.ensureHasRematerializedFrame(cx)) {
          return false;
        }
        return dbg->getFrame(cx, iter, result);
      }

I think the bug is that we create a rematerialized frame for the Ion frame, but we then OOM under getFrame so we never invalidate the Ion frame. Because we don't invalidate the Ion frame, we return from the Ion frame to the caller without removing the rematerialized frame from the hash map. This confuses later code that does a lookup on the rematerialized-frame table because it finds the stale frame.

We should at least add better assertions for rematerialized frame lifetimes.

Group: javascript-core-security
Flags: needinfo?(jdemooij)

When the debugger creates a RematerializedFrame for an Ion frame, we need to invalidate
the Ion frame to ensure the rematerialized frame is destroyed in FinishBailoutToBaseline
(or the exception handler).

The debugger code could fail with OOM before doing this invalidation and in this case we
left a rematerialized frame in the activation's map after returning from the Ion frame.

Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a7ff2aad84a1 Ensure Ion frames with rematerialized frames are invalidated. r=iain
Blocks: sm-security
Severity: -- → S3
Priority: -- → P1
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 127 Branch
Flags: sec-bounty? → sec-bounty-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: