-
-
Notifications
You must be signed in to change notification settings - Fork 576
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
Handling exception crashes editor/program #1326
Comments
Are you building the editor with errors enabled as well? |
I used the default binary editor. Looks like in the 4.2 update, they updated disable_exceptions from false -> true by default, so none of the provided binary distributions work. However, it works if I compile the engine myself with |
Then the question is if we need some way to handle errors with the engine built without, or if it's not possible to support errors without the binary also supporting it |
I'm not able to reproduce this using the same code in the issue description. (Although, I didn't use the MRP from the ZIP, I copy-pasted the code into my own local project.) For me, creating an instance of the
I'm using the latest godot-cpp I'm not sure what could be the difference could be between your setup and mine? |
Compiling Godot with I think the default of Is there any way to avoid the breakage caused by the default |
Please read the conversation above, this is the question being investigated 🙂 |
@kb173 Can you share a project that reproduces this issue? I tried reproducing using the code from the OP, and I'm able to compile a GDExtension that uses exceptions which is loaded by the official Godot binaries (4.2-stable) which have exceptions disabled, and everything seems to work correctly. |
Disabling exception handling speeds up compilation and reduces binary size considerably. See comparisons on Godot itself: godotengine/godot#80612 Ideally, C++ libraries themselves shouldn't use exceptions for better portability (consider this if you're writing your own libraries). You should only pay for the performance cost of features you actually need 🙂 |
I see. I'm not using exceptions myself though, as noted in #1341 and godotengine/godot#85959, basic C++ functionality like writing to
I didn't do any testing with actually throwing exceptions since I got here from #1341, but running the test project from this repository breaks for me unless I use a manually compiled Godot binary with the following change: diff --git a/test/src/example.cpp b/test/src/example.cpp
index 5372d70..5600869 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -13,6 +13,8 @@
#include <godot_cpp/classes/multiplayer_peer.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
+#include <iostream>
+
using namespace godot;
@@ -288,6 +291,7 @@ Example::~Example() {
// Methods.
void Example::simple_func() {
+ std::cout << "simple func" << std::endl;
emit_custom_signal("simple_func", 3);
} |
@kb173 I just tried using your patch and running the test project, and it worked fine for me :-/ I'm on Ubuntu 22.04, using GCC 11.4 and running with the stock Godot 4.2.1-stable binary (so not compiled with any special arguments). I compiled the test GDExtension with just plain And when I run the test project in Here's my full output:
So, there is some difference that you, @Vantskruv and @id01 are encountering, and we really need to figure out what it is, so we can give proper direction to users, or fix the bug if one exists. Neither your example, nor the original one here that actually uses exceptions, should be crashing. |
Looking over the 3 issues, it seems like all were on Arch Linux or descendant (one was Manjaro which is based on Arch). I wonder if that is somehow related? When I get a chance, I'm going to setup a VM with Arch and see if I can reproduce it there. |
Oooh, your hunch about it being Arch Linux related seems to be right. I just tested my reproduction patch with v4.2.1.stable.official.b09f793f5 (downloaded from the website) and it works fine, it's printing "simple func" and not crashing - even without any I guess the whole |
@kb173 I just tested the Binary distribution from Godot's site directly. It works. Then, I tried the Arch version. It doesn't. This is for 4.2.1 this time. |
@kb173 @id01 Thanks for testing! If someone opens an issue with Arch, I don't know where they they keep their issues, but if you could put a link to the issue in a comment here so we can follow its progress, that would be really great :-) EDIT: This looks like the place to report an issue, however, so far I haven't managed to create an account so that I can post one :-/ |
I opened an issue there: https://gitlab.archlinux.org/archlinux/packaging/packages/godot/-/issues/2 Let me know if I missed anything in the description! |
Godot version
4.2.stable
godot-cpp version
4.2.stable
System information
Arch Linux
Issue description
A handled exception in C++ crashes the Godot editor and the program.
Example code causing crash:
When this code is put in a GDExtension, the editor crashes with SIGABRT.
Relevant traceback portion:
I don't think it should cause a crash when disable_exceptions=false is specified in scons
Steps to reproduce
Compile the minimal reproduction project with
Open the minimal reproduction project in the editor
Minimal reproduction project
archive.zip
The text was updated successfully, but these errors were encountered: