Summary: Inconsistent flag setting in GC.realloc()
           Product: D
           Version: 2.035
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime

--- Comment #0 from David Simcha <> 2009-10-29 17:26:42 PDT ---
GC.realloc() doesn't set the flags on either the old or new memory block for a
whole bunch of code paths.  I was tipped off to this by reading the code while
trying to add precise heap scanning.  Here's a test program that demonstrates

import std.stdio, core.memory;

void main() {
    doTest(1024 * 1024);

void doTest(size_t multiplier) {
    auto foo = GC.malloc(8 * multiplier);
    auto bar = GC.realloc(foo, 2 * multiplier, GC.BlkAttr.NO_SCAN);

    writeln("Old block attributes:  ", GC.getAttr(foo));
    writeln("New block attributes:  ", GC.getAttr(bar));
    writeln("Old Ptr:  ", foo, "  New Ptr:  ", bar);

Old block attributes:  2
New block attributes:  2
Old Ptr:  961E40  New Ptr:  961E30

Old block attributes:  0
New block attributes:  0
Old Ptr:  10C0000  New Ptr:  10C0000

This is caused by the GC returning early from the B_PAGE path, or if the new
block is almost the same size as the old block.  If I get precise heap scanning
to work, I'll include a fix for this in the patch.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to