Closed Bug 2000469 Opened 1 year ago Closed 1 year ago

Assertion failure: slots == calculateDynamicSlots(), at vm/JSObject-inl.h:36

Categories

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

All
Linux
defect

Tracking

()

RESOLVED FIXED
147 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox145 --- unaffected
firefox146 + fixed
firefox147 + fixed

People

(Reporter: gkw, Assigned: jandem)

References

(Blocks 1 open bug, Regression)

Details

(5 keywords)

Attachments

(1 file, 3 external files)

Attached file debug stack —
var a = ["g"];
function f() {
  const x = {
    set g(z) {
      (function(v) {
        if (b !== undefined) v[a.shift()] = 0;
      })(this);
      this.m = 0;
      this.n = 0;
      for (var y in this);
    },
  };
  x.g = x;
}
new Int8Array(32).reduceRight(f);
var b = 1;
new Int8Array(32).reduceRight(f);
(gdb) bt
#0  0x00005555575aed72 in MOZ_CrashSequence (aAddress=0x0, aLine=36)
    at /home/msf2/shell-cache/js-dbg-64-linux-x86_64-1c2b83c1fdb8-596556/objdir-js/dist/include/mozilla/Assertions.h:237
#1  js::NativeObject::numDynamicSlots (this=0x13a944e029f0) at /home/msf2/trees/firefox/js/src/vm/JSObject-inl.h:36
#2  0x0000555557649ebf in js::NativeObject::growSlotsPure (cx=0x7ffff5e3c200, obj=0x13a944e029f0, newCapacity=6)
    at /home/msf2/trees/firefox/js/src/vm/NativeObject.cpp:435
#3  0x000033a09a50e607 in ?? ()
#4  0xfff8800000000000 in ?? ()
#5  0x000013a944e029f0 in ?? ()
/snip
90711c04449c-592521
90711c04449c324bb18eb22522010fe85a051143 is the first interesting commit
commit 90711c04449c324bb18eb22522010fe85a051143
Author: André Bargull
Date:   Tue Oct 21 07:05:41 2025 +0000

    Bug 1991402 - Part 7: Avoid duplicate shape guards for SetSize. r=jandem

    Switch `InlinableNativeIRGenerator::tryAttachSetSize()` to use
    `emitOptimisticClassGuard` in order to emit a shape guard instead of a class
    guard.

    MIR instructions after this change:
    ```
    6 GuardShape <object>
    7 GuardShape GuardShape6
    8 SetObjectSize GuardShape7
    ```

    Then add `MGuardShape::foldsTo` to optimise away the duplicate shape guards.

    Drive-by change:
    - Simplify `M{GuardShape,CallBindVar}::congruentTo` implementations.

    Differential Revision: https://phabricator.services.mozilla.com/D266599

Run with --fuzzing-safe --no-threads --fast-warmup, compile with AR=ar sh ~/trees/firefox/js/src/configure --enable-debug --enable-debug-symbols --with-ccache --enable-nspr-build --enable-ctypes --enable-gczeal --enable-rust-simd --disable-tests, tested on gh rev 1c2b83c1fdb8ba523831bcdb63947f5f7a4cfa5e.

Andre, is bug 1991402 a likely regressor? (Note that a previous similar JIT assert bug 1875795 was marked sec-high)

Flags: sec-bounty?
Flags: needinfo?(andrebargull)

Set release status flags based on info from the regressing bug 1991402

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

That's a good find. In MGuardShape::foldsTo we check if the object operand is another MGuardShape for the same shape, but that isn't valid because between these two instructions the object's shape could be mutated.

Flags: needinfo?(jdemooij)
Flags: needinfo?(andrebargull)
Attached file (secure) —
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Attached file (secure) —
Keywords: sec-high
Severity: -- → S2
Priority: -- → P1

Thanks for fixing this bug! I didn't have time last week to look at this issue.

Comment on attachment 9528277 [details]
(secure)

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Not very easily but possible with some effort.
  • Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
  • Which branches (beta, release, and/or ESR) are affected by this flaw, and do the release status flags reflect this affected/unaffected state correctly?: 146+
  • If not all supported branches, which bug introduced the flaw?: Bug 1991402
  • Do you have backports for the affected branches?: Yes
  • If not, how different, hard to create, and risky will they be?: Patch should apply.
  • How likely is this patch to cause regressions; how much testing does it need?: Unlikely, it's just adding an extra check.
  • Is the patch ready to land after security approval is given?: Yes
  • Is Android affected?: Yes
Attachment #9528277 - Flags: sec-approval?

Comment on attachment 9528277 [details]
(secure)

Approved to land and request uplift

Attachment #9528277 - Flags: sec-approval? → sec-approval+
Attached file (secure) —
Attachment #9528927 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: Crashes or security issues.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Very low risk. The patch just adds an extra check to an if-condition.
  • String changes made/needed: None
  • Is Android affected?: yes
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch
Attachment #9528927 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [sec] [uplift] [qa-triage-done-c147/b146]
Flags: sec-bounty? → sec-bounty+
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: