Bug 20497 – thread with limited stackspace crashes depending on size of TLS
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2020-01-10T17:49:31Z
Last change time
2020-01-11T12:36:42Z
Keywords
pull
Assigned to
No Owner
Creator
Rainer Schuetze
Comments
Comment #0 by r.sagitario — 2020-01-10T17:49:31Z
import core.thread;
import core.stdc.stdio;
ubyte[9000] data;
void task()
{
ubyte[1024] useStack;
printf("%p\n", useStack.ptr);
}
void main()
{
auto th = new Thread(&task, 16384);
th.start();
th.join();
}
Running this code on Ubuntu 19 crashes with a segmentation fault. If the size of data[] is reduced to 8000, the program runs as expected. With size of data[] of 16kB, you get the error
core.thread.osthread.ThreadError@src/core/thread/osthread.d(3184): Error creating thread
Comment #1 by dlang-bot — 2020-01-10T20:32:28Z
@rainers created dlang/druntime pull request #2904 "fix Issue 20497 - thread with limited stackspace crashes depending on…" fixing this issue:
- fix Issue 20497 - thread with limited stackspace crashes depending on size of TLS
on Posix systems, add the TLS size to the requested stack size for new threads
https://github.com/dlang/druntime/pull/2904
Comment #2 by dlang-bot — 2020-01-11T12:36:42Z
dlang/druntime pull request #2904 "fix Issue 20497 - thread with limited stackspace crashes depending on…" was merged into stable:
- d8876bc9f7b898047759cdc683afebb85a5c0353 by Rainer Schuetze:
fix Issue 20497 - thread with limited stackspace crashes depending on size of TLS
on Posix systems, add the TLS size to the requested stack size for new threads
https://github.com/dlang/druntime/pull/2904