www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18853] New: std.allocator: AllocatorList fails to allocate

https://issues.dlang.org/show_bug.cgi?id=18853

          Issue ID: 18853
           Summary: std.allocator: AllocatorList fails to allocate after a
                    deallocation
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: edi33416 gmail.com
          Reporter: dlang-bugzilla thecybershadow.net
                CC: andrei erdani.com

///////////////////////////// test.d ////////////////////////////
import std.algorithm.comparison;
import std.experimental.allocator;
import std.experimental.allocator.building_blocks.allocator_list;
import std.experimental.allocator.building_blocks.region;
import std.experimental.allocator.gc_allocator;

void main()
{
    AllocatorList!((n) => Region!GCAllocator(max(n, 4096)),
        GCAllocator) allocator;

    auto buf = allocator.allocate(2048);
    allocator.deallocate(buf);
    buf = allocator.allocate(4097);
    assert(buf.length);
}
/////////////////////////////////////////////////////////////////

At a glance, looks like it's caused by the thrashing protection not taking
deallocations into account.

--
May 10 2018