www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20497] New: thread with limited stackspace crashes depending


          Issue ID: 20497
           Summary: thread with limited stackspace crashes depending on
                    size of TLS
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

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);

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

Jan 10 2020