Bug 17564 – std.experimental.allocator.theAllocator is null within shared static this

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-28T12:44:04Z
Last change time
2018-01-05T13:29:39Z
Assigned to
No Owner
Creator
Sönke Ludwig

Comments

Comment #0 by sludwig — 2017-06-28T12:44:04Z
vibe.d needs to use "shared static this" for initialization to support the original initialization scheme for applications that it still in wide use. With 2.075.0-b1, since processAllocator now returns an ISharedAllocator, it had to switch to theAllocator where possible. However, since this returns null during the "shared static this" phase, this causes a crash on startup. Setting theAllocator to something else also doesn't work, because of an assertion in std.experimental.allocator. Proposed change is to make initialization lazy, just as for processAllocator.
Comment #1 by github-bugzilla — 2017-06-29T13:23:12Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a5d2b3b189f072e9bd0b1779a7d585e3945921b Fix issue 17564: Eliminate "static this" for theAllocator This switches to lazy initialization of theAllocator, so that accessing it form within `shared static this` works as expected. https://github.com/dlang/phobos/commit/2e0a49cd397ea1bdb993e3a9271193cf6051b8ce Merge pull request #5519 from s-ludwig/lazy_the_allocator Issue 17564: Eliminate "static this" for theAllocator merged-on-behalf-of: Martin Nowak <[email protected]>
Comment #2 by github-bugzilla — 2017-07-08T17:09:28Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a5d2b3b189f072e9bd0b1779a7d585e3945921b Fix issue 17564: Eliminate "static this" for theAllocator https://github.com/dlang/phobos/commit/2e0a49cd397ea1bdb993e3a9271193cf6051b8ce Merge pull request #5519 from s-ludwig/lazy_the_allocator
Comment #3 by github-bugzilla — 2018-01-05T13:29:39Z
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/4a5d2b3b189f072e9bd0b1779a7d585e3945921b Fix issue 17564: Eliminate "static this" for theAllocator https://github.com/dlang/phobos/commit/2e0a49cd397ea1bdb993e3a9271193cf6051b8ce Merge pull request #5519 from s-ludwig/lazy_the_allocator