www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16506] New: segfaults with


          Issue ID: 16506
           Summary: segfaults with
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

Found by Ryan who posted to the Learn group:
http://forum.dlang.org/post/vuhulvwgtahinnknntvv forum.dlang.org

Reduced test case:
import std.experimental.allocator: dispose, makeArray;
import std.experimental.allocator.gc_allocator: GCAllocator;
import std.experimental.allocator.mallocator: Mallocator;
import std.experimental.allocator.building_blocks: FreeTree;

void f(ParentAllocator)(size_t sz)
  static FreeTree!ParentAllocator myAlloc;
  byte[] _payload = myAlloc.makeArray!byte(sz, 0);
  assert(_payload, "_payload is null"); /* passes */

version(malloc) void main()

version (gc) void main()

Both versions segfault in Linux.

The malloc version seems to need slightly different numbers for the second
call, depending on details like the version of dmd. On my machine, compiled
with git master dmd, the segfaults occurs with a value of 41 or higher, and
2.071.1 needs 42 or higher. On DPaste, 2.071.1 needs 43 or higher.

No segfault with Windows dmd, tested in Wine.

Sep 17 2016