www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17914] New: Accidental per-process limit of fiber uses


          Issue ID: 17914
           Summary: Accidental per-process limit of fiber uses
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: industry
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: briancschott gmail.com

The fiber stack overflow protection introduced in 2.075 has introduced a
per-process limit of the number of times a function implemented using fibers
can be called. This limit is located in `/proc/sys/vm/max_map_count`.

The problem is caused by unbalanced calls to `allocStack` and `freeStack` in
core.thread. There is one call to mmap and one call to mprotect per fiber use,
but no corresponding call to munmap to deallocate the memory protection
information inside of the kernel. This is caused by the fact that Fiber is a
class and `freeStack` is only called in Fiber's destructor. (Which of course
means there's no guarantee that it is run.) Once this limit (65530) is hit, the
program fails with a SIGABRT.

Oct 18 2017