Skip to content

Conversation

@briansemrau
Copy link
Contributor

@briansemrau briansemrau commented Sep 27, 2021

GDScript 2.0 opcode OPCODE_CALL_PTRCALL_OBJECT will double-reference returned Refs. This results in a memory leak.
This change fixes that issue while still keeping the fixes of #43992

Fixes #53093
Fixes #52699
(both issues are the same underlying bug)

@vnen Requesting review to make sure there are no regressions to #43941 or #43851

@briansemrau briansemrau requested a review from a team as a code owner September 27, 2021 16:29
@akien-mga akien-mga added this to the 4.0 milestone Sep 27, 2021
@akien-mga akien-mga requested a review from vnen September 27, 2021 16:51
@akien-mga
Copy link
Member

The current version looks pretty clean, kudos. I'll let @vnen review/confirm that it's the best approach.

@akien-mga
Copy link
Member

Poke @vnen.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 31, 2022

I checked #52699 and with my original code some instances are still leaked with the typed line. So it fixes only half of the issue.

Copy link
Member

@vnen vnen left a comment

Choose a reason for hiding this comment

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

It looks okay to me. I guess this a bit tricky to wrap the head around since there's a lot going on under the hood.

I wonder if we should restore the set_object() function that I removed in #43992, though having one just for updating the ID should be good enough.

Maybe a comment here about the reference counting would be handy so it isn't wrongly changed in the future.

@akien-mga akien-mga merged commit 622b656 into godotengine:master Jun 28, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GDScript 2.0] RefCounted objects leaking when calling a bound C++ function that returns a Ref Some Tweeners are leaking references

4 participants