Skip to content

[GLIB] WebProcess critical assertion during D-Bus RequestName completion on process shutdown#60411

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
lauromoura:eng/GLIB-WebProcess-critical-assertion-during-D-Bus-RequestName-completion-on-process-shutdown
Mar 13, 2026
Merged

[GLIB] WebProcess critical assertion during D-Bus RequestName completion on process shutdown#60411
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
lauromoura:eng/GLIB-WebProcess-critical-assertion-during-D-Bus-RequestName-completion-on-process-shutdown

Conversation

@lauromoura
Copy link
Contributor

@lauromoura lauromoura commented Mar 12, 2026

57438b0

[GLIB] WebProcess critical assertion during D-Bus RequestName completion on process shutdown
https://bugs.webkit.org/show_bug.cgi?id=309693

Reviewed by Claudio Saavedra.

While rare, there's a chance that the WebProcess exits while the
AccessibilityAtspi dbus name callbacks are still in flight. If we don't
close them gracefully, we risk critical errors when the reply arrives.
This is likely related to 284894@main, which added the support for
well-known bus name to AccessibilityAtspi.

This happens, for example, in some WebDriver tests that quickly open and
close browsing contexts. A run with release asserts is reporting almost
30 crashes.

This commit addresses this issue by adding a graceful cleanup path to
AccessibilityAtspi.

* Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp:
(WebCore::AccessibilityAtspi::didConnect):
(WebCore::AccessibilityAtspi::disconnect):
* Source/WebCore/accessibility/atspi/AccessibilityAtspi.h:
* Source/WebKit/WebProcess/glib/WebProcessGLib.cpp:
(WebKit::WebProcess::stopRunLoop):

Canonical link: https://commits.webkit.org/309174@main

3fd797f

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
🧪 ios-wk2-wpt 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@lauromoura lauromoura requested a review from a team as a code owner March 12, 2026 00:12
@lauromoura lauromoura self-assigned this Mar 12, 2026
@lauromoura lauromoura added the WebKitGTK Bugs related to the Gtk API layer. label Mar 12, 2026
Copy link
Member

@csaavedra csaavedra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some style comments, not reviewing correctness as I think @GeorgesStavracas should do that.

Comment on lines +105 to +108
if (m_nameOwnerId) {
g_bus_unown_name(m_nameOwnerId);
m_nameOwnerId = 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use std::exchange:

Suggested change
if (m_nameOwnerId) {
g_bus_unown_name(m_nameOwnerId);
m_nameOwnerId = 0;
}
if (auto id = std::exchange(m_nameOwnerId, 0))
g_bus_unown_name(id);

Comment on lines +110 to +113
if (m_registry) {
g_signal_handlers_disconnect_by_data(m_registry.get(), this);
m_registry = nullptr;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment on lines +115 to +122
if (m_connection) {
for (auto id : m_clients.values())
g_dbus_connection_signal_unsubscribe(m_connection.get(), id);
m_clients.clear();

g_dbus_connection_close_sync(m_connection.get(), nullptr, nullptr);
m_connection = nullptr;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here probably too.

Comment on lines +101 to +103
for (auto& pending : m_pendingRootRegistrations)
pending.completionHandler({ });
m_pendingRootRegistrations.clear();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also use std::exchange().

@lauromoura lauromoura force-pushed the eng/GLIB-WebProcess-critical-assertion-during-D-Bus-RequestName-completion-on-process-shutdown branch from 616bd88 to c577e4a Compare March 12, 2026 13:42
@lauromoura lauromoura requested a review from csaavedra March 12, 2026 14:20
Copy link
Member

@csaavedra csaavedra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a fix.

g_signal_handlers_disconnect_by_data(registry.get(), this);

if (auto connection = std::exchange(m_connection, nullptr)) {
for (auto id : moveToVector(std::exchange(m_clients, { }).values()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the moveToVector() call really necessary? That's going to iterate over the elements to fill a vector. IIUC this could just be

Suggested change
for (auto id : moveToVector(std::exchange(m_clients, { }).values()))
for (auto id : std::exchange(m_clients, { }).values())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first approach, but the compiler warned of dangling-reference. Different from the other cases, here we're iterating through the values() member, which is LIFETIME_BOUND to the result of std::exchange, which in turn is not held alive by the loop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe it's not worth using std:: exchange in this case.

@lauromoura lauromoura force-pushed the eng/GLIB-WebProcess-critical-assertion-during-D-Bus-RequestName-completion-on-process-shutdown branch from c577e4a to 3fd797f Compare March 12, 2026 19:43
@lauromoura lauromoura added the merge-queue Applied to send a pull request to merge-queue label Mar 13, 2026
…ion on process shutdown

https://bugs.webkit.org/show_bug.cgi?id=309693

Reviewed by Claudio Saavedra.

While rare, there's a chance that the WebProcess exits while the
AccessibilityAtspi dbus name callbacks are still in flight. If we don't
close them gracefully, we risk critical errors when the reply arrives.
This is likely related to 284894@main, which added the support for
well-known bus name to AccessibilityAtspi.

This happens, for example, in some WebDriver tests that quickly open and
close browsing contexts. A run with release asserts is reporting almost
30 crashes.

This commit addresses this issue by adding a graceful cleanup path to
AccessibilityAtspi.

* Source/WebCore/accessibility/atspi/AccessibilityAtspi.cpp:
(WebCore::AccessibilityAtspi::didConnect):
(WebCore::AccessibilityAtspi::disconnect):
* Source/WebCore/accessibility/atspi/AccessibilityAtspi.h:
* Source/WebKit/WebProcess/glib/WebProcessGLib.cpp:
(WebKit::WebProcess::stopRunLoop):

Canonical link: https://commits.webkit.org/309174@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/GLIB-WebProcess-critical-assertion-during-D-Bus-RequestName-completion-on-process-shutdown branch from 3fd797f to 57438b0 Compare March 13, 2026 00:55
@webkit-commit-queue
Copy link
Collaborator

Committed 309174@main (57438b0): https://commits.webkit.org/309174@main

Reviewed commits have been landed. Closing PR #60411 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 57438b0 into WebKit:main Mar 13, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 13, 2026
@aperezdc aperezdc added GLib Suggested Backport - 2.50 Suggest this merge request be backported to webkitglib/2.50 branch GLib Suggested Backport - 2.52 Suggest this merge request be backported to the webkitglib/2.52 stable branch labels Mar 13, 2026
@aperezdc
Copy link
Contributor

Backported into webkitglib/2.52 as commit d665e8f

@aperezdc aperezdc removed the GLib Suggested Backport - 2.52 Suggest this merge request be backported to the webkitglib/2.52 stable branch label Mar 13, 2026
@aperezdc
Copy link
Contributor

Backported into webkitglib/2.50 as commit 45d479c

@aperezdc aperezdc removed the GLib Suggested Backport - 2.50 Suggest this merge request be backported to webkitglib/2.50 branch label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebKitGTK Bugs related to the Gtk API layer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants