SIGSEGV bei std::thread-Zuweisung
-
Moin, mein Programm stürzt bei der Zuweisung eines std::thread-Objekts ab, allerdings nur wenn ich statisch linke.
const int threadCount=4; std::vector<std::thread> threads(threadCount); for (int i=0;i<threadCount;i++)threads[i]=std::thread([=](){searchThread(iterations);});
`
Backtrace:
#0 0x0000000000000000 in ?? ()
#1 0x0000000000413adf in __gthread_equal (__t1=0, __t2=0) at /usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr-default.h:680
#2 0x000000000041a828 in std::operator== (__x=..., __y=...) at /usr/include/c++/4.8/thread:84
#3 0x000000000041a8e3 in std::thread::joinable (this=0x798530) at /usr/include/c++/4.8/thread:162
#4 0x000000000041a870 in std::thread::operator=(std::thread&&)`
Ist an dem Code etwas falsch?
-
Hate richtig gelinkt?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52590
-
Dieser Thread wurde von Moderator/in Arcoth aus dem Forum C++ (alle ISO-Standards) in das Forum Compiler- und IDE-Forum verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Danke, mit
-Wl,--whole-archive -lpthread -Wl,--no-whole-archive
funktioniert es. Ich dachte, es würde reichen, dem Linker -pthread mitzugeben.