Assertion failure: result.tenuredBytes <= (previousGC.nurseryUsedBytes - (NurseryChunkHeaderSize * previousGC.nurseryUsedChunkCount)), at js/src/gc/Nursery.cpp:1432
Categories
(Core :: JavaScript Engine, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr115 | --- | unaffected |
| firefox-esr128 | --- | unaffected |
| firefox138 | --- | unaffected |
| firefox139 | --- | unaffected |
| firefox140 | --- | verified |
People
(Reporter: decoder, Assigned: sfink)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: assertion, regression, testcase, Whiteboard: [bugmon:update,bisected,confirmed])
Attachments
(2 files, 1 external file)
The following testcase crashes on mozilla-central revision 20250511-e473aa82ffe1 (debug build, run with --fuzzing-safe --ion-offthread-compile=off):
a = `
MY YOUNGEST MEMORY IS OF A TOE A GIANT BLUE TOE IT MADE FUN OF ME
INCESSANTLY BUT THAT DID NOT BOTHER ME IN THE LEAST. MY MOTHER WOULD
HAVE BEEN HORRIFIED BUT SHE WAS A GOOSE AND HAD ALREADY LAID THE EGG
THAT CONTAINED ME SO SHE DID NOT ESPECIALLY CARE AND THOUGHT THAT IT
WOULD E GOOD TO E TOUGHENED UP.
`;
b = newString(a);
c = newDependentString(b, 5, {
tenured: true
});
d = newDependentString(c, 1, {
'suppress-contraction': true
});
Backtrace:
received signal SIGSEGV, Segmentation fault.
#0 0x00005555579abaa2 in js::Nursery::collect(JS::GCOptions, JS::GCReason) ()
#1 0x0000555557956d0a in js::gc::GCRuntime::collectNursery(JS::GCOptions, JS::GCReason, js::gcstats::PhaseKind) ()
#2 0x000055555794d732 in js::gc::GCRuntime::collectNurseryFromMajorGC(JS::GCReason) ()
#3 0x000055555794ce63 in js::gc::GCRuntime::endPreparePhase(JS::GCReason) ()
#4 0x000055555795582f in js::gc::GCRuntime::incrementalSlice(JS::SliceBudget&, JS::GCReason, bool) ()
#5 0x0000555557959593 in js::gc::GCRuntime::gcCycle(bool, JS::SliceBudget const&, JS::GCReason) ()
#6 0x000055555795ae04 in js::gc::GCRuntime::collect(bool, JS::SliceBudget const&, JS::GCReason) ()
#7 0x000055555794114a in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) ()
#8 0x0000555557392454 in JSRuntime::destroyRuntime() ()
#9 0x0000555557237480 in js::DestroyContext(JSContext*) ()
#10 0x0000555556ebe189 in main ()
rax 0x0 0
rbx 0x7ffff46329e8 140737293527528
rcx 0x598 1432
rdx 0x1 1
rsi 0x0 0
rdi 0x7ffff7bee7d0 140737349871568
rbp 0x7fffffffd840 140737488345152
rsp 0x7fffffffd790 140737488344976
r8 0x0 0
r9 0x3 3
r10 0x0 0
r11 0x0 0
r12 0xc7200000 3340763136
r13 0xb 11
r14 0x908 2312
r15 0x2 2
rip 0x5555579abaa2 <js::Nursery::collect(JS::GCOptions, JS::GCReason)+3138>
=> 0x5555579abaa2 <_ZN2js7Nursery7collectEN2JS9GCOptionsENS1_8GCReasonE+3138>: mov %rcx,(%rax)
0x5555579abaa5 <_ZN2js7Nursery7collectEN2JS9GCOptionsENS1_8GCReasonE+3141>: callq 0x555556f58910 <abort>
This test raises some concerns:
-
It looks like the string has to have a certain length but I wasn't able to replace it with a generic string that just doubled itself a few times, can you clarify on the requirements and do we have shell options to tune this so it becomes easier to hit each case here?
-
Can you elaborate on the various options of "newDependentString" that should be tested?
Thanks!
| Reporter | ||
Comment 1•1 year ago
|
||
| Reporter | ||
Comment 2•1 year ago
|
||
Comment 3•1 year ago
|
||
It looks like this suppress-contraction thing from the test case was added in bug 1959310.
Comment 4•1 year ago
|
||
Verified bug as reproducible on mozilla-central 20250511205430-e473aa82ffe1.
The bug appears to have been introduced in the following build range:
Start: d26175655bd6c4934e45ff8f8130879c0f4c157b (20250508043248)
End: f54cbc744584916b02555ce7344256ae83e511e1 (20250507203432)
Pushlog: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=d26175655bd6c4934e45ff8f8130879c0f4c157b&tochange=f54cbc744584916b02555ce7344256ae83e511e1
Updated•1 year ago
|
| Assignee | ||
Comment 5•1 year ago
|
||
Yes. suppress-contraction is definitely worth testing with, though note that I'm pretty sure it can create situations that are impossible in practice. (It does something that would otherwise require setting up a rope and flattening it, and it's easy to perturb things in the process.)
newDependentString has two possible options in its flags argument: suppress-contraction and tenured. Both are (intended to be) booleans. Very different things will happen for different combinations of them, and when the given base string uses different combinations of them.
| Assignee | ||
Comment 6•1 year ago
|
||
Oh, and note that the length sensitivity is only going to get worse. Currently, the main factors going into where the length thresholds are:
- latin1 vs char16_t strings
- running on 32-bit vs 64-bit
- how the base string is allocated (
newString, as in your test case, is the most flexible way to control this. The optionstenured,newStringBuffer,shareStringBuffer,external/maybeExternal, and to a lesser degreecapacityall influence this. The only other option recognized bynewStringistwoByte, which helps with the first item in this list.)
Soon, I intend to add one more factor: the percentage of a base string's characters used by a dependent string. (So eg newDependentString(a, 0, 5) will give an inline string, newDependentString(a, 0, 20) will give a fat inline string, newDependentString(a + a + a, 0, 40) will give a regular linear string, and newDependentString(a, 0, a.length - 1) will give a dependent string.)
The current "size classes" are roughly:
- 64-bit:
- latin1: 0, 1-15, 16-23, 24-
- char16_t: 0, 1-7, 8-11, 12-
- 32-bit:
- latin1: 0, 1-7, 8-23, 24-
- char16_t: 0, 1-3, 4-11, 12-
These classes correspond to empty strings, thin inline strings, fat inline strings, non-inline linear strings.
Later on, there will also be a threshold at some fraction, current 1/16, of the "root base string". That's the string passed as the 1st argument to newDependentString, or its base string if it is itself a dependent string.
| Assignee | ||
Comment 7•1 year ago
|
||
The size classes aren't going to be all that relevant here. The problem is a fairly simple double-counting issue, and it's going to trigger based on everything else being tenured in the same minor GC. Usually when the problem happens it will not be detected because it's hiding behind stuff that did not get tenured.
It turns out to not be s-s, it just makes the tenured percentage slightly off (and could cause it to go above 100% in weird cases, like the included test case.)
| Assignee | ||
Comment 8•1 year ago
|
||
Updated•1 year ago
|
Updated•1 year ago
|
Comment 10•1 year ago
|
||
| bugherder | ||
Comment 11•1 year ago
|
||
Verified bug as fixed on rev mozilla-central 20250517213057-99bb697dd65f.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.
Description
•