Thread overview
[Issue 24331] @nogc and GC.disable() are often confused
Jan 12
Dlang Bot
Jan 12
Dlang Bot
Jan 12
Dlang Bot
Jan 12
Dlang Bot
January 11
https://issues.dlang.org/show_bug.cgi?id=24331

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
Sounds like better documentation is needed for both @nogc and GC.disable().

--
January 11
https://issues.dlang.org/show_bug.cgi?id=24331

timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch

--- Comment #2 from timon.gehr@gmx.ch ---
(In reply to Walter Bright from comment #1)
> Sounds like better documentation is needed for both @nogc and GC.disable().

Well, currently, the spec states:

How Garbage Collection Works
-----------------------------
The GC works by:

- Stopping all other threads than the thread currently trying to allocate GC
memory.
- ‘Hijacking’ the current thread for GC work.
- Scanning all ‘root’ memory ranges for pointers into GC allocated memory.
- Recursively scanning all allocated memory pointed to by roots looking for
more pointers into GC allocated memory.
- Freeing all GC allocated memory that has no active pointers to it and do not
need destructors to run.
- Queueing all unreachable memory that needs destructors to run.
- Resuming all other threads.
- Running destructors for all queued memory.
- Freeing any remaining unreachable memory.
- Returning the current thread to whatever work it was doing.

https://dlang.org/spec/garbage.html

So what people are relying on is currently indeed specified behavior. This can of course be changed, but I do not think we can fault users for relying on this documented behavior of the GC.

--
January 12
https://issues.dlang.org/show_bug.cgi?id=24331

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry
           Hardware|x86                         |All
                 OS|Windows                     |All

--
January 12
https://issues.dlang.org/show_bug.cgi?id=24331

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

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

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dlang.org pull request #3756 "fix Issue 24331 - @nogc and GC.disable() are often confused" fixing this issue:

- fix Issue 24331 - @nogc and GC.disable() are often confused

https://github.com/dlang/dlang.org/pull/3756

--
January 12
https://issues.dlang.org/show_bug.cgi?id=24331

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #16023 "fix Issue 24331 - @nogc and GC.disable() are often confused" fixing this issue:

- fix Issue 24331 - @nogc and GC.disable() are often confused

https://github.com/dlang/dmd/pull/16023

--
January 12
https://issues.dlang.org/show_bug.cgi?id=24331

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

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

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dlang.org pull request #3756 "fix Issue 24331 - @nogc and GC.disable() are often confused" was merged into master:

- 5c56620fa0fbfc2db75e681751abbd5f85758cb1 by Walter Bright:
  fix Issue 24331 - @nogc and GC.disable() are often confused

https://github.com/dlang/dlang.org/pull/3756

--
January 12
https://issues.dlang.org/show_bug.cgi?id=24331

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #16023 "fix Issue 24331 - @nogc and GC.disable() are often confused" was merged into master:

- e04af29b775a42417d43081fdc905021766b6bb4 by Walter Bright:
  fix Issue 24331 - @nogc and GC.disable() are often confused

https://github.com/dlang/dmd/pull/16023

--