| Issue |
63841
|
| Summary |
std::thread creation spuriously fails
|
| Labels |
bug,
libc++
|
| Assignees |
|
| Reporter |
dvyukov
|
While running a program I got a spurious std::system_error exception.
The problem is that std::thread does very simple error handling for pthread_create:
https://github.com/llvm/llvm-project/blob/96ae0851c26237378fa1280b0a9ad713e1b72bdb/libcxx/include/__thread/thread.h#L257-L258
https://github.com/llvm/llvm-project/blob/96ae0851c26237378fa1280b0a9ad713e1b72bdb/libcxx/include/__threading_support#L374
But on Linux clone system call can spuriously fail with EAGAIN:
https://github.com/torvalds/linux/commit/498052bba55ecaff58db6a1436b0e25bfd75a7ff
I think std::thread should do what Go runtime does to avoid spuroius exceptions:
https://github.com/golang/go/blob/2ebe77a2fda1ee9ff6fd9a3e08933ad1ebaea039/src/runtime/cgo/gcc_libinit.c#L99-L111
Unfortunately it's not a good idea to loop infinitely since EAGAIN can be returned for other reasons (no resources, task limit reached).
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs