Skip to content

fix(hyprland/window): Fix segfault caused by use-after-free#4938

Open
jayshozie wants to merge 1 commit intoAlexays:masterfrom
jayshozie:hyprland/window/segfault-fix
Open

fix(hyprland/window): Fix segfault caused by use-after-free#4938
jayshozie wants to merge 1 commit intoAlexays:masterfrom
jayshozie:hyprland/window/segfault-fix

Conversation

@jayshozie
Copy link

The window module registers itself with the Hyprland IPC singleton at
the start of its constructor, before calling update(). If update()
throws an exception (e.g. from an invalid format string), the object is
destroyed without the destructor running, leaving a dangling pointer in
the IPC callback list. When the IPC thread receives an event, it
attempts to call onEvent() on this invalid memory, causing a crash.

Moving the update() call before IPC registration ensures that any
initialization errors occur before the pointer is shared. If the
configuration is invalid, the module fails to construct and is
gracefully disabled by the factory without leaving a "landmine" in the
background IPC thread.

Fixes: #4923

Signed-off-by: Emir Baha Yıldırım jayshozie@gmail.com

@jayshozie jayshozie marked this pull request as draft March 19, 2026 16:38
@jayshozie jayshozie force-pushed the hyprland/window/segfault-fix branch from a32805f to afd0b54 Compare March 19, 2026 16:43
@jayshozie jayshozie marked this pull request as ready for review March 19, 2026 16:43
@jayshozie jayshozie force-pushed the hyprland/window/segfault-fix branch from afd0b54 to 2221fcf Compare March 19, 2026 16:44
The window module registers itself with the Hyprland IPC singleton at
the start of its constructor, before calling update(). If update()
throws an exception (e.g. from an invalid format string), the object is
destroyed without the destructor running, leaving a dangling pointer in
the IPC callback list. When the IPC thread receives an event, it
attempts to call onEvent() on this invalid memory, causing a crash.

Moving the update() call before IPC registration ensures that any
initialization errors occur before the pointer is shared. If the
configuration is invalid, the module fails to construct and is
gracefully disabled by the factory without leaving a "landmine" in the
background IPC thread.

Fixes: Alexays#4923

Signed-off-by: Emir Baha Yıldırım <jayshozie@gmail.com>
@jayshozie jayshozie force-pushed the hyprland/window/segfault-fix branch from 2221fcf to 83e1949 Compare March 19, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hyprland IPC Crash with hyprland/window

1 participant