I have created a simple program using two C++ threads: ``` #include <iostream> #include <mutex> #include <thread> int num = 0; std::mutex mut{}; void func() { for (int i = 0; i < 10000; ++i) { std::lock_guard lock(mut) ++num; } } int main() { std::thread thread1 = std::thread(func); std::thread thread2 = std::thread(func); thread2.join(); thread1.join(); printf("%d\n", num); return 0; } ``` Compiling this with `g++13 -static -O3 -pthread main.cpp` and running `./a.out` generates a core dump: ``` zsh: abort (core dumped) ./a.out ``` I've tried linking with `-lthr` and `-static-libstdc++` and `-static-libgcc` but those should be implied by `g++ -static` anyways. I'm working on a project where this issue occures aswell when using the pthread.h header instead of C++ threads. Clang's static and dynammic output works as expected as well as gcc's dynamic executable.
Created attachment 244418 [details] Backtrace of `gcc -static -g3 -pthread main.cpp`
I should probably deal with this bug since I am now the maintainer of all the GCC ports for supported versions. Gerald: would you like me to assign this bug to myself? Please mind that I cannot deal with it right now: as you know, I am already busy with a lot of things, GCC default version update included, but I can get to it when the update is finished. Moreover, would it make more sense if I took maintainership of lang/gcc? Or would you like to keep it?
Yes, agreed, this is actually an issue for the specific lang/gcc* ports, not lang/gcc as such. (In terms of maintainership I'm happy to keep lang/gcc.)