On Monday, 25 January 2021 at 11:15:28 UTC, frame wrote:
After a while my program crashes.
I'm inspecting in the debugger that some strings are
overwritten after a struct is assigned to an associative array.
- I have disabled the GC.
- All happens in the same thread.
- The strings belong to an object collection inside an object
created from a d-DLL.
- The object returned by the DLL function is added to the GC
with GC.addRoot().
- This object also lives in a static array the whole time.
- Not all objects are affected but many.
- The struct itself looks okay also the key for the associative
array has normal form.
The data is not overwritten by another Thread (only one is
running) but by the compiler. I'm watching it by memory
location. It gets always visible first after that assignment.
But how is this even possible? In theory, how could I ran into
this issue?
That should really not be possible.
I suspect the memory used by the original data got reused for the
associative array somehow. But if the GC is off from program
start, that should really not occur. Do you maybe turn the GC off
before the AA assignment, but after it's already marked that
memory freed? Try turning it off completely from the commandline
with --DRT-gcopt=gc:manual