Closed YuriSizov closed 4 months ago
My extension fails at load because of this bug. Adding the changes here fixed it. Crashes when declaring the method_info
variable in ClassDB::bind_method_godot
when dereferencing the return_value_metadata
which seems to be null because of an empty vector.
Cherry-picked for 4.2 in PR https://github.com/godotengine/godot-cpp/pull/1527
Cherry-picked for 4.1 in PR https://github.com/godotengine/godot-cpp/pull/1529
While there doesn't seem to be any runtime issues, this triggers the address sanitizer in a few ways, depending on what kind of method you're binding.
For a method like this, with a return value
you get a container overflow. It even reaches the Godot side of things, but the bug is caused by
godot-cpp
all the same: the argument metadata is invalid.A method like this, without a return value and with arguments
causes heap buffer overflow. The return value metadata is invalid.
Looks like this was introduced as is in https://github.com/godotengine/godot-cpp/pull/896, in commit https://github.com/godotengine/godot-cpp/commit/e24b6b0e517bbebe4ed98d9736c0c7219c418b99. A similar method
get_arguments_info_list
had the same issue initially, but was corrected in https://github.com/godotengine/godot-cpp/commit/b6ba0dca13c1cda5826f23abf203c2f05c0bee42, all within the same PR.I can't say if this change has any unexpected side effects, or if it fixes any outstanding issues (quite possible, anything related to arguments can be affected, I guess?), but I can confirm that with it included there are no asan issues in my project anymore.