Skip to content
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

Test project builds fine but crashes when ran with official 4.0.alpha10 (both Windows and Linux) #768

Closed
rendawudi opened this issue Jun 16, 2022 · 14 comments · Fixed by #778
Labels
bug This has been identified as a bug crash topic:gdextension This relates to the new Godot 4 extension implementation

Comments

@rendawudi
Copy link

env:
vs2019
godot-alpha10-win64
win10-sdk (10.0.19041.0)
MSVC v142
Cmake 3.23.2
Python 3.9.6

try to clone the newest code as commonds:
git clone --recursive -b master https://github.com/godotengine/godot-cpp
cd .\godot-cpp
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_SYSTEM_NAME=Windows .
cmake --build .

then build test demo with commonds:
cd .\test
cmake -DCMAKE_BUILD_TYPE=Release .
cmake --build .

then move and rename the .dll .exp .lib .pdb from bin to demo/bin
libgdexample.windows.debug.x86_64.dll
libgdexample.windows.debug.x86_64.exp
libgdexample.windows.debug.x86_64.lib
libgdexample.windows.debug.x86_64.pdb

then open godot :

Godot Engine v4.0.alpha10.official.4bbe7f0b9 - https://godotengine.org
Vulkan API 1.2.198 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 2080

Editing project: C:/Users/Administrator/Downloads/gdnative_cpp_example-master/godot-cpp/test/demo (C:::Users::Administrator::Downloads::gdnative_cpp_example-master::godot-cpp::test::demo)

Godot Engine v4.0.alpha10.official.4bbe7f0b9 - https://godotengine.org
ERROR: Condition "!windows.has(p_window)" is true.
at: window_resize (drivers/vulkan/vulkan_context.cpp:1404)
Vulkan API 1.2.198 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 2080

Constructor.
Destructor.

(crash)

@Calinou Calinou added bug This has been identified as a bug topic:gdextension This relates to the new Godot 4 extension implementation crash labels Jun 16, 2022
@Calinou
Copy link
Member

Calinou commented Jun 16, 2022

Official Godot builds are compiled with MinGW, but you used MSVC to compile your extension. This may be the cause of the issue as the GNU and MSVC ABIs are incompatible with each other.

@akien-mga
Copy link
Member

akien-mga commented Jun 16, 2022

I have the same problem on Linux with the official 4.0-alpha10 binaries, while a custom build from the same commit works fine. I've checked and even a custom build with target=release_debug production=yes (i.e. similar to official builds) works, while 4.0.alpha10.official crashes.

I'll keep investigating, maybe it's related to the GCC version used.

@akien-mga akien-mga changed the title win10 vs2019 build successful but open in demo failed (godot.exe crash without err msg) Test project builds fine but crashes when ran with official 4.0.alpha10 (both Windows and Linux) Jun 16, 2022
@akien-mga
Copy link
Member

Likely related to godotengine/godot#61963

@oparisy
Copy link

oparisy commented Jun 26, 2022

I reproduced this with Visual Studio 2022 and 4.0.alpha10.official.

The issue disappeared when compiling Godot myself with VS2022 (from the alpha10 commitId), so @Calinou analysis is certainly proper in this case.

I guess the official GDExtension documentation will need to touch on this: something along the line of "use MinGW if you did not compile Godot yourself" I guess?

@dsge
Copy link

dsge commented Jun 26, 2022

I guess the official GDExtension documentation will need to touch on this: something along the line of "use MinGW if you did not compile Godot yourself" I guess?

That's not good enough as this also affects Linux.

@oparisy
Copy link

oparisy commented Jun 26, 2022 via email

@oparisy
Copy link

oparisy commented Jun 26, 2022

@Calinou Isn't this issue contradicting with this tweet for example? Doesn't this mean that a unique compiler per platform (the one used to build the official releases) will be usable when willing to distribute compiled extensions?

@tancop
Copy link
Contributor

tancop commented Jun 27, 2022

I'm getting this in the test project on Linux, definitely related to static methods. Removing them fixes the crash.

@oparisy
Copy link

oparisy commented Jun 27, 2022 via email

@Faless
Copy link
Contributor

Faless commented Jun 27, 2022

Doesn't this mean that a unique compiler per platform (the one used to build the official releases) will be usable when willing to distribute compiled extensions?

I don't think that's the case, the old WebRTC GDNative plugin was built with MSVC and was working with the official Godot version compiled with gcc/mingw

@alessandrofama
Copy link
Contributor

alessandrofama commented Jun 28, 2022

If this is related to godotengine/godot#61963 then I think it could be about the GDNativePropertyInfo struct variable pinfo having garbage values for static methods without return after get_argument_info_func is called:
https://github.com/godotengine/godot/blob/f41cb30f9b7fe46a014162aba9c0e9a9697343d2/core/extension/native_extension.cpp#L55-L66

What fixes the crash for me on Windows (MSVC) and macOS (Clang) is making sure the GDNativePropertyInfo struct variable pi is initialized with some default values in gen_argument_type_info if p_arg is -1, otherwise pi will stay uninitialized in the consequent call to call_get_argument_type_info.

This is what I noticed by stepping in the debugger, not 100% sure as I don't fully understand GDExtensions, but it's still fun trying to track down the issue. I've pushed the small change in my branch if anyone wants to check if it fixes the issue.

@tancop
Copy link
Contributor

tancop commented Jul 3, 2022

This is what I noticed by stepping in the debugger, not 100% sure as I don't fully understand GDExtensions, but it's still fun trying to track down the issue. I've pushed the small change in my branch if anyone wants to check if it fixes the issue.

Your commit fixes it on Linux/GCC. You should make a PR and get it merged.

@dsge
Copy link

dsge commented Jul 3, 2022

Your commit fixes it on Linux/GCC. You should make a PR and get it merged.

I got the same result also on Linux/GCC.

With @alessandrofama's patch I am able to Play the test project and press the "Click me!" button on the release_debug editor build (alpha10), whereas without the patch the editor would crash while opening the project. The debug editor worked with or without the patch, which is puzzling though.

Anyway, I too agree that he should make a PR :)

@akien-mga
Copy link
Member

Fixed by #778.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This has been identified as a bug crash topic:gdextension This relates to the new Godot 4 extension implementation
Projects
None yet
8 participants