Repository navigation
Closed
Labels
bugThis has been identified as a bugcrashtopic:gdextensionThis relates to the new Godot 4 extension implementation
Description
When trying to call methods like Mesh::get_surface_count and Mesh::surface_get_material I get a crash. This is definitely a GDExtension issue as it doesn't happen when called from GDScript.
Backtrace (for surface_get_material):
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha7.official (3e9ead05f2e87e46b5982cc9a140e172ee98c227)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x42750) [0x7f09ad6c9750] (??:0)
[2] godot::Mesh::surface_get_material(int) const (??:0)
[3] ExampleRef::test(godot::Ref<godot::ArrayMesh>) (??:0)
[4] void godot::call_with_variant_args_helper<godot::___UnexistingClass, godot::Ref<godot::ArrayMesh>, 0ul>(godot::___UnexistingClass*, void (godot::___UnexistingClass::*)(godot::Ref<godot::ArrayMesh>), godot::Variant const**, GDNativeCallError&, IndexSequence<0ul>) (??:0)
[5] void godot::call_with_variant_args_dv<godot::___UnexistingClass, godot::Ref<godot::ArrayMesh> >(godot::___UnexistingClass*, void (godot::___UnexistingClass::*)(godot::Ref<godot::ArrayMesh>), void* const*, int, GDNativeCallError&, std::vector<godot::Variant, std::allocator<godot::Variant> > const&) (??:0)
[6] godot::MethodBindT<godot::Ref<godot::ArrayMesh> >::call(void*, void* const*, long, GDNativeCallError&) const (??:0)
[7] godot::MethodBind::bind_call(void*, void*, void* const*, long, void*, GDNativeCallError*) (??:0)
[8] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x3f9f3cf] (??:0)
[9] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x402686b] (??:0)
[10] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x3edbeca] (??:0)
[11] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x174ac87] (??:0)
[12] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x163bb78] (??:0)
[13] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x280eb43] (??:0)
[14] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x1405793] (??:0)
[15] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x4010684] (??:0)
[16] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x27d5a06] (??:0)
[17] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x27d59af] (??:0)
[18] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x280e0df] (??:0)
[19] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0x283e61f] (??:0)
[20] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0xd5862d] (??:0)
[21] /lib64/libc.so.6(+0x2d560) [0x7f09ad6b4560] (??:0)
[22] /lib64/libc.so.6(__libc_start_main+0x7c) [0x7f09ad6b460c] (??:0)
[23] /home/tpotancok/Programs/Godot_v4.0-alpha7_linux.64() [0xd71cde] (??:0)
-- END OF BACKTRACE --
================================================================
Reproduction project: extension-crash.tar.gz
Metadata
Metadata
Assignees
Labels
bugThis has been identified as a bugcrashtopic:gdextensionThis relates to the new Godot 4 extension implementation
Activity
Zylann commentedon Jul 1, 2022
godot::___UnexistingClassthat looks odd.Is this happening exclusively on meshes? My guess is, it's yet another occurence of
Ref<T>passing being buggy somewhat, there are already various reported bugs which could be related to this one.Note 1: for better troubleshooting of errors you might find, consider compiling the bindings and your library in debug mode, so that more info will be visible, and it will allow you to attach a debugger to inspect variables. For example, it can show that some pointer is null or some memory was used after being freed thanks to a binary pattern etc.
Note 2:
register_types.osin your files,.osis a bogus extension, with GCC it should be.ofor object files generated by the compiler. That was a mistake done in the past in a SCons script example but keeps being copied by everyone it seems (even though the linker doesn't seem to care about the extension?).Note 3:
Always check for
nullbefore accessing a pointer passed from GDScript. I assume it's ok here, but it's to rule out any mistake because it could cause similar crashes.Note 4:
#include <godot_cpp/variant/utility_functions.hpp>Where is this file? I don't see it in https://github.com/godotengine/godot-cpp/tree/master/include/godot_cpp/variant
tancop commentedon Jul 4, 2022
No, I tested it on a
Texture2Dand also get a crash. Backtraces here.Both are compiled in debug mode. The godot binary is
release_debugbecause it's an official alpha.Tried that, still segfaults with the same backtrace.
I also don't see it, but it works and it's used in the official test project. Odd.
[-]Calling surface related methods on `Mesh` crashes[/-][+]Calling methods that return a `Ref` crashes[/+]Faless commentedon Jul 4, 2022
That file is generated by the binding generator script: https://github.com/godotengine/godot-cpp/blob/master/binding_generator.py#L1361
Zylann commentedon Jul 4, 2022
Note when I mean to use debug mode, this won't give more info in crash dumps of Godot. The idea is so you can attach a C++ debugger while running your project so that if a crash occurs it will stop at a breakpoint, allowing to inspect things.
tancop commentedon Jul 4, 2022
I attached
gdb, that's how I got the new backtraces.tancop commentedon Jul 16, 2022
Looks like this is fixed in the new version but only for types that directly extend
RefCountedorResource(Texture2DandArrayMeshwith other base classes still crash). This remaining bug is older and already mentioned in #662.