got this problem - in title..
I have this code:
#include <thread>
#include <iostream>
void my_thread_func()
{
std::cout<<"hello"<<std::endl;
}
int main()
{
std::thread t(my_thread_func);
t.join();
}
taken somewhere from web. compiler options -pthread -std=gnu++0x (also tried -std=c++0x) and I have segfault. All is on Debian on vmBox.. I have launched other codes before, and they worked. Suddenly I have segfault on threads with std::thread in all working apps.
EDIT: this is from gdb:
(gdb) where
#0 0x00000000 in ?? ()
#1 0x08048dc9 in thread<void (*)()> (this=0xbffff3fc,
__f=0x8048b9f <my_thread_func()>) at /usr/include/c++/4.4/thread:129
#2 0x08048bea in main () at ../test.cpp:18
(when I launch more advanced apps with std::thread t(&ClassName::my_thread_func,ptr) error is same, but other line [thread:133])
I was searching trough the web but I have not found nothing suitable.
compile with g++ -std=c++0x -lpthread
. Note the l
before pthread
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With