[Issue 6014] rt_finalize Segmentation fault , dmd 2.053 on linux & freebsd

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 13 17:52:41 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6014


dawg at dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #18 from dawg at dawgfoto.de 2011-09-13 17:52:15 PDT ---
@changlon

You won't like the cause of your bug.
All fields in a struct are default initialized.
Pointers with null, Integrals with 0, Floats with NaN and enums with
the first enum member.

enum BlkAttr : uint
{
    FINALIZE    = 0b0000_0001, /// Finalize the data in this block on collect.
    NO_SCAN     = 0b0000_0010, /// Do not scan through this block on collect.
    NO_MOVE     = 0b0000_0100,  /// Do not move this memory block on collect.
    APPENDABLE  = 0b0000_1000, /// This block contains the info to allow
appending.
    NO_INTERIOR = 0b0001_0000
}

That means the attr flag in your memory pool is always set to BlkAttr.FINALIZE.
Every GC.malloc you do will get a wrong finalization.
It can be avoided this by giving a default value to the field.
GC.BlkAttr attr = cast(GC.BlkAttr)0;
Arguably this could be the default member in BlkAttr.

I will close this bug and open a new one for the order of class finalization.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list