[Issue 16982] New: std.experimental.allocator.make!T must either call GC.addRange or be marked @system

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Dec 18 10:19:08 PST 2016


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

          Issue ID: 16982
           Summary: std.experimental.allocator.make!T must either call
                    GC.addRange or be marked @system
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: sludwig at outerproduct.org

When creating objects that contain references, make() doesn't currently call
GC.addRange(), which may lead to dangling references in case the GC frees such
an unseen reference.

To fix this, make() must either be marked as @system as soon as an object with
references is created, or preferably, it should call GC.addRange(). A vanilla
version ("makeNoGC"?) could be added to be able to opt-out of this, but it
should be very clear from its name that it is unsafe in a GC scenario, because
this is a pitfall that is very easy to hit.

The same reasoning applies to makeArray().

--


More information about the Digitalmars-d-bugs mailing list