Program crash: GC destroys an object unexpectedly

eugene dee0xeed at gmail.com
Sun Sep 19 20:12:45 UTC 2021


On Monday, 13 September 2021 at 17:54:43 UTC, eugene wrote:
> full src is here
> http://zed.karelia.ru/0/e/edsm-in-d-2021-09-10.tar.gz

I've also made two simple examples, just in case

- http://zed.karelia.ru/0/e/edsm-in-d-simple-example-1.tar.gz
Program does nothing, just waits for ^c, does not crash upon 
SIGINT.

Now, let's put some pressure on garbage collector
- http://zed.karelia.ru/0/e/edsm-in-d-simple-example-2.tar.gz

Every 10 ms do some allocations:

```d
     void mainIdleEnter() {
         tm0.enable();
         tm0.heartBeat(10); // milliseconds
     }

     void mainIdleT0(StageMachine src, Object o) {
         int[] a;
         foreach (k; 0 .. 1000) {
             a ~= k;
         }
     }
```
After 3 seconds from the start destructors are called

edsm-in-d-simple-example-2 $ ./test | grep owner
    !!! esrc.EventSource.~this() : esrc.Signal (owner STOPPER, fd 
= 5) this @ 0x7fa267872150
    !!! esrc.EventSource.~this() : esrc.Signal (owner STOPPER, fd 
= 6) this @ 0x7fa267872180

After this happens, pressing ^C results in segfault.


More information about the Digitalmars-d-learn mailing list