Repository navigation
[linux] Use GWeakRef for engine and parent in FlAccessibleNode - #188699
Merged
robert-ancell merged 2 commits intoJun 29, 2026
Merged
Conversation
FlAccessibleNode registered its engine and parent weak pointers on the node itself rather than on the target objects, so the pointers were never cleared when the engine or parent was destroyed. The AT-SPI bridge can keep nodes alive past engine teardown, so subsequent calls would dereference freed memory. Store the engine and parent as GWeakRef and fetch a strong reference where needed, returning safely when the target has been destroyed. This matches the rest of the embedder. Add tests covering access after engine and parent destruction. Fixes flutter#188660
robert-ancell
force-pushed
the
linux-accessible-node-gweakref
branch
from
June 28, 2026 22:33
37e9d4e to
0a1432e
Compare
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors FlAccessibleNode to use GWeakRef for engine and parent references, and adds tests to ensure nodes survive engine and parent destruction. The review feedback points out that passing a potential nullptr from g_weak_ref_get directly to GLib casting macros (ATK_OBJECT and FL_ENGINE) will trigger critical warnings, and recommends checking for nullptr before casting. Additionally, the feedback suggests initializing both weak references in fl_accessible_node_init and using g_weak_ref_set in the property setter to prevent undefined behavior from re-initializing GWeakRef structures.
Initialize the engine weak reference in fl_accessible_node_init and set it with g_weak_ref_set, matching the parent weak reference. This ensures the GWeakRef is always initialized before dispose clears it, even if the engine property is not set during construction.
This was referenced Jun 30, 2026
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.
FlAccessibleNode registered its engine and parent weak pointers on the node itself rather than on the target objects, so the pointers were never cleared when the engine or parent was destroyed. The AT-SPI bridge can keep nodes alive past engine teardown, so subsequent calls would dereference freed memory.
Store the engine and parent as GWeakRef and fetch a strong reference where needed, returning safely when the target has been destroyed. This matches the rest of the embedder. Add tests covering access after engine and parent destruction.
Fixes #188660