Skip to content

Attempting to show a message box segfaults when using Qt backend #51988

Description

@0x9fff00

Preflight Checklist

Electron Version

42.3.0

What operating system(s) are you using?

Other Linux

Operating System Version

Arch Linux (X11, KDE Plasma 6)

What arch are you using?

x64

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

No

Expected Behavior

Showing a message box should work with both GTK and Qt backends.

Actual Behavior

When Electron/Chromium is built with use_qt6=true (as Arch Linux does), attempting to show a message box in Electron segfaults when Chromium uses its Qt backend, which it does by default on KDE. Forcing the GTK backend with --ui-toolkit=gtk works around the issue. This does not affect upstream binaries as Electron defaults to use_qt5 = false and use_qt6 = false.

Testcase Gist URL

No response

Additional Information

The issue can be reproduced with the following code:

const { dialog } = require("electron");
dialog.showMessageBox({ message: "test" });

I believe it is caused by this cast in GetGtkUiPlatform which assumes linux_ui always points to a GtkUi instance. The function then calls GtkUi::GetPlatform on that object to get GtkUiPlatform* platform. I have determined with gdb that the segfault happens on this line in Chromium's gtk::SetGtkTransientForAura (called here in the GtkMessageBox constructor) when it tries to call platform->SetGtkWidgetTransientFor. Since platform is not actually a GtkUiPlatform pointer, this tries to jump to an invalid address leading to a segfault.

The incorrect cast was introduced during the development of Electron 41, but I have not been able to test whether Electron 40 or earlier works when built with the Qt backend enabled as Arch Linux first enabled it for Electron 42.

See also https://gitlab.archlinux.org/archlinux/packaging/packages/code/-/work_items/58 and microsoft/vscode#320788

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions