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 */ myAlloc.dispose(_payload); } version(malloc) void main() { f!Mallocator(33); f!Mallocator(43); } version (gc) void main() { f!GCAllocator(1); } ---- 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.
With the malloc version, I got this output: malloc.c:2369: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed. To me, it looks like the problem is specific to FreeTree. Changing the title to reflect this.
https://github.com/dlang/phobos/pull/4798
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/2a2e04b9c7b0c7fa10b22254b95aa2cb7826a82c fix issue 16506 - segfaults in std.experimental.allocator: FreeTree with GCAllocator or Mallocator https://github.com/dlang/phobos/commit/25418edb0611ca6de06c6a8d7281407cd4c9a2e6 Merge pull request #4798 from aG0aep6G/FreeTree std.experimental.allocator: fix FreeTree issues 16506 and 16507
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/2a2e04b9c7b0c7fa10b22254b95aa2cb7826a82c fix issue 16506 - segfaults in std.experimental.allocator: FreeTree with GCAllocator or Mallocator https://github.com/dlang/phobos/commit/25418edb0611ca6de06c6a8d7281407cd4c9a2e6 Merge pull request #4798 from aG0aep6G/FreeTree