Skip to content

Fix heap-use-after-free in workspace switch animation#353

Open
jbms wants to merge 1 commit into
dawsers:masterfrom
jbms:fix-workspace-switch-uaf-again
Open

Fix heap-use-after-free in workspace switch animation#353
jbms wants to merge 1 commit into
dawsers:masterfrom
jbms:fix-workspace-switch-uaf-again

Conversation

@jbms

@jbms jbms commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

During rapid workspace switching, empty workspaces can be destroyed synchronously when transactions are completed. If an active animation's filter data still holds a raw pointer to a destroyed workspace, it results in a heap-use-after-free when the layout is next arranged.

This patch fixes the issue by registering destroy listeners on both the 'from' and 'to' workspaces in workspace_switch_data. When a workspace is destroyed, its pointer in the animation data is set to NULL. The filters and layout code are updated to safely handle NULL workspaces.

Additionally, disable animations by default in ScrollInstance.reset() to prevent test pollution between test runs.

During rapid workspace switching, empty workspaces can be destroyed
synchronously when transactions are completed. If an active animation's
filter data still holds a raw pointer to a destroyed workspace, it
results in a heap-use-after-free when the layout is next arranged.

This patch fixes the issue by registering destroy listeners on both
the 'from' and 'to' workspaces in `workspace_switch_data`. When a
workspace is destroyed, its pointer in the animation data is set to
NULL. The filters and layout code are updated to safely handle NULL
workspaces.

Additionally, disable animations by default in `ScrollInstance.reset()`
to prevent test pollution between test runs.
@jbms

jbms commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

It turns out that your previous fix did not fully eliminate the possibility of use-after-free during workspace switch animations, it just made it happen less reliably.

This adds listeners to reliably fix the problem.

@dawsers

dawsers commented Jul 11, 2026

Copy link
Copy Markdown
Owner

I am curious about how you make it crash now. Is there a test or a command I can run?

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.

2 participants