F*cked by memory corruption after assiging value to associative array

tsbockman thomas.bockman at gmail.com
Thu Jan 28 19:22:16 UTC 2021


On Thursday, 28 January 2021 at 07:50:43 UTC, frame wrote:
> Under Linux everything is shared. Under Windows each DLL seems 
> to run in its own thread, has its own rt_options and do not see 
> any __gshared variable value. Its completely isolated and so I 
> assume that also GC is.

This stuff works correctly under Linux, and is quite broken in 
Windows. This has been known for years, but hasn't been fixed 
yet. This link for my other reply gives more details:
     
https://forum.dlang.org/post/veeksndchoppftlujrwl@forum.dlang.org

> Also https://wiki.dlang.org/Win32_DLLs_in_D says: Each EXE and 
> DLL will have their own gc instance.

They each have their own GC instance because no one has fully 
fixed the problems discussed at my link, above, not because it's 
actually a good idea for them each to have their own GC instance.

It is possible to get things sort of working with on Windows, 
anyway. But, this requires either:

A) Following all the same rules that you would need to follow if 
you wanted to share D GCed memory with another thread written in 
C. (Just adding GC roots is not enough.)

B) Ensuring that the GC proxy connections are properly 
established before doing anything else. This doesn't actually 
work correctly or reliably, but it might work well enough for 
your use case. Maybe.


More information about the Digitalmars-d-learn mailing list