Bug 18760 – theAllocator should hold a reference to the allocator that it uses

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2018-04-13T15:07:33Z
Last change time
2018-04-17T20:13:16Z
Assigned to
Eduard Staniloiu
Creator
Eduard Staniloiu

Comments

Comment #0 by edi33416 — 2018-04-13T15:07:33Z
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); ```
Comment #1 by github-bugzilla — 2018-04-17T20:13:15Z
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4126f928270570c9149a6412acde16f16506fd39 Merge pull request #6449 from edi33416/fix_thread_alloc Fix Issue 18760 - theAllocator dangling reference bug