fix: check for NULL view->container in constrain_popup to prevent segfault - #9206
Open
xieguaiwu wants to merge 1 commit into
Open
fix: check for NULL view->container in constrain_popup to prevent segfault#9206xieguaiwu wants to merge 1 commit into
xieguaiwu wants to merge 1 commit into
Conversation
Member
|
This PR contains many unrelated commits. |
…fault When using an IME (Input Method Editor) like fcitx or anthywl, closing a window while the IME popup (candidate window) is still active can cause sway to crash with a segfault in constrain_popup(). The crash occurs because: 1. A view is unmapped and its container is freed (set to NULL) 2. The IME popup still holds a reference to the destroyed view via popup->desc.view 3. When the IME sends a new frame for the popup, handle_im_popup_surface_commit() calls constrain_popup() 4. constrain_popup() accesses view->container->pending.content_x without checking if view->container is non-NULL Add a NULL check for view->container before dereferencing it. If the container is NULL, the view is no longer valid and we return early rather than crashing. Fixes: swaywm#8541
xieguaiwu
force-pushed
the
fix/constrain-popup-null-container
branch
from
July 3, 2026 09:37
0831baa to
3024142
Compare
Author
|
Branch has been rebased onto the latest upstream master. The history is now a single clean commit — no more unrelated commits. /cc @emersion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using an IME (Input Method Editor, e.g. fcitx, ibus, anthywl) with sway, closing a window while the IME candidate popup is still active can cause sway to crash with a segfault.
Root Cause
The crash occurs in
constrain_popup()insway/input/text_input.c:popup->desc.viewhandle_im_popup_surface_commit()callsconstrain_popup()constrain_popup()accessesview->container->pending.content_xwithout checking ifview->containeris non-NULL → NULL pointer dereference → segfaultThe Fix
Add a NULL guard for
view->containerbefore dereferencing it. If the container is NULL, the view is no longer valid and we return early rather than crashing.Reproduction
constrain_popupBacktrace
Fixes #8541