Skip to content
Memory corruption Disclosed report Advanced CVE-2022-45407

heap-use-after-free in font loading using FontFace from worker thread

Loading a user font via the FontFace constructor from a worker thread is not thread-safe, so the font's character map can be freed on one thread while another thread still reads it. An attacker could trigger a heap-use-after-free in the browser's content process, which may crash it and, in principle, allow memory corruption.

Armin Ebert Follow

Originally disclosed on Mozilla

  • Fixed in 24 days
  • Paid in 25 days
  • Disclosed after 24 days

Loading user fonts via FontFace() from workers isn't thread-safe and may cause a heap-use-after-free.

Two ASAN UAF samples on m-c-20220930214439-asan-opt:

C++
==521246==ERROR: AddressSanitizer: heap-use-after-free on address 0x6030001a4f88 at pc 0x7f0f6c3ca7b6 bp 0x7f0f5410c130 sp 0x7f0f5410c128
READ of size 8 at 0x6030001a4f88 thread T228
    #0 0x7f0f6c3ca7b5 in load /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/atomic_base.h:396:9
    #1 0x7f0f6c3ca7b5 in get /builds/worker/workspace/obj-build/dist/include/nsISupportsImpl.h:389:19
    #2 0x7f0f6c3ca7b5 in operator unsigned long /builds/worker/workspace/obj-build/dist/include/nsISupportsImpl.h:385:56
    #3 0x7f0f6c3ca7b5 in gfxCharacterMap::NotifyMaybeReleased() /builds/worker/checkouts/gecko/gfx/thebes/gfxFontEntry.cpp:63:7
    #4 0x7f0f72342cd7 in Release /builds/worker/workspace/obj-build/dist/include/gfxFontEntry.h:84:14
    #5 0x7f0f72342cd7 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #6 0x7f0f72342cd7 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #7 0x7f0f72342cd7 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #8 0x7f0f72342cd7 in mozilla::dom::FontFaceImpl::~FontFaceImpl() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:75:1
    #9 0x7f0f7233f976 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFaceImpl.h:37:3
    #10 0x7f0f7233f976 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #11 0x7f0f7233f976 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #12 0x7f0f7233f976 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #13 0x7f0f7233f976 in mozilla::dom::FontFace::~FontFace() /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:83:1
    #14 0x7f0f7235f200 in DeleteCycleCollectable /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:73:1
    #15 0x7f0f7235f200 in mozilla::dom::FontFace::cycleCollection::DeleteCycleCollectable(voibuilds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFace.h:44:3
    #16 0x7f0f69c1ded2 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2406:7
    #17 0x7f0f69c1d46e in nsCycleCollector::FreeSnowWhite(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2596:3
    #18 0x7f0f69c25424 in nsCycleCollector::BeginCollection(mozilla::CCReason, ccIsManual, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3585:3
    #19 0x7f0f69c24a4c in nsCycleCollector::Collect(mozilla::CCReason, ccIsManual, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3412:9
    #20 0x7f0f69c2813a in nsCycleCollector_collect(mozilla::CCReason, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3920:28
    #21 0x7f0f7156ca3d in mozilla::dom::workerinternals::(anonymous namespace)::WorkerJSRuntime::CustomGCCallback(JSGCStatus) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:816:11
    #22 0x7f0f69bd9338 in mozilla::CycleCollectedJSRuntime::OnGC(JSContext*, JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/xpcom/base/CycleCollectedJSRuntime.cpp:1884:3
    #23 0x7f0f77c1f298 in js::gc::GCRuntime::maybeCallGCCallback(JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3755:3
    #24 0x7f0f77c1fc6c in ~AutoCallGCCallbacks /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3728:32
    #25 0x7f0f77c1fc6c in js::gc::GCRuntime::gcCycle(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3845:1
    #26 0x7f0f77c21b20 in js::gc::GCRuntime::collect(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4027:9
    #27 0x7f0f77beca36 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4104:3
    #28 0x7f0f7156ae49 in mozilla::dom::workerinternals::(anonymous namespace)::WorkerThreadPrimaryRunnable::Run() /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:2084:7
    #29 0x7f0f69e0193e in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1199:16
    #30 0x7f0f69e0b594 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #31 0x7f0f6b415c38 in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:300:20
    #32 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #33 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #34 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #35 0x7f0f69df8a94 in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:384:10
    #36 0x7f0f8b5d7c0e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5
    #37 0x7f0f8bdb774c  (/usr/lib/libc.so.6+0x8674c) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)
    #38 0x7f0f8be396ff  (/usr/lib/libc.so.6+0x1086ff) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

0x6030001a4f88 is located 24 bytes inside of 32-byte region [0x6030001a4f70,0x6030001a4f90)
freed by thread T231 here:
    #0 0x55ffcf465ef2 in __interceptor_free /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
    #1 0x7f0f6c3ca782 in operator delete /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:51:10
    #2 0x7f0f6c3ca782 in gfxCharacterMap::NotifyMaybeReleased() /builds/worker/checkouts/gecko/gfx/thebes/gfxFontEntry.cpp:73:3
    #3 0x7f0f72342cd7 in Release /builds/worker/workspace/obj-build/dist/include/gfxFontEntry.h:84:14
    #4 0x7f0f72342cd7 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #5 0x7f0f72342cd7 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #6 0x7f0f72342cd7 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #7 0x7f0f72342cd7 in mozilla::dom::FontFaceImpl::~FontFaceImpl() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:75:1
    #8 0x7f0f7233f976 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFaceImpl.h:37:3
    #9 0x7f0f7233f976 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #10 0x7f0f7233f976 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #11 0x7f0f7233f976 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #12 0x7f0f7233f976 in mozilla::dom::FontFace::~FontFace() /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:83:1
    #13 0x7f0f7235f200 in DeleteCycleCollectable /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:73:1
    #14 0x7f0f7235f200 in mozilla::dom::FontFace::cycleCollection::DeleteCycleCollectable(void*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFace.h:44:3
    #15 0x7f0f69c1ded2 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2406:7
    #16 0x7f0f69c1d46e in nsCycleCollector::FreeSnowWhite(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2596:3
    #17 0x7f0f69c25424 in nsCycleCollector::BeginCollection(mozilla::CCReason, ccIsManual, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3585:3
    #18 0x7f0f69c24a4c in nsCycleCollector::Collect(mozilla::CCReason, ccIsManual, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3412:9
    #19 0x7f0f69c2813a in nsCycleCollector_collect(mozilla::CCReason, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3920:28
    #20 0x7f0f7156ca3d in mozilla::dom::workerinternals::(anonymous namespace)::WorkerJSRuntime::CustomGCCallback(JSGCStatus) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:816:11
    #21 0x7f0f69bd9338 in mozilla::CycleCollectedJSRuntime::OnGC(JSContext*, JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/xpcom/base/CycleCollectedJSRuntime.cpp:1884:3
    #22 0x7f0f77c1f298 in js::gc::GCRuntime::maybeCallGCCallback(JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3755:3
    #23 0x7f0f77c1fc6c in ~AutoCallGCCallbacks /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3728:32
    #24 0x7f0f77c1fc6c in js::gc::GCRuntime::gcCycle(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3845:1
    #25 0x7f0f77c21b20 in js::gc::GCRuntime::collect(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4027:9
    #26 0x7f0f77beca36 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4104:3
    #27 0x7f0f7156ae49 in mozilla::dom::workerinternals::(anonymous namespace)::WorkerThreadPrimaryRunnable::Run() /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:2084:7
    #28 0x7f0f69e0193e in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1199:16
    #29 0x7f0f69e0b594 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #30 0x7f0f6b415c38 in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:300:20
    #31 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #32 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #33 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #34 0x7f0f69df8a94 in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:384:10
    #35 0x7f0f8b5d7c0e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5
    #36 0x7f0f8bdb774c  (/usr/lib/libc.so.6+0x8674c) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

previously allocated by thread T0 (Isolated Web Co) here:
    #0 0x55ffcf46619e in malloc /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x55ffcf4aacb5 in moz_xmalloc /builds/worker/checkouts/gecko/memory/mozalloc/mozalloc.cpp:52:15
    #2 0x7f0f7234699c in operator new /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:33:10
    #3 0x7f0f7234699c in mozilla::dom::FontFaceImpl::GetUnicodeRangeAsCharacterMap() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:688:39
    #4 0x7f0f72354650 in mozilla::dom::FontFaceSetImpl::FindOrCreateUserFontEntryFromFontFace(nsTSubstring<char> const&, mozilla::dom::FontFaceImpl*, mozilla::StyleOrigin) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:458:47
    #5 0x7f0f72343fd1 in mozilla::dom::FontFaceSetImpl::FindOrCreateUserFontEntryFromFontFace(mozilla::dom::FontFaceImpl*) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:345:10
    #6 0x7f0f723440e1 in mozilla::dom::FontFaceImpl::CreateUserFontEntry() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:326:9
    #7 0x7f0f72343905 in mozilla::dom::FontFaceImpl::DoLoad() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:342:8
    #8 0x7f0f7236493f in operator() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:338:65
    #9 0x7f0f7236493f in mozilla::detail::RunnableFunction<mozilla::dom::FontFaceImpl::DoLoad()::$_9>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #10 0x7f0f69e1f6b2 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:538:16
    #11 0x7f0f69ddfdbd in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:851:26
    #12 0x7f0f69ddcf28 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:683:15
    #13 0x7f0f69ddd650 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:461:36
    #14 0x7f0f69e28714 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:190:37
    #15 0x7f0f69e28714 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_1>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #16 0x7f0f69e01117 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1205:16
    #17 0x7f0f69e0b594 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #18 0x7f0f6b414bfd in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:107:5
    #19 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #20 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #21 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #22 0x7f0f71ea4717 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:150:27
    #23 0x7f0f76d0f307 in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:880:20
    #24 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #25 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #26 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #27 0x7f0f76d0e22c in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:739:34
    #28 0x55ffcf4a3825 in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #29 0x55ffcf4a3c77 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:359:18
    #30 0x7f0f8bd5428f  (/usr/lib/libc.so.6+0x2328f) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

Thread T228 created by T0 (Isolated Web Co) here:
    #0 0x55ffcf44f6fc in __interceptor_pthread_create /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:208:3
    #1 0x7f0f8b5c7cbc in _PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14
    #2 0x7f0f8b5b905e in PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:533:12
    #3 0x7f0f69dfba15 in nsThread::Init(nsTSubstring<char> const&) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:618:18
    #4 0x7f0f715baa3a in mozilla::dom::WorkerThread::Create(mozilla::dom::WorkerThreadFriendKey const&) /builds/worker/checkouts/gecko/dom/workers/WorkerThread.cpp:102:7
    #5 0x7f0f71545e65 in mozilla::dom::workerinternals::RuntimeService::ScheduleWorker(mozilla::dom::WorkerPrivate&) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:1323:37
    #6 0x7f0f71544f8e in mozilla::dom::workerinternals::RuntimeService::RegisterWorker(mozilla::dom::WorkerPrivate&) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:1205:19
    #7 0x7f0f7158e557 in mozilla::dom::WorkerPrivate::Constructor(JSContext*, nsTSubstring<char16_t> const&, bool, mozilla::dom::WorkerKind, nsTSubstring<char16_t> const&, nsTSubstring<char> const&, mozilla::dom::WorkerLoadInfo*, mozilla::ErrorResult&, nsTString<char16_t>) /builds/worker/checkouts/gecko/dom/workers/WorkerPrivate.cpp:2588:24
    #8 0x7f0f71555525 in mozilla::dom::Worker::Constructor(mozilla::dom::GlobalObject const&, nsTSubstring<char16_t> const&, mozilla::dom::WorkerOptions const&, mozilla::ErrorResult&) /builds/worker/checkouts/gecko/dom/workers/Worker.cpp:43:41
    #9 0x7f0f6e33f2f4 in mozilla::dom::Worker_Binding::_constructor(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/obj-build/dom/bindings/WorkerBinding.cpp:1107:52
    #10 0x7f0f7882e937 in CallJSNative /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:458:13
    #11 0x7f0f7882e937 in CallJSNativeConstructor /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:474:8
    #12 0x7f0f7882e937 in InternalConstruct(JSContext*, js::AnyConstructArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:693:10
    #13 0x7f0f7881a99e in Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3359:16
    #14 0x7f0f787ffffe in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:430:13
    #15 0x7f0f7882c165 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:578:13
    #16 0x7f0f7882dc0e in InternalCall /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:613:10
    #17 0x7f0f7882dc0e in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:645:8
    #18 0x7f0f7717da05 in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/CallAndConstruct.cpp:117:10
    #19 0x7f0f6e7e05a7 in mozilla::dom::Function::Call(mozilla::dom::BindingCallContext&, JS::Handle<JS::Value>, nsTArray<JS::Value> const&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&) /builds/worker/workspace/obj-build/dom/bindings/FunctionBinding.cpp:50:8
    #20 0x7f0f6cd8932c in void mozilla::dom::Function::Call<nsCOMPtr<nsIGlobalObject> >(nsCOMPtr<nsIGlobalObject> const&, nsTArray<JS::Value> const&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObject::ExceptionHandling, JS::Realm*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FunctionBinding.h:71:12
    #21 0x7f0f6cd88f32 in mozilla::dom::CallbackTimeoutHandler::Call(char const*) /builds/worker/checkouts/gecko/dom/base/TimeoutHandler.cpp:167:29
    #22 0x7f0f6c9ae90b in nsGlobalWindowInner::RunTimeoutHandler(mozilla::dom::Timeout*, nsIScriptContext*) /builds/worker/checkouts/gecko/dom/base/nsGlobalWindowInner.cpp:6471:38
    #23 0x7f0f6cd852ab in mozilla::dom::TimeoutManager::RunTimeout(mozilla::TimeStamp const&, mozilla::TimeStamp const&, bool) /builds/worker/checkouts/gecko/dom/base/TimeoutManager.cpp:903:44
    #24 0x7f0f6cd8443a in mozilla::dom::TimeoutExecutor::MaybeExecute() /builds/worker/checkouts/gecko/dom/base/TimeoutExecutor.cpp:179:11
    #25 0x7f0f6cd86b1b in mozilla::dom::TimeoutExecutor::Run() /builds/worker/checkouts/gecko/dom/base/TimeoutExecutor.cpp:234:5
    #26 0x7f0f69e266b2 in mozilla::ThrottledEventQueue::Inner::ExecuteRunnable() /builds/worker/checkouts/gecko/xpcom/threads/ThrottledEventQueue.cpp:254:22
    #27 0x7f0f69e1922f in mozilla::ThrottledEventQueue::Inner::Executor::Run() /builds/worker/checkouts/gecko/xpcom/threads/ThrottledEventQueue.cpp:81:15
    #28 0x7f0f69e1f6b2 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:538:16
    #29 0x7f0f69ddfdbd in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:851:26
    #30 0x7f0f69ddcf28 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:683:15
    #31 0x7f0f69ddd650 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:461:36
    #32 0x7f0f69e286e1 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:187:37
    #33 0x7f0f69e286e1 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #34 0x7f0f69e01117 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1205:16
    #35 0x7f0f69e0b594 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #36 0x7f0f6b414a88 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21
    #37 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #38 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #39 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #40 0x7f0f71ea4717 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:150:27
    #41 0x7f0f76d0f307 in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:880:20
    #42 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #43 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #44 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #45 0x7f0f76d0e22c in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:739:34
    #46 0x55ffcf4a3825 in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #47 0x55ffcf4a3c77 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:359:18
    #48 0x7f0f8bd5428f  (/usr/lib/libc.so.6+0x2328f) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

Thread T231 created by T0 (Isolated Web Co) here:
    #0 0x55ffcf44f6fc in __interceptor_pthread_create /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:208:3
    #1 0x7f0f8b5c7cbc in _PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14
    #2 0x7f0f8b5b905e in PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:533:12
    #3 0x7f0f69dfba15 in nsThread::Init(nsTSubstring<char> const&) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:618:18
    #4 0x7f0f715baa3a in mozilla::dom::WorkerThread::Create(mozilla::dom::WorkerThreadFriendKey const&) /builds/worker/checkouts/gecko/dom/workers/WorkerThread.cpp:102:7
    #5 0x7f0f71545e65 in mozilla::dom::workerinternals::RuntimeService::ScheduleWorker(mozilla::dom::WorkerPrivate&) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:1323:37
    #6 0x7f0f71544f8e in mozilla::dom::workerinternals::RuntimeService::RegisterWorker(mozilla::dom::WorkerPrivate&) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:1205:19
    #7 0x7f0f7158e557 in mozilla::dom::WorkerPrivate::Constructor(JSContext*, nsTSubstring<char16_t> const&, bool, mozilla::dom::WorkerKind, nsTSubstring<char16_t> const&, nsTSubstring<char> const&, mozilla::dom::WorkerLoadInfo*, mozilla::ErrorResult&, nsTString<char16_t>) /builds/worker/checkouts/gecko/dom/workers/WorkerPrivate.cpp:2588:24
    #8 0x7f0f71555525 in mozilla::dom::Worker::Constructor(mozilla::dom::GlobalObject const&, nsTSubstring<char16_t> const&, mozilla::dom::WorkerOptions const&, mozilla::ErrorResult&) /builds/worker/checkouts/gecko/dom/workers/Worker.cpp:43:41
    #9 0x7f0f6e33f2f4 in mozilla::dom::Worker_Binding::_constructor(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/obj-build/dom/bindings/WorkerBinding.cpp:1107:52
    #10 0x7f0f7882e937 in CallJSNative /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:458:13
    #11 0x7f0f7882e937 in CallJSNativeConstructor /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:474:8
    #12 0x7f0f7882e937 in InternalConstruct(JSContext*, js::AnyConstructArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:693:10
    #13 0x7f0f7881a99e in Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3359:16
    #14 0x7f0f787ffffe in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:430:13
    #15 0x7f0f7882c165 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:578:13
    #16 0x7f0f7882dc0e in InternalCall /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:613:10
    #17 0x7f0f7882dc0e in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:645:8
    #18 0x7f0f7717da05 in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/CallAndConstruct.cpp:117:10
    #19 0x7f0f6e7e05a7 in mozilla::dom::Function::Call(mozilla::dom::BindingCallContext&, JS::Handle<JS::Value>, nsTArray<JS::Value> const&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&) /builds/worker/workspace/obj-build/dom/bindings/FunctionBinding.cpp:50:8
    #20 0x7f0f6cd8932c in void mozilla::dom::Function::Call<nsCOMPtr<nsIGlobalObject> >(nsCOMPtr<nsIGlobalObject> const&, nsTArray<JS::Value> const&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObject::ExceptionHandling, JS::Realm*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FunctionBinding.h:71:12
    #21 0x7f0f6cd88f32 in mozilla::dom::CallbackTimeoutHandler::Call(char const*) /builds/worker/checkouts/gecko/dom/base/TimeoutHandler.cpp:167:29
    #22 0x7f0f6c9ae90b in nsGlobalWindowInner::RunTimeoutHandler(mozilla::dom::Timeout*, nsIScriptContext*) /builds/worker/checkouts/gecko/dom/base/nsGlobalWindowInner.cpp:6471:38
    #23 0x7f0f6cd852ab in mozilla::dom::TimeoutManager::RunTimeout(mozilla::TimeStamp const&, mozilla::TimeStamp const&, bool) /builds/worker/checkouts/gecko/dom/base/TimeoutManager.cpp:903:44
    #24 0x7f0f6cd8443a in mozilla::dom::TimeoutExecutor::MaybeExecute() /builds/worker/checkouts/gecko/dom/base/TimeoutExecutor.cpp:179:11
    #25 0x7f0f6cd86b1b in mozilla::dom::TimeoutExecutor::Run() /builds/worker/checkouts/gecko/dom/base/TimeoutExecutor.cpp:234:5
    #26 0x7f0f69e266b2 in mozilla::ThrottledEventQueue::Inner::ExecuteRunnable() /builds/worker/checkouts/gecko/xpcom/threads/ThrottledEventQueue.cpp:254:22
    #27 0x7f0f69e1922f in mozilla::ThrottledEventQueue::Inner::Executor::Run() /builds/worker/checkouts/gecko/xpcom/threads/ThrottledEventQueue.cpp:81:15
    #28 0x7f0f69e1f6b2 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:538:16
    #29 0x7f0f69ddfdbd in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:851:26
    #30 0x7f0f69ddcf28 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:683:15
    #31 0x7f0f69ddd650 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:461:36
    #32 0x7f0f69e286e1 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:187:37
    #33 0x7f0f69e286e1 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #34 0x7f0f69e01117 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1205:16
    #35 0x7f0f69e0b594 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #36 0x7f0f6b414a88 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21
    #37 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #38 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #39 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #40 0x7f0f71ea4717 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:150:27
    #41 0x7f0f76d0f307 in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:880:20
    #42 0x7f0f6b2b1361 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #43 0x7f0f6b2b1361 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #44 0x7f0f6b2b1361 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #45 0x7f0f76d0e22c in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:739:34
    #46 0x55ffcf4a3825 in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #47 0x55ffcf4a3c77 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:359:18
    #48 0x7f0f8bd5428f  (/usr/lib/libc.so.6+0x2328f) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/atomic_base.h:396:9 in load
