Closed Bug 2037923 Opened 2 months ago Closed 1 month ago

Crash in [@ shutdownhang | mozilla::scache::StartupCache::GetBuffer]

Categories

(Core :: XPCOM, defect, P2)

Unspecified
Windows 10
defect

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox152 + disabled
firefox153 + fixed
firefox154 + fixed

People

(Reporter: aryx, Assigned: leggert)

References

(Blocks 1 open bug, Regression)

Details

(5 keywords)

Crash Data

Attachments

(2 files)

Crash report: https://crash-stats.mozilla.org/report/index/a4ff4dfa-900c-434a-83cf-24daa0260507

MOZ_CRASH Reason:

Shutdown hanging at step XPCOMWillShutdown. Something is blocking the main-thread.

main thread:

ZwWaitForAlertByThreadId	
RtlAcquireSRWLockExclusive	
mozilla::OffTheBooksMutex::Lock()	xpcom/threads/Mutex.h:64
mozilla::detail::BaseAutoLock<mozilla::Mutex&>::BaseAutoLock(mozilla::Mutex&)	xpcom/threads/Mutex.h:159
mozilla::scache::StartupCache::GetBuffer(char const*, char const**, unsigned int*)	startupcache/StartupCache.cpp:392
ReadCachedStencil(mozilla::scache::StartupCache*, nsTSubstring<char>&, JSContext*, JS::ReadOnlyDecodeOptions const&, js::frontend::InitialStencilAndDelazifications**)	js/xpconnect/loader/mozJSLoaderUtils.cpp:44
mozJSModuleLoader::GetScriptForLocation(JSContext*, ModuleLoaderInfo&, nsIFile*, bool, JS::MutableHandle<JSObject*>, char**)	js/xpconnect/loader/mozJSModuleLoader.cpp:889
mozJSModuleLoader::LoadSingleModule(mozilla::loader::SyncModuleLoader*, JSContext*, JS::loader::ModuleLoadRequest*, JS::MutableHandle<JSObject*>)	js/xpconnect/loader/mozJSModuleLoader.cpp:725
mozilla::loader::SyncModuleLoader::StartFetch(JS::loader::ModuleLoadRequest*)	js/xpconnect/loader/SyncModuleLoader.cpp:146
JS::loader::ModuleLoaderBase::StartOrRestartModuleLoad(JS::loader::ModuleLoadRequest*, JS::loader::ModuleLoaderBase::RestartRequest)	js/loader/ModuleLoaderBase.cpp:601 

Top 9 frames:

0  xul.dll  MOZ_Crash(char const*, int, char const*)  mfbt/Assertions.h:402
0  xul.dll  mozilla::(anonymous namespace)::RunWatchdog(void*)  toolkit/components/terminator/nsTerminator.cpp:238
1  nss3.dll  _PR_NativeRunThread(void*)  nsprpub/pr/src/threads/combined/pruthr.c:381
2  nss3.dll  pr_root(void*)  nsprpub/pr/src/md/windows/w95thred.c:129
3  ucrtbase.dll  thread_start<unsigned int (__cdecl*)(void*), 1>
4  kernel32.dll  BaseThreadInitThunk
5  mozglue.dll  mozilla::interceptor::FuncHook<mozilla::interceptor::WindowsDllInterceptor<mo...  toolkit/xre/dllservices/mozglue/nsWindowsDllInterceptor.h:142
5  mozglue.dll  patched_BaseThreadInitThunk(int, void*, void*)  toolkit/xre/dllservices/mozglue/WindowsDllBlocklist.cpp:564
6  ntdll.dll  RtlUserThreadStart
Blocks: sm-runtime
Severity: -- → S3
Priority: -- → P2

The bug is linked to a topcrash signature, which matches the following criteria:

  • Top 20 desktop browser crashes on beta
  • Top 5 desktop browser crashes on Windows on beta

:gtonietto, could you consider increasing the severity of this top-crash bug?

For more information, please visit BugBot documentation.

Flags: needinfo?(gtonietto)
Keywords: topcrash

Keeping it S3 for now.

Flags: needinfo?(gtonietto)

The bug is linked to a topcrash signature, which matches the following criteria:

  • Top 20 desktop browser crashes on beta (startup)
  • Top 5 desktop browser crashes on Windows on beta (startup)

For more information, please visit BugBot documentation.

Setting as tracking+ across all releases, this crash spiked in 152 beta and is now crashing in 152 release

QA Whiteboard: [p1][qa-triage-done-c154/b153][qa-investig-needed-c154/b153]

:lars, Claude thinks Bug 2026686 is the potential regressor here. It may be incorrect, but please take a look:

What the patch does: wraps the StartupCache background write thread with nsAutoLowPriorityIO, which on Windows means
SetThreadPriority(THREAD_MODE_BACKGROUND_BEGIN) — background I/O priority — held while the thread is also holding mTableLock.

Why it hangs at StartupCache::GetBuffer during shutdown:

  1. Shutdown saturates the disk with normal-priority I/O (sessionstore, places, cookies, dom storage, telemetry, etc.).
  2. The background write thread is mid-WriteToDisk, holding mTableLock, but its I/O is now Windows background-tier — the
    scheduler can defer it for many seconds while foreground writes go through.
  3. Late in shutdown, a lazy ESM getter fires → ImportESModule → SyncModuleLoader::StartFetch → ReadCachedStencil →
    StartupCache::GetBuffer → tries to acquire mTableLock → blocked.
  4. The watchdog's AppShutdownConfirmed timeout fires before the throttled write releases the lock → crash with shutdownhang |
    StartupCache::GetBuffer.
Flags: needinfo?(leggert)

I agree with the analysis.

Flags: needinfo?(leggert)
Assignee: nobody → leggert
Status: NEW → ASSIGNED
Pushed by leggert@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a316c0cc866b https://hg.mozilla.org/integration/autoland/rev/601037445071 Don't use low-priority I/O for startup cache writes during shutdown r=xpcom-reviewers,emilio

Any concerns with me reverting https://github.com/mozilla-firefox/firefox/commit/0af8f0534bd5 for a 152 dot release, assuming that'd be a sufficient mitigation?

Flags: needinfo?(leggert)

Nope, that should be a safe fix.

Flags: needinfo?(leggert)
Component: JavaScript Engine → XPCOM

Revert pushed for 152.0.1.

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch

The patch landed in nightly and beta is affected.
:leggert, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(leggert)

:RyanVM, does this need an uplift, since you had a different fix for the point release?

Flags: needinfo?(leggert) → needinfo?(ryanvm)

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Fixes topcrash on Windows
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Simple fix
  • String changes made/needed?: No
  • Is Android affected?: no
Attachment #9598768 - Flags: approval-mozilla-beta?
Flags: needinfo?(ryanvm)
Attachment #9598768 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: