Closed Bug 1995441 Opened 1 year ago Closed 1 year ago

AddressSanitizer: heap-use-after-free in js::gc::ArenaChunk::isNurseryChunk() running jsapi-tests testSortedArenaList

Categories

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

defect

Tracking

()

RESOLVED FIXED
146 Branch
Tracking Status
firefox146 --- fixed

People

(Reporter: csmantle, Assigned: csmantle)

References

(Blocks 1 open bug)

Details

(Keywords: reporter-external)

Attachments

(2 files, 1 external file)

Attached file mozconfig —

ASan logs:

$ ./mach jsapi-tests testSortedArenaList
Creating the 'common' site at /home/csmantle/.mozbuild/srcdirs/mozilla-firefox-dev-2ddf79ca1d57/_virtualenvs/common
testSortedArenaList
=================================================================
==2286142==ERROR: AddressSanitizer: heap-use-after-free on address 0x0021da700000 at pc 0x002add68109a bp 0x003fd81ca530 sp 0x003fd81ca518
READ of size 8 at 0x0021da700000 thread T0
    #0 0x002add681098 in js::gc::ArenaChunk::isNurseryChunk() const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40
    #1 0x002add681098 in js::gc::ArenaChunk::withinValidRange(unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:487:40
    #2 0x002add681098 in js::gc::Arena::checkAddress() const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:590:3
    #3 0x002add681098 in js::gc::FreeSpan::checkSpan(js::gc::Arena const*) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:443:10
    #4 0x002addb20770 in js::gc::FreeSpan::nextSpan(js::gc::Arena const*) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:101:5
    #5 0x002addb20770 in js::gc::ArenaCellIter::settle() /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/GC-inl.h:77:20
    #6 0x002adec7e854 in js::gc::ArenaCellIter::ArenaCellIter(js::gc::Arena*) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/GC-inl.h:91:5
    #7 0x002adec7e854 in js::gc::Arena::checkNoMarkedCells() /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.cpp:153:22
    #8 0x002add67eccc in AutoTestArena::AutoTestArena(JSContext*, js::gc::AllocKind, unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/testSortedArenaList.cpp:29:12
    #9 0x002add67e4f0 in cls_testSortedArenaList::run(JS::Handle<JSObject*>) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/testSortedArenaList.cpp:60:19
    #10 0x002add757b56 in main::$_1::operator()(JSAPIRuntimeTest*) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:267:51
    #11 0x002add757b56 in void RunTests<JSAPIRuntimeTest, main::$_0, main::$_1, main::$_2>(int&, int&, CommandOptions&, JSAPITestList<JSAPIRuntimeTest>, main::$_0, main::$_1, main::$_2) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:198:9
    #12 0x002add757b56 in main /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:262:5
    #13 0x003fa3aa3a58 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #14 0x003fa3aa3b04 in __libc_start_main csu/libc-start.c:360:3
    #15 0x002add23c57e in _start (/home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/bin/jsapi-tests+0x2b5857e) (BuildId: 33da86be33824e9693a1e11edc359db9)

0x0021da700000 is located 1792 bytes inside of 5120-byte region [0x0021da6ff900,0x0021da700d00)
freed by thread T0 here:
    #0 0x002add2ba78c in free (/home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/bin/jsapi-tests+0x2bd678c) (BuildId: 33da86be33824e9693a1e11edc359db9)
    #1 0x002adedbc3be in js_free(void*) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/js/Utility.h:434:3
    #2 0x002adedbc3be in void js::AllocPolicyBase::free_<mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FakeSlot>(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FakeSlot*, unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/js/AllocPolicy.h:88:5
    #3 0x002adedbc3be in mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::freeTable(js::SystemAllocPolicy&, char*, unsigned int) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:1730:18
    #4 0x002adedbc3be in mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::changeTableSize(unsigned int, mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FailureBehavior) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:1916:5
    #5 0x002adedcbd1c in mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::rehashIfOverloaded(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FailureBehavior) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:1940:12
    #6 0x002adedcbd1c in bool mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::add<js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&>(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::AddPtr&, js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:2195:30
    #7 0x002aded9f406 in bool mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::add<js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&>(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::AddPtr&, js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:346:18
    #8 0x002aded9f406 in js::gc::MemoryTracker::trackGCMemory(js::gc::Cell*, unsigned long, js::MemoryUse) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Scheduling.cpp:678:14
    #9 0x002adda389ac in js::ZoneAllocator::addCellMemory(js::gc::Cell*, unsigned long, js::MemoryUse) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/ZoneAllocator.h:76:19
    #10 0x002addd37026 in JSAtom* JSAtom::newValidLength<unsigned char>(JSContext*, JSString::OwnedChars<unsigned char>&, unsigned int) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/StringType-inl.h:595:15
    #11 0x002ade1547b0 in JSAtom* js::NewAtomCopyNDontDeflateValidLength<unsigned char>(JSContext*, unsigned char const*, unsigned long, unsigned int) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/StringType.cpp:2259:10
    #12 0x002addcd1a1c in JSAtom* AllocateNewPermanentAtomNonStaticValidLength<unsigned char>(JSContext*, unsigned char const*, unsigned long, js::AtomHasher::Lookup const&) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:641:7
    #13 0x002addcd1a1c in JSAtom* PermanentlyAtomizeAndCopyCharsNonStaticValidLength<unsigned char>(JSContext*, js::AtomSet&, unsigned char const*, unsigned long, js::AtomHasher::Lookup const&) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:519:7
    #14 0x002addccb64a in js::PermanentlyAtomizeCharsNonStaticValidLength(JSContext*, js::AtomSet&, unsigned int, unsigned char const*, unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:843:10
    #15 0x002adea9ada4 in js::frontend::ParserAtom::instantiatePermanentAtom(JSContext*, js::FrontendContext*, js::AtomSet&, js::frontend::TypedIndex<js::frontend::ParserAtom>, js::frontend::CompilationAtomCache&) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/frontend/ParserAtom.cpp:192:18
    #16 0x002adeaa3f50 in js::frontend::InstantiateMarkedAtomsAsPermanent(JSContext*, js::FrontendContext*, js::AtomSet&, mozilla::Span<js::frontend::ParserAtom*, 18446744073709551615ul> const&, js::frontend::CompilationAtomCache&) /home/csmantle/workspace/mozilla-firefox-dev/js/src/frontend/ParserAtom.cpp:1211:17
    #17 0x002adeadb8ea in js::frontend::CompilationStencil::instantiateSelfHostedAtoms(JSContext*, js::AtomSet&, js::frontend::CompilationAtomCache&) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/frontend/Stencil.cpp:2891:10
    #18 0x002addcca6c8 in JSRuntime::initializeAtoms(JSContext*) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:205:41
    #19 0x002addc7febc in JS::InitSelfHostedCode(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>, bool (*)(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>)) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/Initialization.cpp:226:12
    #20 0x002add756216 in JSAPIRuntimeTest::init(JSContext*) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:41:8
    #21 0x002add757b2e in main::$_0::operator()(JSAPIRuntimeTest*) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:265:24
    #22 0x002add757b2e in void RunTests<JSAPIRuntimeTest, main::$_0, main::$_1, main::$_2>(int&, int&, CommandOptions&, JSAPITestList<JSAPIRuntimeTest>, main::$_0, main::$_1, main::$_2) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:191:10
    #23 0x002add757b2e in main /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:262:5
    #24 0x003fa3aa3a58 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #25 0x003fa3aa3b04 in __libc_start_main csu/libc-start.c:360:3
    #26 0x002add23c57e in _start (/home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/bin/jsapi-tests+0x2b5857e) (BuildId: 33da86be33824e9693a1e11edc359db9)

previously allocated by thread T0 here:
    #0 0x002add2ba894 in malloc (/home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/bin/jsapi-tests+0x2bd6894) (BuildId: 33da86be33824e9693a1e11edc359db9)
    #1 0x002adedbc6f8 in mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::createTable(js::SystemAllocPolicy&, unsigned int, mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FailureBehavior) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/js/Utility.h
    #2 0x002adedbc2bc in mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::changeTableSize(unsigned int, mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FailureBehavior) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:1893:22
    #3 0x002adedcbd1c in mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::rehashIfOverloaded(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::FailureBehavior) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:1940:12
    #4 0x002adedcbd1c in bool mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::add<js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&>(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::AddPtr&, js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:2195:30
    #5 0x002aded9f406 in bool mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::add<js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&>(mozilla::detail::HashTable<mozilla::HashMapEntry<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long>, mozilla::HashMap<js::gc::MemoryTracker::Key<js::gc::Cell>, unsigned long, js::gc::MemoryTracker::Hasher<js::gc::Cell>, js::SystemAllocPolicy>::MapHashPolicy, js::SystemAllocPolicy>::AddPtr&, js::gc::MemoryTracker::Key<js::gc::Cell>&, unsigned long&) /home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/include/mozilla/HashTable.h:346:18
    #6 0x002aded9f406 in js::gc::MemoryTracker::trackGCMemory(js::gc::Cell*, unsigned long, js::MemoryUse) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Scheduling.cpp:678:14
    #7 0x002adda389ac in js::ZoneAllocator::addCellMemory(js::gc::Cell*, unsigned long, js::MemoryUse) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/ZoneAllocator.h:76:19
    #8 0x002addd37026 in JSAtom* JSAtom::newValidLength<unsigned char>(JSContext*, JSString::OwnedChars<unsigned char>&, unsigned int) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/StringType-inl.h:595:15
    #9 0x002ade1547b0 in JSAtom* js::NewAtomCopyNDontDeflateValidLength<unsigned char>(JSContext*, unsigned char const*, unsigned long, unsigned int) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/StringType.cpp:2259:10
    #10 0x002addcd1a1c in JSAtom* AllocateNewPermanentAtomNonStaticValidLength<unsigned char>(JSContext*, unsigned char const*, unsigned long, js::AtomHasher::Lookup const&) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:641:7
    #11 0x002addcd1a1c in JSAtom* PermanentlyAtomizeAndCopyCharsNonStaticValidLength<unsigned char>(JSContext*, js::AtomSet&, unsigned char const*, unsigned long, js::AtomHasher::Lookup const&) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:519:7
    #12 0x002addccb64a in js::PermanentlyAtomizeCharsNonStaticValidLength(JSContext*, js::AtomSet&, unsigned int, unsigned char const*, unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:843:10
    #13 0x002adea9ada4 in js::frontend::ParserAtom::instantiatePermanentAtom(JSContext*, js::FrontendContext*, js::AtomSet&, js::frontend::TypedIndex<js::frontend::ParserAtom>, js::frontend::CompilationAtomCache&) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/frontend/ParserAtom.cpp:192:18
    #14 0x002adeaa3f50 in js::frontend::InstantiateMarkedAtomsAsPermanent(JSContext*, js::FrontendContext*, js::AtomSet&, mozilla::Span<js::frontend::ParserAtom*, 18446744073709551615ul> const&, js::frontend::CompilationAtomCache&) /home/csmantle/workspace/mozilla-firefox-dev/js/src/frontend/ParserAtom.cpp:1211:17
    #15 0x002adeadb8ea in js::frontend::CompilationStencil::instantiateSelfHostedAtoms(JSContext*, js::AtomSet&, js::frontend::CompilationAtomCache&) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/frontend/Stencil.cpp:2891:10
    #16 0x002addcca6c8 in JSRuntime::initializeAtoms(JSContext*) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/JSAtomUtils.cpp:205:41
    #17 0x002addc7febc in JS::InitSelfHostedCode(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>, bool (*)(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>)) /home/csmantle/workspace/mozilla-firefox-dev/js/src/vm/Initialization.cpp:226:12
    #18 0x002add756216 in JSAPIRuntimeTest::init(JSContext*) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:41:8
    #19 0x002add757b2e in main::$_0::operator()(JSAPIRuntimeTest*) const /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:265:24
    #20 0x002add757b2e in void RunTests<JSAPIRuntimeTest, main::$_0, main::$_1, main::$_2>(int&, int&, CommandOptions&, JSAPITestList<JSAPIRuntimeTest>, main::$_0, main::$_1, main::$_2) /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:191:10
    #21 0x002add757b2e in main /home/csmantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:262:5
    #22 0x003fa3aa3a58 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #23 0x003fa3aa3b04 in __libc_start_main csu/libc-start.c:360:3
    #24 0x002add23c57e in _start (/home/csmantle/workspace/mozilla-firefox-dev/obj-riscv64-unknown-linux-gnu/dist/bin/jsapi-tests+0x2b5857e) (BuildId: 33da86be33824e9693a1e11edc359db9)

SUMMARY: AddressSanitizer: heap-use-after-free /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40 in js::gc::ArenaChunk::isNurseryChunk() const
Shadow bytes around the buggy address:
  0x0021da6ffd80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da6ffe00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da6ffe80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da6fff00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da6fff80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0021da700000:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da700080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da700100: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da700180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da700200: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0021da700280: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==2286142==ABORTING
jsapi-tests failed, exit code 1 

It seems that the pointer is some random one, since re-running the test three more times produces the following crashes respectively:

