Crash in IPCError-content | RecvConstructBrowser BrowserChild::Init failed (rv=NS_ERROR_RECURSIVE_DOCUMENT_LOAD)
Categories
(Core :: DOM: Navigation, defect, P5)
Tracking
()
People
(Reporter: vhilla, Unassigned)
References
Details
Crash Data
Attachments
(1 file)
|
5.16 KB,
text/plain
|
Details |
Going through RecvConstructBrowser crashes caused by bug 543435, I saw NS_ERROR_RECURSIVE_DOCUMENT_LOAD is the second most frequent reason (still rare) and recursion during initial document creation seems unexpected / peculiar to me.
With the help from claude, I did some analysis and generated a crashtest.
What seems to happen is that a buggy page starts infinitely recursing and involves synchronous event loop spins, e.g. sync XHR request -> sync event loop spin -> rendering tick -> scroll event handler -> sync XHR request. Then something causes the creation of a new browser and the parent selects the overrecursing process for it. The sync event loop spin processes RecvConstructBrowser, we try to create a document and fail the overrecursion check in SetNewDocument. The crash appears often on android, maybe due to dom.ipc.processCount.webIsolated=1.
I don't think this is too bad, my initial concern was we would somehow recursively create initial documents. But it seems difficult to resolve.
| Reporter | ||
Updated•7 months ago
|
| Reporter | ||
Updated•7 months ago
|
| Reporter | ||
Updated•7 months ago
|
Comment 1•21 days ago
|
||
This bug has had no comment from a person since 2026-04-16. Clouseau analysed a recent crash report on its signature; the analysis is below.
Crash report: https://crash-stats.mozilla.org/report/index/4c35db71-5b55-40b0-a979-955550261021
MOZ_CRASH Reason:
MOZ_CRASH(Content child abort due to IPC error)
Top 10 frames:
0 libxul.so mozilla::dom::ContentChild::ProcessingError(mozilla::ipc::HasResultCodes::Result... dom/ipc/ContentChild.cpp:2284
1 libxul.so mozilla::ipc::IPCResult::FailImpl(mozilla::NotNull<mozilla::ipc::IProtocol*>, ch... ipc/glue/ProtocolUtils.cpp:59
2 libxul.so mozilla::dom::ContentChild::RecvConstructBrowser(mozilla::ipc::ManagedEndpoint<m... dom/ipc/ContentChild.cpp:1939
3 libxul.so mozilla::dom::PContentChild::OnMessageReceived(IPC::Message const&) ipc/ipdl/PContentChild.cpp:8232
4 libxul.so mozilla::ipc::MessageChannel::MessageTask::Run() ipc/glue/MessageChannel.cpp:1614
5 libxul.so mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::... xpcom/threads/TaskController.cpp:1190
6 libxul.so mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_1... xpcom/threads/nsThreadUtils.h:535
7 libxul.so NS_ProcessNextEvent(nsIThread*, bool) xpcom/threads/nsThreadUtils.cpp:471
8 libxul.so mozilla::dom::XMLHttpRequestMainThread::SendInternal(mozilla::dom::BodyExtractor... dom/xhr/XMLHttpRequestMainThread.cpp:3279
9 libxul.so mozilla::dom::XMLHttpRequest_Binding::send(JSContext*, JS::Handle<JSObject*>, vo... dom/bindings/XMLHttpRequestBinding.cpp:1663
There are 26 crashes (from 21 installations) in 158.0.2 starting with buildid 20261021001945.
In the last 30 days, Fenix has 248 crashes (from 152 installations) on release, 5 crashes (from 3 installations) on nightly and 3 crashes (from 2 installations) on beta with this signature.
This signature has been reported since build 20260228091114 (2026-02-28), 235 days before the build above.
This bug looks actionable because:
-
The content process aborts in
ContentChild::RecvConstructBrowserbecauseBrowserChild::InitreturnsNS_ERROR_RECURSIVE_DOCUMENT_LOAD: a new tab is built inside 77 nested sync-XHR event loops and runs out of native stack.- Page script makes sync XHRs nested 77 deep. Each one spins a nested event loop in
XMLHttpRequestMainThread::SendInternalon the main thread, using up most of the native stack. - A
ConstructBrowsermessage from the parent is handled in the innermost loop, andBrowserChild::Initstarts creating the tab's initialabout:blankviansWebBrowser::CreateandnsDocShell::InitWindow. nsGlobalWindowOuter::SetNewDocumentrunscheckConservativeDontReport, which fails near the stack limit, so it returnsNS_ERROR_RECURSIVE_DOCUMENT_LOAD.- Since bug 2009931 the docshell passes initial document-viewer failures up instead of only warning about them, so
nsWebBrowser::CreateandBrowserChild::Initboth fail. RecvConstructBrowsercallsIPC_FAIL_UNSAFE_PRINTF("BrowserChild::Init failed (rv=%s)"), and the content process aborts.
The report fits this chain: frame 2 is line 1939 of
ContentChild.cpp, the rv is named in the signature, and the spin-event-loop annotation showsXMLHttpRequestMainThread::SendInternalx77 with the IPC task running under frame 8. Picking the recursion guard as the source of the error is an inference: the only other code that returns it is the network document-load code, whichBrowserChild::Initdoes not run. What to look at first: whetherRecvConstructBrowsershould run inside a sync-XHR nested event loop at all, or whether a stack-limit failure while creating the initialabout:blankcan be handled without killing the content process. - Page script makes sync XHRs nested 77 deep. Each one spins a nested event loop in
-
The failing code comes from f463d3648a1e (gh) (bug 2009931) by :vhilla.
Code references:
- nsGlobalWindowOuter::SetNewDocument
- nsDocumentViewer::InitInternal
- nsDocShell::InitWindow
- docshell/base/nsDocShell.cpp:446
- toolkit/components/browser/nsWebBrowser.cpp:143
- dom/ipc/ContentChild.cpp:1977
:vhilla, can you have a look please?
Posted automatically by Clouseau, which analyses release crashes with an LLM. Nothing above was written or checked by a human.
| Reporter | ||
Comment 2•21 days ago
|
||
The analysis of Closeau isn't really something new, we already have a crashtest after all.
What's unclear is how to fix this. Perhaps hackbot has some idea.
Comment 3•21 days ago
|
||
| bug-fix | ||
Some ideas, from reading ContentChild::RecvConstructBrowser and nsGlobalWindowOuter::SetNewDocument on current central. I haven't built or tested any of them.
1. Relax the stack check when creating a fresh window's initial about:blank (the most targeted fix).
The comment on the checkConservativeDontReport check in SetNewDocument says it exists because "the transplanting code … has no good way to handle errors". For a window created in BrowserChild::Init, GetWrapperPreserveColor() is null, so we take the NewOuterWindowProxy branch. That branch never reaches xpc::TransplantObjectNukingXrayWaiver. The one transplant it can still do is BrowsingContext::CleanUpDanglingRemoteOuterWindowProxies → js::RemapRemoteWindowProxies, and only when mDanglingRemoteOuterProxies is set. So we could:
- run the conservative check only when a transplant can actually happen (
GetWrapperPreserveColor() || mBrowsingContext->HasDanglingRemoteOuterProxies()or similar), or - for that case, use
checkSystemDontReport(the system limit) instead of the untrusted-script limit. Creating the initial document doesn't run content script, so it doesn't need the untrusted margin.
The native stack is still deep after 77 nested sync XHRs, so we should confirm with the crashtest that we don't just move the crash to a real stack overflow further down. The system-limit variant keeps a safety margin, so I'd try that first.
2. Fail the tab, not the whole process.
At the moment any BrowserChild::Init failure goes to IPC_FAIL_UNSAFE_PRINTF, which kills the content process. On Android with processCount.webIsolated=1, that takes down every tab of the site. For a recoverable rv like NS_ERROR_RECURSIVE_DOCUMENT_LOAD, we could tear down only the new BrowserChild/PBrowser (both are already bound at that point), so the parent shows a crashed or failed tab. That needs parent-side handling for a PBrowser that dies right after construction. It's similar to what the failPBrowserCreation test pref already covers, except that pref returns before the endpoints are bound.
3. Not viable, I think: deferring ConstructBrowser out of the nested event loop would reorder it with later messages for the new PBrowser. Suppressing IPC during sync XHR isn't an option either, because the sync loop has to keep processing messages.
My suggestion is 1 (system-limit variant) plus the crashtest from comment 0, with 2 as a possible follow-up to make BrowserChild::Init failures less fatal in general.
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
Description
•