Shadow bytes around the buggy address:
  0x0c068002c9a0: fd fd fd fd fa fa fd fd fd fd fa fa fd fd fd fd
  0x0c068002c9b0: fa fa fd fd fd fd fa fa fd fd fd fd fa fa fd fd
  0x0c068002c9c0: fd fd fa fa fd fd fd fd fa fa fd fd fd fd fa fa
  0x0c068002c9d0: fd fd fd fd fa fa fd fd fd fd fa fa fd fd fd fd
  0x0c068002c9e0: fa fa fd fd fd fd fa fa fd fd fd fd fa fa fd fd
=>0x0c068002c9f0: fd[fd]fa fa fd fd fd fa fa fa fd fd fd fd fa fa
  0x0c068002ca00: 00 00 00 00 fa fa 00 00 00 fa fa fa fd fd fd fd
  0x0c068002ca10: fa fa fd fd fd fd fa fa fd fd fd fd fa fa 00 00
  0x0c068002ca20: 00 00 fa fa fd fd fd fd fa fa fd fd fd fd fa fa
  0x0c068002ca30: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fd
  0x0c068002ca40: fa fa fd fd fd fa fa fa fd fd fd fd fa fa 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
==521246==ABORTING
C++
==392594==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f5a9ca5f800 at pc 0x7f5ab8c17612 bp 0x7f5aa3b50110 sp 0x7f5aa3b50108
WRITE of size 4 at 0x7f5a9ca5f800 thread T357
    #0 0x7f5ab8c17611 in ClearAndRetainStorage /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1478:30
    #1 0x7f5ab8c17611 in nsTArray_Impl<gfxSparseBitSet::Block, nsTArrayInfallibleAllocator>::~nsTArray_Impl() /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1031:7
    #2 0x7f5ab8be5fe2 in ~gfxSparseBitSet /builds/worker/checkouts/gecko/gfx/thebes/gfxFontUtils.h:56:7
    #3 0x7f5ab8be5fe2 in gfxCharacterMap::NotifyMaybeReleased() /builds/worker/checkouts/gecko/gfx/thebes/gfxFontEntry.cpp:73:3
    #4 0x7f5abebc8377 in Release /builds/worker/workspace/obj-build/dist/include/gfxFontEntry.h:84:14
    #5 0x7f5abebc8377 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #6 0x7f5abebc8377 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #7 0x7f5abebc8377 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #8 0x7f5abebc8377 in mozilla::dom::FontFaceImpl::~FontFaceImpl() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:75:1
    #9 0x7f5abebc5016 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFaceImpl.h:37:3
    #10 0x7f5abebc5016 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #11 0x7f5abebc5016 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #12 0x7f5abebc5016 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #13 0x7f5abebc5016 in mozilla::dom::FontFace::~FontFace() /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:83:1
    #14 0x7f5abebe48a0 in DeleteCycleCollectable /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:73:1
    #15 0x7f5abebe48a0 in mozilla::dom::FontFace::cycleCollection::DeleteCycleCollectable(void*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFace.h:44:3
    #16 0x7f5ab642e2e2 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2432:7
    #17 0x7f5ab642d87e in nsCycleCollector::FreeSnowWhite(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2622:3
    #18 0x7f5ab6435834 in nsCycleCollector::BeginCollection(mozilla::CCReason, ccIsManual, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3611:3
    #19 0x7f5ab6434e5c in nsCycleCollector::Collect(mozilla::CCReason, ccIsManual, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3438:9
    #20 0x7f5ab643854a in nsCycleCollector_collect(mozilla::CCReason, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3946:28
    #21 0x7f5abddeb5fd in mozilla::dom::workerinternals::(anonymous namespace)::WorkerJSRuntime::CustomGCCallback(JSGCStatus) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:816:11
    #22 0x7f5ab63e95f8 in mozilla::CycleCollectedJSRuntime::OnGC(JSContext*, JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/xpcom/base/CycleCollectedJSRuntime.cpp:1884:3
    #23 0x7f5ac44a8cd8 in js::gc::GCRuntime::maybeCallGCCallback(JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3755:3
    #24 0x7f5ac44a96ac in ~AutoCallGCCallbacks /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3728:32
    #25 0x7f5ac44a96ac in js::gc::GCRuntime::gcCycle(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3845:1
    #26 0x7f5ac44ab560 in js::gc::GCRuntime::collect(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4027:9
    #27 0x7f5ac4476476 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4104:3
    #28 0x7f5abdde9a09 in mozilla::dom::workerinternals::(anonymous namespace)::WorkerThreadPrimaryRunnable::Run() /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:2084:7
    #29 0x7f5ab6610a6e in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1199:16
    #30 0x7f5ab661a6c4 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #31 0x7f5ab7c27d49 in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:330:5
    #32 0x7f5ab7ac42a1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #33 0x7f5ab7ac42a1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #34 0x7f5ab7ac42a1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #35 0x7f5ab6607bc4 in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:384:10
    #36 0x7f5ad7fd7c0e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5
    #37 0x7f5ad87b774c  (/usr/lib/libc.so.6+0x8674c) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)
    #38 0x7f5ad88396ff  (/usr/lib/libc.so.6+0x1086ff) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

0x7f5a9ca5f800 is located 0 bytes inside of 139272-byte region [0x7f5a9ca5f800,0x7f5a9ca81808)
freed by thread T356 here:
    #0 0x55f5a6c02ef2 in __interceptor_free /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
    #1 0x7f5ab8be5fe2 in ~gfxSparseBitSet /builds/worker/checkouts/gecko/gfx/thebes/gfxFontUtils.h:56:7
    #2 0x7f5ab8be5fe2 in gfxCharacterMap::NotifyMaybeReleased() /builds/worker/checkouts/gecko/gfx/thebes/gfxFontEntry.cpp:73:3
    #3 0x7f5abebc8377 in Release /builds/worker/workspace/obj-build/dist/include/gfxFontEntry.h:84:14
    #4 0x7f5abebc8377 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #5 0x7f5abebc8377 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #6 0x7f5abebc8377 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #7 0x7f5abebc8377 in mozilla::dom::FontFaceImpl::~FontFaceImpl() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:75:1
    #8 0x7f5abebc5016 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFaceImpl.h:37:3
    #9 0x7f5abebc5016 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #10 0x7f5abebc5016 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #11 0x7f5abebc5016 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #12 0x7f5abebc5016 in mozilla::dom::FontFace::~FontFace() /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:83:1
    #13 0x7f5abebe48a0 in DeleteCycleCollectable /builds/worker/checkouts/gecko/layout/style/FontFace.cpp:73:1
    #14 0x7f5abebe48a0 in mozilla::dom::FontFace::cycleCollection::DeleteCycleCollectable(void*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFace.h:44:3
    #15 0x7f5ab642e2e2 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2432:7
    #16 0x7f5ab642d87e in nsCycleCollector::FreeSnowWhite(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2622:3
    #17 0x7f5ab6435834 in nsCycleCollector::BeginCollection(mozilla::CCReason, ccIsManual, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3611:3
    #18 0x7f5ab6434e5c in nsCycleCollector::Collect(mozilla::CCReason, ccIsManual, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3438:9
    #19 0x7f5ab643854a in nsCycleCollector_collect(mozilla::CCReason, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3946:28
    #20 0x7f5abddeb5fd in mozilla::dom::workerinternals::(anonymous namespace)::WorkerJSRuntime::CustomGCCallback(JSGCStatus) /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:816:11
    #21 0x7f5ab63e95f8 in mozilla::CycleCollectedJSRuntime::OnGC(JSContext*, JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/xpcom/base/CycleCollectedJSRuntime.cpp:1884:3
    #22 0x7f5ac44a8cd8 in js::gc::GCRuntime::maybeCallGCCallback(JSGCStatus, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3755:3
    #23 0x7f5ac44a96ac in ~AutoCallGCCallbacks /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3728:32
    #24 0x7f5ac44a96ac in js::gc::GCRuntime::gcCycle(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:3845:1
    #25 0x7f5ac44ab560 in js::gc::GCRuntime::collect(bool, js::SliceBudget const&, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4027:9
    #26 0x7f5ac4476476 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) /builds/worker/checkouts/gecko/js/src/gc/GC.cpp:4104:3
    #27 0x7f5abdde9a09 in mozilla::dom::workerinternals::(anonymous namespace)::WorkerThreadPrimaryRunnable::Run() /builds/worker/checkouts/gecko/dom/workers/RuntimeService.cpp:2084:7
    #28 0x7f5ab6610a6e in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1199:16
    #29 0x7f5ab661a6c4 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #30 0x7f5ab7c27be8 in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:300:20
    #31 0x7f5ab7ac42a1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #32 0x7f5ab7ac42a1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #33 0x7f5ab7ac42a1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #34 0x7f5ab6607bc4 in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:384:10
    #35 0x7f5ad7fd7c0e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5
    #36 0x7f5ad87b774c  (/usr/lib/libc.so.6+0x8674c) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

previously allocated by thread T0 (Isolated Web Co) here:
    #0 0x55f5a6c03466 in __interceptor_realloc /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:85:3
    #1 0x7f5ab74010d5 in Realloc /builds/worker/workspace/obj-build/dist/include/nsTArray.h:247:12
    #2 0x7f5ab74010d5 in nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_RelocateUsingMemutils>::ShrinkCapacity(unsigned long, unsigned long) /builds/worker/workspace/obj-build/dist/include/nsTArray-inl.h:292:30
    #3 0x7f5abebcc275 in Compact /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2340:5
    #4 0x7f5abebcc275 in Compact /builds/worker/workspace/obj-build/dist/include/gfxFontUtils.h:325:13
    #5 0x7f5abebcc275 in mozilla::dom::FontFaceImpl::GetUnicodeRangeAsCharacterMap() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:692:14
    #6 0x7f5abebd9cf0 in mozilla::dom::FontFaceSetImpl::FindOrCreateUserFontEntryFromFontFace(nsTSubstring<char> const&, mozilla::dom::FontFaceImpl*, mozilla::StyleOrigin) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:458:47
    #7 0x7f5abebc9671 in mozilla::dom::FontFaceSetImpl::FindOrCreateUserFontEntryFromFontFace(mozilla::dom::FontFaceImpl*) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:345:10
    #8 0x7f5abebc9781 in mozilla::dom::FontFaceImpl::CreateUserFontEntry() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:326:9
    #9 0x7f5abebc8fa5 in mozilla::dom::FontFaceImpl::DoLoad() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:342:8
    #10 0x7f5abebe9fdf in operator() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:338:65
    #11 0x7f5abebe9fdf in mozilla::detail::RunnableFunction<mozilla::dom::FontFaceImpl::DoLoad()::$_9>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #12 0x7f5ab662e7e2 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:538:16
    #13 0x7f5ab65eeeed in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:851:26
    #14 0x7f5ab65ec058 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:683:15
    #15 0x7f5ab65ec780 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:461:36
    #16 0x7f5ab6637811 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:187:37
    #17 0x7f5ab6637811 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #18 0x7f5ab6610247 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1205:16
    #19 0x7f5ab661a6c4 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #20 0x7f5ab7c26a38 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21
    #21 0x7f5ab7ac42a1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #22 0x7f5ab7ac42a1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #23 0x7f5ab7ac42a1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #24 0x7f5abe70d887 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:150:27
    #25 0x7f5ac3596c37 in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:880:20
    #26 0x7f5ab7ac42a1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #27 0x7f5ab7ac42a1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #28 0x7f5ab7ac42a1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #29 0x7f5ac3595b5c in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:739:34
    #30 0x55f5a6c40825 in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #31 0x55f5a6c40c77 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:359:18
    #32 0x7f5ad875428f  (/usr/lib/libc.so.6+0x2328f) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)

Thread T357 created by T0 (Isolated Web Co) here:
    #0 0x55f5a6bec6fc in __interceptor_pthread_create /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:208:3
    #1 0x7f5ad7fc7cbc in _PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14
    #2 0x7f5ad7fb905e in PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:533:12
    #3 0x7f5ab660ab45 in nsThread::Init(nsTSubstring<char> const&) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:618:18
    #4 0x7f5abde395fa in mozilla::dom::WorkerThread::Create(mozilla::dom::WorkerThreadFriendKey const&) /builds/worker/checkouts/gecko/dom/workers/WorkerThread.cpp:102:7
    (...)

Thread T356 created by T0 (Isolated Web Co) here:
    #0 0x55f5a6bec6fc in __interceptor_pthread_create /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:208:3
    #1 0x7f5ad7fc7cbc in _PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14
    #2 0x7f5ad7fb905e in PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:533:12
    #3 0x7f5ab660ab45 in nsThread::Init(nsTSubstring<char> const&) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:618:18
    #4 0x7f5abde395fa in mozilla::dom::WorkerThread::Create(mozilla::dom::WorkerThreadFriendKey const&) /builds/worker/checkouts/gecko/dom/workers/WorkerThread.cpp:102:7
    (...)

SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1478:30 in ClearAndRetainStorage
Shadow bytes around the buggy address:
  0x0febd3943eb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0febd3943ec0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0febd3943ed0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0febd3943ee0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0febd3943ef0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0febd3943f00:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0febd3943f10: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0febd3943f20: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0febd3943f30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0febd3943f40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0febd3943f50: 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
==392594==ABORTING

Testcase

The UAF was triggered by loading mock user fonts on concurrent worker threads. Here's an initial testcase which crashes on debug builds as shown below.

HTML
<script>
new Worker("data:text/javascript,new FontFace('foo', new ArrayBuffer(100));");
</script>

(Because the font source is given as an ArrayBuffer, font loading is triggered implicitly, so no need to call FontFace.load(). In either case the actual loading then gets delegated to the main thread in FontFaceImpl::DoLoad().)

C++
==869252==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000001 (pc 0x7f5825254c41 bp 0x7ffee1b91730 sp 0x7ffee1b91720 T0)
==869252==The signal is caused by a WRITE memory access.
==869252==Hint: address points to the zero page.
    #0 0x7f5825254c41 in MOZ_Crash /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:261:3
    #1 0x7f5825254c41 in nsAutoOwningThread::AssertCurrentThreadOwnsMe(char const*) const /builds/worker/checkouts/gecko/xpcom/base/nsISupportsImpl.cpp:43:5
    #2 0x7f5827afd010 in AssertOwnership<40> /builds/worker/workspace/obj-build/dist/include/nsISupportsImpl.h:60:5
    #3 0x7f5827afd010 in AddRef /builds/worker/checkouts/gecko/gfx/thebes/gfxUserFontSet.h:62:3
    #4 0x7f5827afd010 in AddRef /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:49:39
    #5 0x7f5827afd010 in AddRef /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:380:35
    #6 0x7f5827afd010 in RefPtr<gfxFontFaceBufferSource>::RefPtr(RefPtr<gfxFontFaceBufferSource> const&) /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:97:7
    #7 0x7f5827afccb6 in Construct<const gfxFontFaceSrc &> /builds/worker/workspace/obj-build/dist/include/nsTArray.h:628:34
    #8 0x7f5827afccb6 in void AssignRangeAlgorithm<false, true>::implementation<gfxFontFaceSrc, gfxFontFaceSrc, unsigned long, unsigned long>(gfxFontFaceSrc*, unsigned long, unsigned long, gfxFontFaceSrc const*) /builds/worker/workspace/obj-build/dist/include/nsTArray.h:661:7
    #9 0x7f5827afcb59 in AssignRange<gfxFontFaceSrc> /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2418:5
    #10 0x7f5827afcb59 in nsTArrayInfallibleAllocator::ResultType nsTArray_Impl<gfxFontFaceSrc, nsTArrayInfallibleAllocator>::AssignInternal<nsTArrayInfallibleAllocator, gfxFontFaceSrc>(gfxFontFaceSrc const*, unsigned long) /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2449:5
    #11 0x7f5827ac4fcd in Clone /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2828:12
    #12 0x7f5827ac4fcd in gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet*, nsTArray<gfxFontFaceSrc> const&, mozilla::WeightRange, mozilla::StretchRange, mozilla::SlantStyleRange, nsTArray<gfxFontFeature> const&, nsTArray<mozilla::gfx::FontVariation> const&, unsigned int, gfxCharacterMap*, mozilla::StyleFontDisplay, gfxFontEntry::RangeFlags, float, float, float, float) /builds/worker/checkouts/gecko/gfx/thebes/gfxUserFontSet.cpp:58:31
    #13 0x7f582d9e0c7d in mozilla::dom::FontFaceImpl::Entry::Entry(gfxUserFontSet*, nsTArray<gfxFontFaceSrc> const&, mozilla::WeightRange, mozilla::StretchRange, mozilla::SlantStyleRange, nsTArray<gfxFontFeature> const&, nsTArray<mozilla::gfx::FontVariation> const&, unsigned int, gfxCharacterMap*, mozilla::StyleFontDisplay, gfxFontEntry::RangeFlags, float, float, float, float) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/FontFaceImpl.h:57:11
    #14 0x7f582d9e0c05 in mozilla::dom::FontFaceSetImpl::CreateUserFontEntry(nsTArray<gfxFontFaceSrc> const&, mozilla::WeightRange, mozilla::StretchRange, mozilla::SlantStyleRange, nsTArray<gfxFontFeature> const&, nsTArray<mozilla::gfx::FontVariation> const&, unsigned int, gfxCharacterMap*, mozilla::StyleFontDisplay, gfxFontEntry::RangeFlags, float, float, float, float) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:982:40
    #15 0x7f5827acd73e in gfxUserFontSet::FindOrCreateUserFontEntry(nsTSubstring<char> const&, nsTArray<gfxFontFaceSrc> const&, mozilla::WeightRange, mozilla::StretchRange, mozilla::SlantStyleRange, nsTArray<gfxFontFeature> const&, nsTArray<mozilla::gfx::FontVariation> const&, unsigned int, gfxCharacterMap*, mozilla::StyleFontDisplay, gfxFontEntry::RangeFlags, float, float, float, float) /builds/worker/checkouts/gecko/gfx/thebes/gfxUserFontSet.cpp:977:13
    #16 0x7f582d9da9f4 in mozilla::dom::FontFaceSetImpl::FindOrCreateUserFontEntryFromFontFace(nsTSubstring<char> const&, mozilla::dom::FontFaceImpl*, mozilla::StyleOrigin) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:633:41
    #17 0x7f582d9c9671 in mozilla::dom::FontFaceSetImpl::FindOrCreateUserFontEntryFromFontFace(mozilla::dom::FontFaceImpl*) /builds/worker/checkouts/gecko/layout/style/FontFaceSetImpl.cpp:345:10
    #18 0x7f582d9c9781 in mozilla::dom::FontFaceImpl::CreateUserFontEntry() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:326:9
    #19 0x7f582d9c8fa5 in mozilla::dom::FontFaceImpl::DoLoad() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:342:8
    #20 0x7f582d9e9fdf in operator() /builds/worker/checkouts/gecko/layout/style/FontFaceImpl.cpp:338:65
    #21 0x7f582d9e9fdf in mozilla::detail::RunnableFunction<mozilla::dom::FontFaceImpl::DoLoad()::$_9>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #22 0x7f582542e7e2 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:538:16
    #23 0x7f58253eeeed in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:851:26
    #24 0x7f58253ec058 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:683:15
    #25 0x7f58253ec780 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:461:36
    #26 0x7f5825437811 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:187:37
    #27 0x7f5825437811 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
    #28 0x7f5825410247 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1205:16
    #29 0x7f582541a6c4 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:465:10
    #30 0x7f5826a26a38 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21
    #31 0x7f58268c42a1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #32 0x7f58268c42a1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #33 0x7f58268c42a1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #34 0x7f582d50d887 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:150:27
    #35 0x7f5832396c37 in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:880:20
    #36 0x7f58268c42a1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:381:10
    #37 0x7f58268c42a1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:374:3
    #38 0x7f58268c42a1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:356:3
    #39 0x7f5832395b5c in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:739:34
    #40 0x55fb6485b825 in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #41 0x55fb6485bc77 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:359:18
    #42 0x7f584763c28f  (/usr/lib/libc.so.6+0x2328f) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)
    #43 0x7f584763c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349) (BuildId: 26c81e7e05ebaf40bac3523b7d76be0cd71fad82)
    #44 0x55fb6479bc80 in _start (/m-c-20220930214439-asan-opt/firefox+0x75c80) (BuildId: 299d2569dc538e4ecc6eab756f7d0eca461536c7)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:261:3 in MOZ_Crash
==869252==ABORTING

The original report as published on Mozilla's Bugzilla, by Armin Ebert. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the font character map shared by a FontFace is reference-counted without synchronisation, so a worker thread and the main thread can race on its release and read freed memory.

Impact

A crafted page could trigger a heap-use-after-free in the content process, causing a crash and potentially memory corruption; the text does not demonstrate code execution.

What the attacker needed

Victim visits a malicious page; page loads a font via FontFace from a worker

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A web page can ask the browser to load a custom font using a built-in feature called FontFace, and this can be done from a background worker, which is a separate thread of execution. The browser keeps a shared record of which characters the font covers, and when two threads touch that record at the same time one can delete it while the other is still using it. That is a use-after-free: reading memory that has already been handed back, which can crash the browser or let an attacker influence what happens next.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Armin Ebert

View all

18 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.