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

Improve thread IDs to avoid collisions with threads not created by the Godot API. #46742

Merged
merged 1 commit into from
Mar 6, 2021

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Mar 6, 2021

Replaces custom thread IDs with std::thread::id hashes.

Fixes #46679, fixes #46550 and fixes #46411

@bruvzg bruvzg added bug topic:core topic:dotnet crash cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Mar 6, 2021
@bruvzg bruvzg added this to the 4.0 milestone Mar 6, 2021
@bruvzg bruvzg requested a review from a team as a code owner March 6, 2021 22:21
@akien-mga akien-mga merged commit 27aacab into godotengine:master Mar 6, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

akien-mga commented Mar 6, 2021

Cherry-picked for 3.2.4.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Mar 6, 2021
@akien-mga
Copy link
Member

Undid my cherry-pick for now (hadn't pushed yet) as it doesn't seem to work as is in 3.2:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
WARNING: start: A Thread object has been re-started without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread.
   At: core/os/thread.cpp:82.
terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument

Program received signal SIGABRT, Aborted.
0x00007ffff7aa04b0 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install lib64bsd0-0.10.0-2.mga8.x86_64 lib64gl1-1.3.2-16.mga8.x86_64 lib64glx0-1.3.2-16.mga8.x86_64 lib64x11_6-1.7.0-1.mga8.x86_64 lib64xau6-1.0.9-2.mga8.x86_64 lib64xcb1-1.14-1.mga8.x86_64 lib64xcursor1-1.2.0-2.mga8.x86_64 lib64xdmcp6-1.1.3-2.mga8.x86_64 lib64xext6-1.3.4-2.mga8.x86_64 lib64xfixes3-5.0.3-3.mga8.x86_64 lib64xi6-1.7.10-2.mga8.x86_64 lib64xinerama1-1.1.4-3.mga8.x86_64 lib64xrandr2-1.5.2-2.mga8.x86_64 lib64xrender1-0.9.10-3.mga8.x86_64
(gdb) bt
#0  0x00007ffff7aa04b0 in raise () from /lib64/libc.so.6
#1  0x00007ffff7a8b526 in abort () from /lib64/libc.so.6
#2  0x0000000001702e2b in __gnu_cxx::__verbose_terminate_handler () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00000000046eb696 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
#4  0x00000000046eb701 in std::terminate () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:58
#5  0x00000000046eb854 in __cxxabiv1::__cxa_throw (obj=obj@entry=0x673e9a0, tinfo=tinfo@entry=0x60cb4e8 <typeinfo for std::system_error>, dest=dest@entry=0x4764820 <std::system_error::~system_error()>)
    at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:95
#6  0x0000000001704c2f in std::__throw_system_error (__i=22) at ../../../../../libstdc++-v3/src/c++11/system_error.cc:338
#7  0x0000000004764d3a in std::thread::detach (this=0x673e8f0) at ../../../../../libstdc++-v3/src/c++11/thread.cc:127
#8  0x00000000043ca577 in Thread::start (this=0x673e8e8, p_callback=0x445cd2b <_IP_ResolverPrivate::_thread_function(void*)>, p_user=0x673e360, p_settings=...) at core/os/thread.cpp:84
#9  0x000000000445c520 in IP::IP (this=0x6725020) at core/io/ip.cpp:319
#10 0x00000000028f666b in IP_Unix::IP_Unix (this=0x6725020) at drivers/unix/ip_unix.cpp:265
#11 0x00000000028f6637 in IP_Unix::_create_unix () at drivers/unix/ip_unix.cpp:262
#12 0x000000000445c44c in IP::create () at core/io/ip.cpp:310
#13 0x00000000042bb622 in register_core_types () at core/register_core_types.cpp:212
#14 0x000000000173db89 in Main::setup (execpath=0x7fffffffdbcb "/home/akien/.local/bin/godot-3.2", argc=0, argv=0x7fffffffd790, p_second_phase=true) at main/main.cpp:361
#15 0x00000000017056f8 in main (argc=1, argv=0x7fffffffd788) at platform/x11/godot_x11.cpp:49

@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Mar 6, 2021
@bruvzg
Copy link
Member Author

bruvzg commented Mar 7, 2021

Undid my cherry-pick for now (hadn't pushed yet) as it doesn't seem to work as is in 3.2:

3.2 have ID initialized in the constructor, it's probably not cherry-picked correctly, and override it with zero.
PR for 3.2: #46749.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Mar 7, 2021
@bruvzg bruvzg deleted the thread_id_fix branch March 7, 2021 09:20
@RedworkDE RedworkDE mentioned this pull request Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants