Thread overview
[Issue 24856] std.array.Appender.ensureAddable can create stale memory references
Nov 13
apham
Nov 14
Dlang Bot
Nov 14
Dlang Bot
November 13
https://issues.dlang.org/show_bug.cgi?id=24856

apham <apz28@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |apz28@hotmail.com

--- Comment #1 from apham <apz28@hotmail.com> ---
In light of this bug, can build in array also affected by this bug since there are various bugs reported of runtime memory leak?

--
November 13
https://issues.dlang.org/show_bug.cgi?id=24856

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #2 from Nick Treleaven <nick@geany.org> ---
I've made a pull to add warnings to core.memory about uninitialized bytes
containing GC pointers:
https://github.com/dlang/dmd/pull/17061

--
November 13
https://issues.dlang.org/show_bug.cgi?id=24856

--- Comment #3 from Steven Schveighoffer <schveiguy@gmail.com> ---
(In reply to apham from comment #1)
> In light of this bug, can build in array also affected by this bug since there are various bugs reported of runtime memory leak?

You are right. The same mistake is made there. Very interesting!

https://github.com/dlang/dmd/blob/5cce98ed7fbd80cad0f7dcce08c09da3c1bffad8/druntime/src/rt/lifetime.d#L1906

--
November 13
https://issues.dlang.org/show_bug.cgi?id=24856

--- Comment #4 from Steven Schveighoffer <schveiguy@gmail.com> ---
(In reply to apham from comment #1)
> since there are various bugs reported of runtime memory leak?

Do you have references to these bugs?

--
November 14
https://issues.dlang.org/show_bug.cgi?id=24856

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@schveiguy created dlang/phobos pull request #9084 "Fix appender code that might not initialize memory that might point at huge allocations" fixing this issue:

- Fix bugzilla issue 24856 - Make sure appender doesn't leave some stale
  pointers in unallocated space, thereby pinning unused memory.

https://github.com/dlang/phobos/pull/9084

--
November 14
https://issues.dlang.org/show_bug.cgi?id=24856

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=24860

--
November 14
https://issues.dlang.org/show_bug.cgi?id=24856

--- Comment #6 from Steven Schveighoffer <schveiguy@gmail.com> ---
(In reply to Steven Schveighoffer from comment #3)
> You are right. The same mistake is made there. Very interesting!
> 


I made a bug report for this, but I'm realizing it's not actually a problem in current released compilers, nor will it be a problem in 2.110, due to a quirk in the way small allocations are grown, and the way large allocations are scanned. So this would not explain any existing bugs with memory leaks.

The 2.111 version however, was changed to adjust the growth factor for small blocks, so this problem would appear in that unless we do something.

In any case, I created issue 24860 to track that, it is separate from this.

--
November 14
https://issues.dlang.org/show_bug.cgi?id=24856

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #9084 "Fix appender code that might not initialize memory that might point at huge allocations" was merged into stable:

- 120e8195c93d6778fd99a143963bbdb1bb5872ec by Steven Schveighoffer:
  Fix bugzilla issue 24856 - Make sure appender doesn't leave some stale
  pointers in unallocated space, thereby pinning unused memory.

https://github.com/dlang/phobos/pull/9084

--