==2287019==ERROR: AddressSanitizer: SEGV on unknown address 0x0021abd00000 (pc 0x002aaecbfd20 bp 0x003fe8ae44c0 sp 0x003fe8ae4470 T0)
==2287019==The signal is caused by a READ memory access.
    #0 0x002aaecbfd20 in js::gc::ArenaChunk::isNurseryChunk() const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40
    #1 0x002aaecbfd20 in js::gc::ArenaChunk::withinValidRange(unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:487:40
[...]

==2287209==ERROR: AddressSanitizer: heap-use-after-free on address 0x0021e4d00000 at pc 0x002ae7c7f09a bp 0x003fe9b3c470 sp 0x003fe9b3c458
READ of size 8 at 0x0021e4d00000 thread T0
    #0 0x002ae7c7f098 in js::gc::ArenaChunk::isNurseryChunk() const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40
    #1 0x002ae7c7f098 in js::gc::ArenaChunk::withinValidRange(unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:487:40
[...]

==2287114==ERROR: AddressSanitizer: SEGV on unknown address 0x0021e7900000 (pc 0x002aea950d20 bp 0x003fe3fcb4c0 sp 0x003fe3fcb470 T0)
==2287114==The signal is caused by a READ memory access.
    #0 0x002aea950d20 in js::gc::ArenaChunk::isNurseryChunk() const /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40
    #1 0x002aea950d20 in js::gc::ArenaChunk::withinValidRange(unsigned long) /home/csmantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:487:40
[...]

Checkout:

commit 839a872511acc29b949c47ea90be604456846bd7
Author: Release Engineering Landoscript <release+landoscript@mozilla.com>
Date:   Sun Oct 19 00:10:04 2025 +0000

    No Bug - Import translations from https://github.com/mozilla-l10n/android-l10n CLOSED TREE

System info:

$ cat /proc/cpuinfo | head -n 11
processor       : 0
hart            : 0
model name      : Spacemit(R) X60
isa             : rv64imafdcv_zicbom_zicboz_zicntr_zicond_zicsr_zifencei_zihintpause_zihpm_zfh_zfhmin_zca_zcd_zba_zbb_zbc_zbs_zkt_zve32f_zve32x_zve64d_zve64f_zve64x_zvfh_zvfhmin_zvkt_sscofpmf_sstc_svinval_svnapot_svpbmt_ime
mmu             : sv39
uarch           : spacemit,x60
mvendorid       : 0x710
marchid         : 0x8000000058000001
mimpid          : 0x1000000049772200

processor       : 1
$ uname -a
Linux Milk-V-Jupiter-M1 6.6.63 #2.2.7.3 SMP PREEMPT Fri Aug 15 06:14:36 UTC 2025 riscv64 riscv64 riscv64 GNU/Linux
Summary: AddressSanitizer: heap-use-after-free in js::gc::ArenaChunk::isNurseryChunk() running jsapi-tests testSortedArenaList on riscv64 Spacemit M1 → AddressSanitizer: heap-use-after-free in js::gc::ArenaChunk::isNurseryChunk() running jsapi-tests testSortedArenaList on riscv64 Jupiter M1

I can see this crash stably on a native x86 build now -- Is it another ASan incompatibility/bug or something worth investigating?

$ ./obj-native/dist/bin/jsapi-tests testSortedArenaList
testSortedArenaList
=================================================================
==417286==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x521000000000 at pc 0x55a87c2a7a55 bp 0x7ffd52e4fa70 sp 0x7ffd52e4fa68
READ of size 8 at 0x521000000000 thread T0
    #0 0x55a87c2a7a54 in js::gc::ArenaChunk::isNurseryChunk() const /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40
    #1 0x55a87c2a7a54 in js::gc::ArenaChunk::withinValidRange(unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:487:40
    #2 0x55a87c2a7a54 in js::gc::Arena::checkAddress() const /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:590:3
    #3 0x55a87c2a7a54 in js::gc::FreeSpan::checkSpan(js::gc::Arena const*) const /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:443:10
    #4 0x55a87c7c6295 in js::gc::FreeSpan::nextSpan(js::gc::Arena const*) const /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:101:5
    #5 0x55a87c7c6295 in js::gc::ArenaCellIter::settle() /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/GC-inl.h:77:20
    #6 0x55a87db1e06a in js::gc::ArenaCellIter::ArenaCellIter(js::gc::Arena*) /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/GC-inl.h:91:5
    #7 0x55a87db1e06a in js::gc::Arena::checkNoMarkedCells() /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.cpp:153:22
    #8 0x55a87c2a4a06 in AutoTestArena::AutoTestArena(JSContext*, js::gc::AllocKind, unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/testSortedArenaList.cpp:29:12
    #9 0x55a87c2a4072 in cls_testSortedArenaList::run(JS::Handle<JSObject*>) /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/testSortedArenaList.cpp:60:19
    #10 0x55a87c39ab8c in main::$_1::operator()(JSAPIRuntimeTest*) const /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:267:51
    #11 0x55a87c39ab8c in void RunTests<JSAPIRuntimeTest, main::$_0, main::$_1, main::$_2>(int&, int&, CommandOptions&, JSAPITestList<JSAPIRuntimeTest>, main::$_0, main::$_1, main::$_2) /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:198:9
    #12 0x55a87c39ab8c in main /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:262:5
    #13 0x7f3a61627674  (/usr/lib/libc.so.6+0x27674) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
    #14 0x7f3a61627728 in __libc_start_main (/usr/lib/libc.so.6+0x27728) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
    #15 0x55a87bdb51e8 in _start (/home/mantle/workspace/mozilla-firefox-dev/obj-native/dist/bin/jsapi-tests+0x2cc51e8) (BuildId: 1a31c2186115486b8bf4ff942041d32f)

