Closed Bug 2075414 Opened 2 months ago Closed 1 month ago

Navigating an iframe during the parents load event might instead restore the iframes SH entry if parent IsLoadingFromSessionHistory

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

VERIFIED FIXED
160 Branch
Tracking Status
firefox-esr153 --- unaffected
firefox157 --- unaffected
firefox158 --- wontfix
firefox159 --- wontfix
firefox160 --- verified

People

(Reporter: tsmith, Assigned: vhilla)

References

(Blocks 3 open bugs, Regression, )

Details

(4 keywords, Whiteboard: [bugmon:bisected,confirmed], [wptsync upstream])

Attachments

(1 file, 1 external file, 1 obsolete file)

Attached file testcase.html —

Found while fuzzing m-c 20260921-f1cfb0e0b987 (--enable-debug --enable-fuzzing)

To reproduce via Grizzly Replay:

$ pip install fuzzfetch grizzly-framework --upgrade
$ python -m fuzzfetch -d --fuzzing -n firefox
$ python -m grizzly.replay.bugzilla ./firefox/firefox <bugid>

Assertion failure: !IsForceReloadType(loadType) (Should've purged entry in PrepareReloadEntry), at checkouts/gecko/docshell/base/CanonicalBrowsingContext.cpp:616

#0 0x7fffe6b668d5 in MOZ_CrashSequence /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:261:3
#1 0x7fffe6b668d5 in mozilla::dom::CanonicalBrowsingContext::AdoptChildSHEntry(mozilla::Maybe<mozilla::dom::LoadingSessionHistoryInfo>&) /builds/worker/workspace/obj-build/docshell/base/./../../../../checkouts/gecko/docshell/base/CanonicalBrowsingContext.cpp:615:3
#2 0x7fffe59d8db9 in mozilla::dom::ContentParent::RecvAdoptChildSHEntry(mozilla::dom::MaybeDiscarded<mozilla::dom::BrowsingContext> const&, std::function<void (mozilla::Maybe<mozilla::dom::LoadingSessionHistoryInfo> const&)>&&) /builds/worker/workspace/obj-build/dom/ipc/./../../../../checkouts/gecko/dom/ipc/ContentParent.cpp:7768:29
#3 0x7fffe5b83508 in mozilla::dom::PContentParent::OnMessageReceived(IPC::Message const&) /builds/worker/workspace/obj-build/dom/ipc/./../../ipc/ipdl/PContentParent.cpp:7846:97
#4 0x7fffe0dcb00e in mozilla::ipc::MessageChannel::DispatchAsyncMessage(mozilla::ipc::ActorLifecycleProxy*, IPC::Message const&) /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessageChannel.cpp:1797:25
#5 0x7fffe0dc8594 in mozilla::ipc::MessageChannel::DispatchMessage(mozilla::ipc::ActorLifecycleProxy*, std::unique_ptr<IPC::Message, std::default_delete<IPC::Message>>) /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessageChannel.cpp:1723:9
#6 0x7fffe0dc8f97 in mozilla::ipc::MessageChannel::RunMessage(mozilla::ipc::ActorLifecycleProxy*, mozilla::ipc::MessageChannel::MessageTask&) /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessageChannel.cpp:1512:3
#7 0x7fffe0dc9f79 in mozilla::ipc::MessageChannel::MessageTask::Run() /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessageChannel.cpp:1614:14
#8 0x7fffe0c9d9f7 in mozilla::RunnableTask::Run() /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:721:16
#9 0x7fffe0c92975 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:1367:20
#10 0x7fffe0c914d7 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:1190:15
#11 0x7fffe0c91945 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:657:36
#12 0x7fffe0c9d116 in operator() /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:349:37
#13 0x7fffe0c9d116 in mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_0>::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.h:535:5
#14 0x7fffe0cb2973 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThread.cpp:1319:16
#15 0x7fffe0cb824f in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:471:32
#16 0x7fffe0dd0ee5 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessagePump.cpp:83:21
#17 0x7fffe0d2baa1 in RunHandler /builds/worker/workspace/obj-build/ipc/chromium/./../../../../checkouts/gecko/ipc/chromium/src/base/message_loop.cc:364:3
#18 0x7fffe0d2baa1 in MessageLoop::Run() /builds/worker/workspace/obj-build/ipc/chromium/./../../../../checkouts/gecko/ipc/chromium/src/base/message_loop.cc:346:3
#19 0x7fffe6261958 in nsBaseAppShell::Run() /builds/worker/workspace/obj-build/widget/./../../../checkouts/gecko/widget/nsBaseAppShell.cpp:151:27
#20 0x7fffe6344404 in nsAppShell::Run() /builds/worker/workspace/obj-build/widget/gtk/./../../../../checkouts/gecko/widget/gtk/nsAppShell.cpp:580:33
#21 0x7fffe7283b24 in nsAppStartup::Run() /builds/worker/workspace/obj-build/toolkit/components/startup/./../../../../../checkouts/gecko/toolkit/components/startup/nsAppStartup.cpp:308:30
#22 0x7fffe73d9efa in XREMain::XRE_mainRun() /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:6495:22
#23 0x7fffe73db4b5 in XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:6747:8
#24 0x7fffe73dbf92 in XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:6820:21
#25 0x5555555dc30a in do_main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:271:22
#26 0x5555555dc30a in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:542:16
Flags: in-testsuite?

This has also been detected via live site testing.

Verified bug as reproducible on mozilla-central 20260924164300-39878598097d.
The bug appears to have been introduced in the following build range:

Start: 33fb450f38182272074552a7ae639b8b7fa9eb49 (20260921071029)
End: f52f9d0d4f1b153a0d6d2bbefcb48ec274498e8b (20260921085140)
Pushlog: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=33fb450f38182272074552a7ae639b8b7fa9eb49&tochange=f52f9d0d4f1b153a0d6d2bbefcb48ec274498e8b

Keywords: regression
Whiteboard: [bugmon:bisected,confirmed]
Regressed by: 2037346

Set release status flags based on info from the regressing bug 2037346

:vhilla, since you are the author of the regressor, bug 2037346, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(vhilla)

Simon, this may be of your interest, too. Thanks.

I'd also appreciate the severity confirmation - does S3 look right given that it's not a production visible, while it still warrants a bit deeper dive as it's introduced by a recent change?

Flags: needinfo?(sfarre)

There was a pre-existing issue here: location.reload(true) caused srcdoc not to appear and not to have a SH entry. Part 1 D323222 means that also happens on browser UI force reload, part 3 D299053 means it happens for normal reload too. Interestingly, the srcdoc content does appear on Nightly but there is still no SH entry.

This creates quite weird states because the iframe can be navigated but we won't create SH entries for it. When the assertion occurs, the entry URI is about:blank.

I wonder where that entry comes from, I guess it's an initial about:blank load on the iframe.

Keywords: pernosco-wanted

Doing a.src = "about:blank" instead of a.srcdoc = "x" in onload has the same effect. I guess we start an iframe load during the parent load handler, so MaybeHandleSubframeHistory sees ...parentDS.get())->IsLoadingFromSessionHistory() being true. That's a pre-existing issue though and I don't yet understand why we don't just continue with AdoptChildSHEntry, don't return an entry, continue the load and get a new SH entry.

(In reply to Vincent Hilla [:vhilla] from comment #6)

I wonder where that entry comes from, I guess it's an initial about:blank load on the iframe.

Claude says the issue with the second load taking the SH part is then that AdoptChildSHEntry clears that child entry, but doesn't clear mActiveEntry on the child BC. Usually with reloads, the child BC wouldn't have an entry yet, but in this case, we incorrectly treat this second load as a load from SH. SessionHistoryCommit would then go through NotTop: Adding entry with an active entry and add an entry to the detached current entry.

So there was a pre-existing issue, but instead of a.srcdoc='a' adopting the initial about:blank entry from SH and not loading srcdoc, we now load srcdoc but are left without SH entry. Other loads should have similar issues.

To hit this regression, we need an initial about:blank and navigate it during the parent load handler, then reload (or force-reload in Beta/Release where docshell.shistory.restoreSubframesOnReload=true).

I think S3 is fine, but I'm unsure how to fix it.

Blocks: 2073998
Severity: -- → S3
Flags: needinfo?(vhilla)
Summary: Assertion failure: !IsForceReloadType(loadType) (Should've purged entry in PrepareReloadEntry), at checkouts/gecko/docshell/base/CanonicalBrowsingContext.cpp:616 → Navigating an iframe during the parents load event might instead restore the iframes SH entry if parent IsLoadingFromSessionHistory
Attachment #9657597 - Attachment description: WIP: Bug 2075414 - Only AdoptChildSHEntry for static original frame src. r=#dom-core → Bug 2075414 - Only AdoptChildSHEntry for static original frame src. r=#dom-core
Assignee: nobody → vhilla
Status: NEW → ASSIGNED
Pushed by vhilla@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4293a0f61175 https://hg.mozilla.org/integration/autoland/rev/87bcf6fc6afd Only AdoptChildSHEntry for static original frame src. r=dom-core-reviewers,smaug

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/63604 for changes under testing/web-platform/tests

Whiteboard: [bugmon:bisected,confirmed] → [bugmon:bisected,confirmed], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

Upstream PR merged by moz-wptsync-bot

Verified bug as fixed on rev mozilla-central 20261013160609-5a4718f5221d.
Successfully recorded a pernosco session. A link to the pernosco session will be added here shortly.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.

Status: RESOLVED → VERIFIED

A pernosco session for this bug can be found here.

Blocks: 2015228
Attachment #9664735 - Attachment is obsolete: true
See Also: → 1988713
Regressions: 2081288
Regressions: 2092362
No longer regressions: 2092362
Flags: needinfo?(sfarre)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: