On Friday, 28 July 2023 at 11:15:31 UTC, Steven Schveighoffer wrote:
All `__gshared` does is give you storage that is accessible from all threads,

"All __gshared does is give you [a live bomb, ready to go off at any moment]"
!!

On Friday, 28 July 2023 at 14:10:16 UTC, Kagamin wrote:
Your error is using allocating the object with malloc. Since gc doesn't see your AA, the AA is freed and you get UAF.

Friend, I think you nailed it. After adding this I haven't been able to reproduce the segfault again:
```d
this(long n){
        (){
                cache = new typeof(cache);
                assert(cache);
                import core.memory;
                core.memory.GC.addRoot(cast(void*)cache);
        }();
        // ...
```
It did always happen at random, so perhaps I haven't spent enough time testing it yet, but I've gone far longer without it segfaulting than ever before.

Reply via email to