0x521000000000 is located 256 bytes before 4096-byte region [0x521000000100,0x521000001100)
allocated by thread T0 here:
    #0 0x55a87be52adf in malloc /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:68:3
    #1 0x55a87d2c5c1c in js_arena_malloc(unsigned long, unsigned long) /home/mantle/workspace/mozilla-firefox-dev/obj-native/dist/include/js/Utility.h:386:10
    #2 0x55a87d2c5c1c in js::detail::BumpChunk::newWithCapacity(unsigned long, unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/ds/LifoAlloc.cpp:26:15
    #3 0x55a87d2c6f34 in js::LifoAlloc::newChunkWithCapacity(unsigned long, bool) /home/mantle/workspace/mozilla-firefox-dev/js/src/ds/LifoAlloc.cpp:189:7
    #4 0x55a87d2c729d in js::LifoAlloc::getOrCreateChunk(unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/ds/LifoAlloc.cpp:221:30
    #5 0x55a87d2c761d in js::LifoAlloc::allocImplColdPath(unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/ds/LifoAlloc.cpp:231:30
    #6 0x55a87d8e4d11 in js::frontend::ParseNodeAllocator::allocNode(unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/ParseNode.cpp:52:19
    #7 0x55a87d68463a in js::frontend::FullParseHandler::allocParseNode(unsigned long) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/FullParseHandler.h:52:46
    #8 0x55a87d68463a in js::frontend::ListNode* js::frontend::FullParseHandler::new_<js::frontend::ListNode, js::frontend::ParseNodeKind, js::frontend::TokenPos const&>(js::frontend::ParseNodeKind&&, js::frontend::TokenPos const&) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/FullParseHandler.h:77:3
    #9 0x55a87d68463a in mozilla::Result<js::frontend::ListNode*, js::frontend::ParseNodeError> js::frontend::FullParseHandler::newResult<js::frontend::ListNode, js::frontend::ParseNodeKind, js::frontend::TokenPos const&>(js::frontend::ParseNodeKind&&, js::frontend::TokenPos const&) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/FullParseHandler.h:94:18
    #10 0x55a87d68463a in js::frontend::FullParseHandler::newStatementList(js::frontend::TokenPos const&) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/FullParseHandler.h:609:12
    #11 0x55a87d68463a in js::frontend::GeneralParser<js::frontend::FullParseHandler, mozilla::Utf8Unit>::statementList(js::frontend::YieldHandling) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/Parser.cpp:4021:27
    #12 0x55a87d7ad033 in js::frontend::Parser<js::frontend::FullParseHandler, mozilla::Utf8Unit>::globalBody(js::frontend::GlobalSharedContext*) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/Parser.cpp:1878:20
    #13 0x55a87d856d34 in ScriptCompiler<mozilla::Utf8Unit>::compile(JSContext*, js::frontend::SharedContext*) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/BytecodeCompiler.cpp:977:20
    #14 0x55a87d7d51d1 in bool CompileGlobalScriptToStencilAndMaybeInstantiate<mozilla::Utf8Unit>(JSContext*, js::FrontendContext*, js::LifoAlloc&, js::frontend::CompilationInput&, js::frontend::ScopeBindingCache*, JS::SourceText<mozilla::Utf8Unit>&, js::ScopeKind, mozilla::Vector<js::frontend::ExtraBindingInfo, 0ul, js::SystemAllocPolicy>*, js::frontend::CompilationStencil**, js::frontend::InitialStencilAndDelazifications**, js::frontend::CompilationGCOutput*) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/BytecodeCompiler.cpp:341:17
    #15 0x55a87d7d4c26 in js::frontend::CompileGlobalScriptToStencilWithInput(JSContext*, js::FrontendContext*, js::LifoAlloc&, js::frontend::CompilationInput&, js::frontend::ScopeBindingCache*, JS::SourceText<mozilla::Utf8Unit>&, js::ScopeKind) /home/mantle/workspace/mozilla-firefox-dev/js/src/frontend/BytecodeCompiler.cpp:376:8
    #16 0x55a87cd5bca4 in JSRuntime::initSelfHostingStencil(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>, bool (*)(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>)) /home/mantle/workspace/mozilla-firefox-dev/js/src/vm/SelfHosting.cpp:2301:7
    #17 0x55a87c944cd3 in JS::InitSelfHostedCode(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>, bool (*)(JSContext*, mozilla::Span<unsigned char const, 18446744073709551615ul>)) /home/mantle/workspace/mozilla-firefox-dev/js/src/vm/Initialization.cpp:222:12
    #18 0x55a87c399017 in JSAPIRuntimeTest::init(JSContext*) /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:41:8
    #19 0x55a87c39ab55 in main::$_0::operator()(JSAPIRuntimeTest*) const /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:265:24
    #20 0x55a87c39ab55 in void RunTests<JSAPIRuntimeTest, main::$_0, main::$_1, main::$_2>(int&, int&, CommandOptions&, JSAPITestList<JSAPIRuntimeTest>, main::$_0, main::$_1, main::$_2) /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:191:10
    #21 0x55a87c39ab55 in main /home/mantle/workspace/mozilla-firefox-dev/js/src/jsapi-tests/tests.cpp:262:5
    #22 0x7f3a61627674  (/usr/lib/libc.so.6+0x27674) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
    #23 0x7f3a61627728 in __libc_start_main (/usr/lib/libc.so.6+0x27728) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
    #24 0x55a87bdb51e8 in _start (/home/mantle/workspace/mozilla-firefox-dev/obj-native/dist/bin/jsapi-tests+0x2cc51e8) (BuildId: 1a31c2186115486b8bf4ff942041d32f)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/mantle/workspace/mozilla-firefox-dev/js/src/gc/Heap.h:528:40 in js::gc::ArenaChunk::isNurseryChunk() const
Shadow bytes around the buggy address:
  0x520ffffffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x520ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x520ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x520fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x520fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x521000000000:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x521000000080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x521000000100: 00 00 00 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x521000000180: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x521000000200: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x521000000280: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==417286==ABORTING
Attached file mozconfig.native —
Summary: AddressSanitizer: heap-use-after-free in js::gc::ArenaChunk::isNurseryChunk() running jsapi-tests testSortedArenaList on riscv64 Jupiter M1 → AddressSanitizer: heap-use-after-free in js::gc::ArenaChunk::isNurseryChunk() running jsapi-tests testSortedArenaList
Group: core-security → javascript-core-security

Jon, is there anything actionable in this bug?

Blocks: GC.stability
Severity: -- → S4
Flags: needinfo?(jcoppeard)
Priority: -- → P1
Severity: S4 → S3

I think the problem is that we manually allocate an Arena (^1) instead of fetching one from a valid ArenaChunk. This breaks many invariants assuming that every Arena must belong to some ArenaChunk, such as in (^2).

Each Arena is expected to be contained within a ArenaChunk. The
current test case breaks this invariant by directly js_pod_calloc-ing
an Arena instead of allocating one from a working ArenaChunk.

This patch addresses this by allocating an ArenaChunk, then obtaining
an Arena from it using regular methods. To force success, a new
wrapper class is created to ensure the existence of free Arenas.

Assignee: nobody → webmaster
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

This a problem in test code so is not a security issue.

Group: javascript-core-security
Flags: needinfo?(jcoppeard)
Attachment #9521566 - Attachment description: (secure) → Bug 1995441 - Allocate Arena-under-testing from a valid ArenaChunk in jsapi-tests/testSortedArenaList. r=jonco
Pushed by jcoppeard@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8d929c6b779e https://hg.mozilla.org/integration/autoland/rev/6cb5a87ce684 Allocate Arena-under-testing from a valid ArenaChunk in jsapi-tests/testSortedArenaList. r=jonco
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: