Thread overview
[Issue 18544] Thread-safety of "proto" GC before initialisation
Mar 18, 2021
rm
Mar 18, 2021
rm
Dec 17, 2022
Iain Buclaw
March 01, 2018
https://issues.dlang.org/show_bug.cgi?id=18544

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> ---
A thought on a potential fix: once you detect ranges being added/removed from independent threads, then you initialize the GC.

You should be able to do this with an atomic read, and then CAS to a ProtoGC instance variable that stores the "main thread" id.

The atomic read should be negligible compared to manipulating the roots/ranges arrays.

--
March 01, 2018
https://issues.dlang.org/show_bug.cgi?id=18544

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Hm.. actually that doesn't work, because one thread could be adding roots while the other one is initializing the GC, causing a race.

There may just have to be some sort of lock, even if it's a simple/spin lock.

--
March 18, 2021
https://issues.dlang.org/show_bug.cgi?id=18544

rm <rymrg@memail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rymrg@memail.com

--
March 18, 2021
https://issues.dlang.org/show_bug.cgi?id=18544

--- Comment #3 from rm <rymrg@memail.com> ---
Example program that makes use of addRoots before anything is allocated. The D following lib is called from multiple threads in C++.

```D
import std;
extern(C) {
   void cFunc( ){
      Foo foo;
      foo.inc;
   }
}

struct Foo{
   Array!int impl;
   void inc(){
       impl.insertBefore(impl[], 0);
   }
}
```

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=18544

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 07
https://issues.dlang.org/show_bug.cgi?id=18544

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17360

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--