MemoryCleaner race condition and memory corruption after running yieldOwnership #222
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi#222
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When
MemoryCleaner.yieldOwnershipis run by bindings, the entry inCacheremains and the cleaner will still be run. For a short-lived object, a new object can be created and have the same address but be of a different type. From there, when the Cleaner runs, it can attempt to clean up the new object with the incorrect cleanup function, resulting in a crash.Instead, modify
yieldOwnershipto only create the entry inCacheif it doesn't already exist, and run thecleanableto both remove the entry fromCacheand ensure that thecleanablewill not run again.I can make a pull request if desired.
Thanks for reporting! I would appreciate a PR.