Greetings.
I was recently playing with gcc 4.4.1 and trying to implement some simple code using the experimental support for std::thread in GCC. The only thing I found about support for it was passing -std=c++0x to g++ at compile time...which allows it to compile but even the simplest example segfaults when I go to create an instance of the thread class:
Code:
int testThread()
{
int nRC = 0;
thread t(workFunc, "Foo", 10); // <<== segfaults here
t.join();
return nRC;
}
Now experience tells me that there must be some other lib to link (although I would hope that the compile would produce at least a warning here or something..) but not sure.
There is nothing remarkable about workFunc() though I think the problem is happening before I get there. The call stack looks like this:
Code:
(gdb) where
#0 _dl_fixup (l=<value optimized out>, reloc_arg=<value optimized out>)
at dl-runtime.c:139
#1 0x00f31fc0 in _dl_runtime_resolve () at ../sysdeps/i386/dl-trampoline.S:37
#2 0x00e26d71 in std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>) () from /usr/lib/libstdc++.so.6
#3 0x0030b156 in thread<int (&)(std::string, int), char const (&) [4], int> (
this=0xbffff398, __f=@0x30ad43, __args#0=..., __args#1=@0xbffff394)
at /usr/include/c++/4.4/thread:133
#4 0x0030aed5 in testThread () at /home/jeff/dev/threadcpp/foo.cpp:27
#5 0x08048d38 in main (argc=1, argv=0xbffff4a4)
at /home/jeff/dev/threadcpp/foo_main.cpp:47
(gdb)
Anyhow, unlike everyone else posting here this is not a rush, nothing is "due" I was just curious and wanted to play with some of the new concurrency functionality...
Many thanks in advance
Jeff