Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RawGd::move_return_ptr with PtrcallType::Virtual leaks reference #848

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

TitanNano
Copy link
Contributor

I came across this reference leak while working on #771. The engine is creating AudioEffectInstances which are being leaked. This is caused by the RawGd::move_return_ptr method.

Calling Godot's ref_set_object creates a new ref counted reference in the engine and increments the count by 1. Since we already hold the initial reference, the count is now at 2. Calling mem::forget(self) on our reference prevents the count from going down to 1 where it should be after we return from our function.

@Bromeon Bromeon added bug c: ffi Low-level components and interaction with GDExtension API labels Aug 9, 2024
Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@Bromeon Bromeon added this pull request to the merge queue Aug 9, 2024
@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-848

@Bromeon Bromeon changed the title RawGd::move_return_ptr with PtrcallType::Virtual leaks reference RawGd::move_return_ptr with PtrcallType::Virtual leaks reference Aug 9, 2024
Merged via the queue into godot-rust:master with commit 558b29f Aug 9, 2024
14 checks passed
@TitanNano TitanNano deleted the jovan/ret_ref_leak branch August 9, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: ffi Low-level components and interaction with GDExtension API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants