-
-
Notifications
You must be signed in to change notification settings - Fork 692
Fixes counting bug with Ref<T>. #660
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
Conversation
|
Just commenting here as well so it's recorded instead of just adding my feedback on godot chat. I think your logic is sound as you've explained in 652, the core issue seems to be that we just copy the pointer into the reference object on the godot side instead of calling the proper setter logic. What I'm wondering about is if this is good/safe enough. This will only work if the reference we're assigning is currently unset. If it is set that means we're just overwriting the current pointer and that object will become dangling. What is should be doing is calling I wonder if this fix should be on the godot side instead of on the godot-cpp side, if that is even possible. Else we may have to enhance this logic to check if there is a current value set on the reference and unref that first. |
include/godot_cpp/classes/ref.hpp
Outdated
| if (p_val != nullptr) { | ||
| p_val->reference(); | ||
| *(void**)p_ptr = p_val->_owner; | ||
| } else { | ||
| *(void**)p_ptr = nullptr; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style issue (spaces vs tabs).
|
Talking some more on Godot chat we're looking at adding a method to the API that allows us to set a reference on the Godot side properly so the full logic runs. |
|
@kidrigger I don't have a good test case to test it with but this should improve your solution to make it a little more safer: This should change your code to: This way we're sure that if a reference object is re-used it will properly clear the previous reference. |
These are likely related to refcounting issues. The change in the SConstruct script fixes a crash that occured somewhere in `bind_get_argument_type` when registering classes and binding methods. Commenting out the `delete`s in destructors fixed a `double free or corruption` crash that occured after the fix described above. Likely related to godotengine/godot-cpp#652, but neither godotengine/godot-cpp#660 or godotengine/godot-cpp#662 seemed to help...
These are likely related to refcounting issues. The change in the SConstruct script fixes a crash that occured somewhere in `bind_get_argument_type` when registering classes and binding methods. Commenting out the `delete`s in destructors fixed a `double free or corruption` crash that occured after the fix described above. Likely related to godotengine/godot-cpp#652, but neither godotengine/godot-cpp#660 or godotengine/godot-cpp#662 seemed to help...
Ref would lose count during return from plugin - either dangling when
directly returned, or double deleted if a Ref is stored.
Fixing by increasing the count before encode.
Fixes: #652