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

Segmentation fault on exit in Time destructor #12

Closed
akien-mga opened this issue May 7, 2024 · 3 comments
Closed

Segmentation fault on exit in Time destructor #12

akien-mga opened this issue May 7, 2024 · 3 comments
Labels
bug A bug, crash, or performance issue
Milestone

Comments

@akien-mga
Copy link

akien-mga commented May 7, 2024


When testing boscaceoil-blue with self-compiled gdsion and latest upstream Godot, I get a segfault on exit (just running the project, not doing anything and quitting with the X window button triggers it).

The stacktrace isn't super helpful:

(gdb) bt
#0  0x00007fffdea5df4b in ?? ()
YuriSizov/boscaceoil-blue#1  0x000000000aad035c in Object::~Object (this=0xb276090, __in_chrg=<optimized out>) at ./core/object/object.cpp:2145
#2  0x000000000a528ff1 in Time::~Time (this=0xb276090, __in_chrg=<optimized out>) at ./core/os/time.cpp:450
#3  0x000000000a4d1ca8 in memdelete<Time> (p_class=0xb276090) at ./core/os/memory.h:116
YuriSizov/gdsion#12  0x000000000a484f36 in unregister_core_types () at ./core/register_core_types.cpp:441
#5  0x0000000005b7255c in Main::cleanup (p_force=false) at main/main.cpp:4317
#6  0x0000000005ab37d1 in main (argc=1, argv=0x7fffffffd728) at platform/linuxbsd/godot_linuxbsd.cpp:89

I'm using dev_builds for both Godot and GDSiON but can't seem to get more details from gdb. I'm not sure if it's not able to load debug symbols from the shared library or if it's something else.

Might very well be a Godot or godot-cpp bug, but starting with a downstream report until we can assess where the crash comes from.


The stacktrace mentions the Time destructor, and I see it's indeed used by GDSiON:

$ rg Time
src/sion_driver.cpp
449:    int start_time = Time::get_singleton()->get_ticks_msec();
461:    _performance_stats.processing_time_data->value = Time::get_singleton()->get_ticks_msec() - start_time;
501:    int start_time = Time::get_singleton()->get_ticks_msec();
505:    _performance_stats.compiling_time = Time::get_singleton()->get_ticks_msec() - start_time;
523:    int start_time = Time::get_singleton()->get_ticks_msec();
531:    _performance_stats.rendering_time = Time::get_singleton()->get_ticks_msec() - start_time;
815:    _performance_stats.frame_timestamp = Time::get_singleton()->get_ticks_msec();
902:    int start_time = Time::get_singleton()->get_ticks_msec();
907:                    _performance_stats.compiling_time += Time::get_singleton()->get_ticks_msec() - start_time;
913:                    int rendering_time = Time::get_singleton()->get_ticks_msec() - start_time;
920:                            rendering_time = Time::get_singleton()->get_ticks_msec() - start_time;
923:                    _performance_stats.rendering_time += Time::get_singleton()->get_ticks_msec() - start_time;
939:    int t = Time::get_singleton()->get_ticks_msec();

src/sequencer/base/mml_parser.cpp
335:    _parsing_time = Time::get_singleton()->get_ticks_msec();
371:    _start_time = Time::get_singleton()->get_ticks_msec();
556:    _parsing_time = Time::get_singleton()->get_ticks_msec() - _parsing_time;
782:            return _interrupt_interval < (Time::get_singleton()->get_ticks_msec() - _start_time);

Presumably removing this Time::get_singleton() dependency might "solve" the issue. I'll see if I can make a MRP using Time::get_singleton() that crashes similarly so we can move the bug report upstream.

@akien-mga akien-mga changed the title Segmentation fault on exit in Timer destructor Segmentation fault on exit in Time destructor May 7, 2024
@akien-mga
Copy link
Author

akien-mga commented May 7, 2024

Yeah I could reproduce this upstream with:

diff --git a/test/src/example.cpp b/test/src/example.cpp
index 3ec8bca..89e5d12 100644
--- a/test/src/example.cpp
+++ b/test/src/example.cpp
@@ -11,6 +11,7 @@
 #include <godot_cpp/classes/label.hpp>
 #include <godot_cpp/classes/multiplayer_api.hpp>
 #include <godot_cpp/classes/multiplayer_peer.hpp>
+#include <godot_cpp/classes/time.hpp>
 #include <godot_cpp/variant/utility_functions.hpp>
 
 using namespace godot;
@@ -297,6 +298,8 @@ Example::~Example() {
 
 // Methods.
 void Example::simple_func() {
+	int time = Time::get_singleton()->get_ticks_msec();
+	printf("time: %d\n", time);
 	emit_custom_signal("simple_func", 3);
 }
 

I'll open an issue on godot-cpp.
Edit: I see it's already reported on godotengine/godot-cpp#889 and you commented there.

Feel free to close this as an upstream bug, unless you want to work it around downstream to avoid the crash.

@YuriSizov
Copy link
Owner

Thanks for the report!

Yeah, it's well known at this point, but having an official issue on this here is a good thing. I'll keep it open as a reminder, because indeed I may have to work around it on GDSiON's end using mihe's suggestion. I'll just transfer this to the GDSiON repo, since there is nothing that can be done in Bosca Ceoil's code.

@YuriSizov YuriSizov transferred this issue from YuriSizov/boscaceoil-blue May 7, 2024
@YuriSizov YuriSizov added the bug A bug, crash, or performance issue label May 7, 2024
@YuriSizov
Copy link
Owner

YuriSizov commented May 16, 2024

godotengine/godot-cpp#1458 resolves the crash, so a workaround is not necessary. But I can't update to a newer version of godot-cpp just yet because no official build of 4.3 is compatible with it (see PackedVector4Array changes). So will have to wait until beta 1 or 2. Keeping it open in the meantime.

@YuriSizov YuriSizov added this to the 0.7 milestone Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug, crash, or performance issue
Projects
None yet
Development

No branches or pull requests

2 participants