Thread overview
[Issue 23611] Zombie heap leak proof of concept: linked list in dead resized array
Jan 09, 2023
FeepingCreature
Jan 09, 2023
Iain Buclaw
Jan 09, 2023
Iain Buclaw
Jan 09, 2023
Ketmar Dark
Jan 10, 2023
FeepingCreature
January 09, 2023
https://issues.dlang.org/show_bug.cgi?id=23611

--- Comment #1 from FeepingCreature <default_357-line@yahoo.de> ---
Interestingly, this issue cannot be provoked with associative arrays - probably deleting a key zeroes out the associated value.

--
January 09, 2023
https://issues.dlang.org/show_bug.cgi?id=23611

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #2 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to FeepingCreature from comment #0)
> In my post A GC Memory Usage Experiment https://forum.dlang.org/post/befrzndhowlwnvlqcoxx@forum.dlang.org , I suggested the existence of a GC leak caused by downsizing data structures. This bug report poses a proof-of-concept for such a leak:
> 
> struct S {
>     S[] parent;
> }
> 
> void main() {
>     S parent;
>     while (true) {
>         S[] link = [S(null), parent];
>         link.length = 1;

I assume no zeroing is done here because you might have other slices to the data.

    auto slice = link[0 .. $];
    link.length = 1;
    assert(slice[1] == parent);

--
January 09, 2023
https://issues.dlang.org/show_bug.cgi?id=23611

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
January 09, 2023
https://issues.dlang.org/show_bug.cgi?id=23611

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
January 10, 2023
https://issues.dlang.org/show_bug.cgi?id=23611

--- Comment #3 from FeepingCreature <default_357-line@yahoo.de> ---
Well, there's lots of ways to avoid this issue. Zeroing, as you say. I'm just putting up this bug to note it's a straightforward issue as it stands. We're used to treating the GC the way we know it works rather than the way it theoretically could work, doing array.dup to cut off dead elements, etc., and at any rate the GC isn't *obligated* to collect anything ever, etc etc. But naively, this is still surprising behavior.

--