Open Bug 1996583 Opened 1 year ago Updated 3 months ago

crash indexing SIZE_MAX element of the freeCommittedArenas BitSet

Categories

(Core :: JavaScript: GC, defect, P3)

defect

Tracking

()

People

(Reporter: gstoll, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

Crash Data

A user on reddit reported a lot of tab crashes starting recently. Looking at a crash report, it seems like this call to freeCommittedArenas.FindFirst() is returning SIZE_MAX, and then indexing that causes an InvalidArrayIndex_CRASH. (this is in release so the MOZ_ASSERTs are skipped)

Looking at this signature on crash-stats it looks like ~44% of crashes are trying to index SIZE_MAX of an array, so probably the same call site.

I'm not sure if FindFirst() returning SIZE_MAX is an indication of something like OOM (although the crash report doesn't seem to show a system that's out of memory), but it would be nice to crash in a more explicit way if there's no other option.

Crash Signature: [@ mozilla::detail::InvalidArrayIndex_CRASH | mozilla::Array<T>::operator[] ]

Please let me know if there's anything else i can contribute to help. I've made a few attempts at running mozregression-gui and did get one crash while running that but TBH i was pretty confused about how to use it correctly and struggled to reliably reproduce the crash.

Querying for this specific moz_crash_reason indicates that this was probably introduced in 141.0.

34% of the crashes are on family 6 model 167 stepping 1 so bad CPUs are at least somewhat of a factor. Really, I should add some signature stuff to split this up on crash-stats....

See Also: → 1996652

(In reply to Andrew McCreight [:mccr8] from comment #3)

bad CPUs are at least somewhat of a factor

Is this a CPU with errata known to cause problems or are you going off the breakdown on crash stats?

family 6 model 167 stepping 1 is specifically a CPU that has given us a lot of problems. We've got a whole meta bug for it: bug 1975808

(In reply to Andrew McCreight [:mccr8] from comment #5)

family 6 model 167 stepping 1 is specifically a CPU that has given us a lot of problems. We've got a whole meta bug for it: bug 1975808

Isn't that a different generation? Some websites suggest family 6 model 167 is Rocket Lake, a bit older than Raptor Lake.

(In reply to Jan de Mooij [:jandem] from comment #6)

Isn't that a different generation? Some websites suggest family 6 model 167 is Rocket Lake, a bit older than Raptor Lake.

I have no idea. I'm just following the nomenclature I've seen at Mozilla, but it could be wrong.

Weird. This signature disappeared on the 28th?

Blocks: GC.stability
No longer blocks: cpu-raptor-lake-bugs
Severity: -- → S3
Priority: -- → P3

still crashing. ;) I'm the "CPU Info = family 6 model 167 stepping 1" person aka "install time = 1761815481" in ... probably all of those crashes.

Nate: Have you tried running memtest86? The crash rate you're seeing in places others aren't really are suggesting something funky is going on with your machine.

(In reply to Matthew Gaudet (he/him) [:mgaudet] from comment #11)

Nate: Have you tried running memtest86? The crash rate you're seeing in places others aren't really are suggesting something funky is going on with your machine.

I did indeed over the weekend. All tests passed. Made sure motherboard firmware and ME were up to date as well just to be sure.

I'm not seeing stability problems in any other applications. Ableton Live, Bitwig, various games or VSTs, Icky Yucky Stinky Poopie Edge ... Event logs are clear. The only thing that's misbehaving is Firefox.

That's good feedback.

Jon: We definitely seem to have a user who is reliably not finding a free committed arena. Aside from just asserting that index != SIZE_MAX, are there other related invariants that could be violated here?

Flags: needinfo?(jcoppeard)

I did some work to change the signature for these bounds checking issues. Not that the new signature is necessarily better but at least you can tell when it is happening in GC land.

Crash Signature: [@ mozilla::detail::InvalidArrayIndex_CRASH | mozilla::Array<T>::operator[] ] → [@ mozilla::detail::InvalidArrayIndex_CRASH | mozilla::Array<T>::operator[] ] [@ mozilla::detail::InvalidArrayIndex_CRASH | mozilla::Array<T>::operator[] | mozilla::BitSet<T>::Reference::operator= | js::gc::ArenaChunk::fetchNextFreeArena ]

Crash report: https://crash-stats.mozilla.org/report/index/499caad6-7a40-471a-9dab-3624e0260821

MOZ_CRASH Reason:

ElementAt(aIndex = 576460752303423487, aLength = 8)

Top 10 frames:

0  mozglue.dll  mozilla::detail::InvalidArrayIndex_CRASH(unsigned long long, unsigned long long)  mfbt/Assertions.cpp:50
1  xul.dll  js::gc::TenuringTracer::promoteString(JSString*)  js/src/gc/Tenuring.cpp
2  xul.dll  js::gc::TenuringTracer::collectToObjectFixedPoint()  js/src/gc/Tenuring.cpp:1394
3  xul.dll  js::Nursery::doCollection(js::gc::AutoGCSession&, JS::GCOptions, JS::GCReason)  js/src/gc/Nursery.cpp:1567
4  xul.dll  js::Nursery::collect(JS::GCOptions, JS::GCReason)  js/src/gc/Nursery.cpp:1415
5  xul.dll  js::gc::GCRuntime::collectNursery(JS::GCOptions, JS::GCReason, js::gcstats::Phas...  js/src/gc/GC.cpp:5547
6  xul.dll  js::gc::GCRuntime::minorGC(JS::GCReason, js::gcstats::PhaseKind)  js/src/gc/GC.cpp:5516
7  xul.dll  std::_Func_impl_no_alloc<`lambda at .\..\..\..\..\checkouts\gecko\dom\base\CCGCS...
8  xul.dll  mozilla::IdleTaskRunner::Run()  xpcom/threads/IdleTaskRunner.cpp:124
9  xul.dll  mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail...  xpcom/threads/TaskController.cpp:1360

There is 1 crash in nightly 156 with buildid 20260820092744.

This signature is not new: its first report anywhere is in build 20251003115653 (2025-10-03), 321 days before the build above. (A 364-day crash-stats search only reaches 2026-01-06, because Socorro's search index keeps about six months — which is why the signature looks much newer there.)

Clouseau analysis (automated, 72% worth investigating — a calibrated estimate that this is worth someone's time, not that the changeset below caused it). The mechanism below fits the evidence but is not proven end-to-end:

The crash is a deterministic consequence of js::gc::ArenaChunk::fetchNextFreeArena calling freeCommittedArenas.FindFirst() on an entirely-empty BitSet<252,uint32_t> and using its SIZE_MAX not-found sentinel as an array index (SIZE_MAX/32 = 576460752303423487, exactly the crash's aIndex) — meaning info.numArenasFreeCommitted (a separate counter) said an arena was free-and-committed while the bitmap itself held none. This desync points at the lock-free "current chunk" allocation fast path in js::gc::ArenaLists::refillFreeListAndAllocate (introduced by bug 1957074, eeb7bca5fead, Jon Coppeard, 2025-04-03), which lets the main thread mutate this bitmap without the GC lock when a chunk is already zone_->currentChunk_, while js::gc::ArenaChunk::decommitFreeArenas mutates the same fields from a background thread under lock with only a re-check-after-unlock guard against the current-chunk case. The same author's later bug 1971961 (8a522039807e, 2025-08-18, "Avoid race while verifing chunk info") added debug-only verify() consistency checks to exactly this bitmap/counter pairing in the same file, confirming this area has a known history of such races — but I could not pinpoint the exact racing write, so this is a domain hypothesis, not a proven chain.

The 321-day-old, single-report-per-year rarity of this signature is consistent with a hard-to-hit race rather than a common logic bug, and the exact SIZE_MAX/32 arithmetic match argues against a hardware bit-flip (which would produce a random value, not a precise sentinel-derived one) despite the crash's own hardware-annotation fields being uninformative at N=1. Neither seed candidate (4bf6eb5d5bf0 bug 2061316, 93d10d0f30e1 bug 2038724) touches freeCommittedArenas, ArenaChunk, or any GC locking, and both landed only 1-3 days before this crash against a signature already 320+ days old — they are noise for this signature, not its cause or amplifier.

Starting point — NOT a suspected cause: eeb7bca5fead (bug 1957074) by Jon Coppeard.

This changeset did not land in this build's pushlog window, so there is no evidence here that the crash is a recent regression from it; it is named only as the closest thing found on the crash path. If you know where this actually comes from, that correction is the most useful thing you could leave on this bug.

Code references:

What the automated skeptic pass checked (its own words — a pass means the check succeeded, which is not always support for the conclusion):

  • unverifiable race_hypothesis — Lock-free current-chunk fast path (bug 1957074) and same-author prior race fix in the same file (bug 1971961) are real and cited, but no specific unsynchronized read/write was pinpointed connecting them to this exact desync — plausible domain link, not a proven data race.
  • pass mechanism_arithmetic — Independently recomputed SIZE_MAX/32=576460752303423487 and kNumWords=8; exact match to crash aIndex/aLength is deterministic, not coincidental — rules out a random hardware bit-flip as the proximate trigger.
  • pass seed_candidate_4bf6eb5d5bf0 — Confirmed noise: only touches Nursery.cpp::IsWriteableAddress, an unrelated buffer-validity check; does not touch freeCommittedArenas/ArenaChunk/locking.
  • pass seed_candidate_93d10d0f30e1 — Confirmed noise: removes Windows BCryptGenRandom init in sandbox/mozglue/xre; zero overlap with GC.

:jonco, can you have a look please?

Filed automatically by Clouseau, which analyses nightly crashes with an LLM. Nothing above was written or checked by a human. Please close it as INVALID if it is wrong — that is useful feedback, not a nuisance.

You need to log in before you can comment on or make changes to this bug.