www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18760] New: theAllocator should hold a reference to the

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

          Issue ID: 18760
           Summary: theAllocator should hold a reference to the allocator
                    that it uses
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: edi33416 gmail.com

Currently, theAllocator does not hold a reference to the underlying process
allocator that does the work. Otherwise, changing the processAllocator will
result in segfault/UB on behalf of theAllocator.

The following snippet better describes the issue, causing a segfault

```
    import std.experimental.allocator.mallocator : Mallocator;

    auto a = sharedAllocatorObject(Mallocator.instance);
    auto buf = theAllocator.allocate(42);
    processAllocator = a;
    theAllocator.deallocate(buf);
```

--
Apr 13 2018