Why filling AA in shared library freezes execution?

Adam D. Ruppe destructionator at gmail.com
Wed Jan 27 14:36:16 UTC 2021


On Wednesday, 27 January 2021 at 13:39:32 UTC, SealabJaster wrote:
> The biggest one for me, is that RTTI isn't "shared" across 
> boundaries.

Yeah, that's a big one. Exception handling tables are also not 
properly merged leading to random behavior even if you do manage 
to catch the exception (I wrote a PR for that but it isn't 
theoretically sound https://github.com/dlang/druntime/pull/2874# 
), the GC proxy is done wrong - but there might be a chance to 
fix that - and there's a bug with static data not being scanned. 
Possibly related to the GC proxy, not sure.

It is all related to the same root problem - on Windows, unlike 
Linux, symbols are not automatically merged. More info

http://dconf.org/2016/talks/thaut.html

Yes, from 2016. And a branch aiming to fix it: 
https://github.com/ingrater/dmd/tree/DllSupportD


So what happens is if you have a global variable in the dll and 
exe, each one has their own copy of it. So typeid are not merged, 
GC meta is not merged. druntime tries to hack around this but it 
doesn't do a good job.

But then in user libs the same thing happens and they almost 
never make any attempt to handle it, so if you using other stuff, 
there be dragons. It might be perfectly fine, separate copies of 
data is often not fatal at all. But if they expect sharing - you 
can get separate singletons and such - you're in some trouble.

Technically what dmd does for dlls isn't wrong. That is the way 
the underlying operating system works. But since it is more 
useful to handle these things and the Microsoft C++ compilers 
paper over this with auto-generated indirection, even Windows 
programmers might not realize it and it just seems completely 
broken.

(btw as for me fixing it myself, there's a number of subtleties 
that I don't even know. Maybe i could figure them out but the 
fact is it is prolly gonna be a buggy transition. But the most 
discouraging part is seeing all that talk and code from 2016 just 
sitting there, ignored. What's the point of even trying if it is 
just going to rot again.)


More information about the Digitalmars-d-learn mailing list