WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
361 stars 27 forks source link

Fixed crashes with pushVariant #138

Closed Trey2k closed 1 year ago

Trey2k commented 1 year ago

This fixed some crashes that were reported in discord. There was 2 separate issues. One which effected module builds and one which effected GDExtension builds.

For the module builds:

~The issue was with the fact that we create Variant pointers with lua_newuserdata. The can cause issues because of the way Variants work, for primitives it will store the literal value. Object and RefCounted types are pointers. The issue we were having is Variant has an assignment operator that calls clear() for primitives this sets the 0 value, for objects and refcounted types it calls their clear() method. Its a switch case for the type. Objects go to default. However since our initial Variant was allocated by lua its dirty memory so it has an invalid type that it tries to use to lookup its clear method. But since its invalid it dose not exist~

The issue is we need to also manually refCount for objects like we did for GDExtension

For GDExtension builds:

The issue had to do with a long know issue to do with Object::cast_to that should of bee caught earlier.

CC @vitawrap