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

[C++] Regression in 4.3: std::set_terminate fails to set termination handler #1576

Closed
int-72h opened this issue Sep 10, 2024 · 5 comments
Closed
Labels
bug This has been identified as a bug needs testing

Comments

@int-72h
Copy link

int-72h commented Sep 10, 2024

Tested versions

  • Reproducible in 4.3.stable
  • Not reproducible in 4.2.2.stable

System information

Arch Linux - Ryzen 5 5600X (x86_64)

Issue description

The C++ function std::set_terminate sets the termination function when an exception's not handled. In Godot 4.3.stable, this function doesn't seem to do anything: the stock termination handler is always used. In 4.2.2.stable, this issue isn't there - the function is called.
This doesn't seem to depend on the version of godot_cpp - same version is used (latest) therefore the bug's in the main engine presumably.

Steps to reproduce

  • Download the MRP
  • git submodule update --init to obtain godot-cpp
  • Use scons to build the library + godot-cpp
  • Open the project using godot 4.2.2 (with console). It will crash, however the terminate handler will be called, printing a few extra lines before crashing.
  • Launch godot 4.3 (with console output)
  • Open the project. It will also crash, however the output will be of the standard C++ terminate handler.

Minimal reproduction project (MRP)

mrp.zip

@int-72h int-72h changed the title Regression in 4.3: set_terminate fails to set termination handler [C++] Regression in 4.3: std::set_terminate fails to set termination handler Sep 10, 2024
@akien-mga
Copy link
Member

akien-mga commented Sep 10, 2024

I'm not familiar with that API, but note that both Godot and godot-cpp disable exceptions out of the box since 4.2-stable. For godot-cpp: #1216

Are you building Godot and godot-cpp with disable_exceptions=no?

You mention it worked in 4.2.2, were you using the godot-4.2.2-stable tag of godot-cpp, or an earlier version with updated extension API json (which might not have had exceptions disabled in the SCons code).

@akien-mga
Copy link
Member

I checked the MRP and I see you're passing -fexceptions explicitly, and you're lucky that it ends after the -fno-exceptions defined by godot-cpp by default. I would recommend using env["disable_exceptions"] = False instead.

Original MRP commit for godot-cpp:

g++ -o godot-cpp/gen/src/classes/audio_stream.linux.template_debug.x86_64.o -c -fno-gnu-unique -fno-exceptions -std=c++17 -fPIC -Wwrite-strings -m64 -march=x86-64 -O2 -fvisibility=hidden -fexceptions -DHOT_RELOAD_ENABLED -DLINUX_ENABLED -DUNIX_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -Igodot-cpp/gdextension -Igodot-cpp/include -Igodot-cpp/gen/include -Igodot-cpp/src godot-cpp/gen/src/classes/audio_stream.cpp

godot-4.3-stable

g++ -o godot-cpp/gen/src/classes/expression.linux.template_debug.x86_64.o -c -fno-gnu-unique -std=c++17 -fno-exceptions -fPIC -Wwrite-strings -m64 -march=x86-64 -fvisibility=hidden -O2 -fexceptions -DLINUX_ENABLED -DUNIX_ENABLED -DTHREADS_ENABLED -DHOT_RELOAD_ENABLED -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DNDEBUG -DGDEXTENSION -Igodot-cpp/gdextension -Igodot-cpp/include -Igodot-cpp/gen/include -Igodot-cpp/src godot-cpp/gen/src/classes/expression.cpp

So it should work fine in both cases, the problem must be something else.

I'll move this to godot-cpp as it's not established yet that it's a Godot bug, and not a godot-cpp one or config change.

@akien-mga akien-mga transferred this issue from godotengine/godot Sep 10, 2024
@akien-mga akien-mga added bug This has been identified as a bug needs testing labels Sep 10, 2024
@int-72h
Copy link
Author

int-72h commented Sep 10, 2024

I was using the latest version of godot-cpp in both instances (as that's what the example project does).
The build of 4.3.stable was obtained from the Arch Linux repos, the 4.2.2.stable build from the archive.

I'll try testing this with 4.3.stable from the archive as well, but I don't believe this is a config issue since an exception is thrown in both cases, if there wasn't an exception handler at all it would presumably just crash with zero mention of an exception.

@int-72h
Copy link
Author

int-72h commented Sep 10, 2024

I was using the latest version of godot-cpp in both instances (as that's what the example project does). The build of 4.3.stable was obtained from the Arch Linux repos, the 4.2.2.stable build from the archive.

I'll try testing this with 4.3.stable from the archive as well, but I don't believe this is a config issue since an exception is thrown in both cases, if there wasn't an exception handler at all it would presumably just crash with zero mention of an exception.

I stand corrected. The version from the arch repository doesn't work, however the version from the godot repos works fine. Closing, reopening if it somehow turns out to be a godot bug.

@int-72h int-72h closed this as completed Sep 10, 2024
@dsnopek
Copy link
Collaborator

dsnopek commented Sep 10, 2024

The Godot package on Arch Linux is known to have some problems with GDExtension:

https://gitlab.archlinux.org/archlinux/packaging/packages/godot/-/issues/2

Folks have reported that using the official builds or their own custom builds of Godot seem to work fine.

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 needs testing
Projects
None yet
Development

No branches or pull requests

3 participants