Bug#576485: Acknowledgement (libstdc++: std::thread completely broken)
BTW, one thing I noticed is that the "error code" field in the
std::system_error exception which is raised, seems to be set to EPERM
("Operation not permitted"), but this code is not apparently caused by a
system call (determined by stracing the process).
For instance, changing the test case to this:
#include <cerrno>
#include <iostream>
#include <thread>
int g = 0;
void f ()
{
g++;
}
int main ()
{
std::cerr << "before thread creation..." << std::endl;
try {
errno = 0;
std::thread t (f);
std::cerr << "after thread creation..." << std::endl;
t.join ();
} catch (const std::system_error &e) {
std::cerr << "caught std::system_error, what = \""
<< e.what ()
<< "\", code = " << e.code().message ()
<< std::endl;
}
std::cout << "after joing, g = " << g << std::endl;
return 0;
}
Results in this:
$ g++-4.5 -std=c++0x -o t t.cc
$ ./t
before thread creation...
caught std::system_error, what = "", code = Operation not permitted
after joing, g = 0
strace shows this:
$ strace ./t 2>&1 | tail -20
mprotect(0x7f2036a9c000, 16384, PROT_READ) = 0
mprotect(0x7f2036f3c000, 4096, PROT_READ) = 0
mprotect(0x7f2037229000, 32768, PROT_READ) = 0
mprotect(0x7f2037464000, 4096, PROT_READ) = 0
munmap(0x7f203744b000, 90011) = 0
write(2, "before thread creation...", 25before thread creation...) = 25
write(2, "\n", 1
) = 1
brk(0) = 0x18b2000
brk(0x18d3000) = 0x18d3000
write(2, "caught std::system_error, what ="..., 34caught std::system_error, what = ") = 34
write(2, "\", code = ", 10", code = ) = 10
write(2, "Operation not permitted", 23Operation not permitted) = 23
write(2, "\n", 1
) = 1
fstat(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2037460000
write(1, "after joing, g = 0\n", 19after joing, g = 0
) = 19
exit_group(0) = ?
Thanks,
-Miles
--
Cabbage, n. A familiar kitchen-garden vegetable about as large and wise as a
man's head.
Reply to: