F*cked by memory corruption after assiging value to associative array
frame
frame86 at live.com
Tue Jan 26 14:31:58 UTC 2021
On Monday, 25 January 2021 at 17:11:37 UTC, frame wrote:
> Wrong way?
Please, someone correct me if I'm getting this wrong:
Structure:
EXE/Main Thread:
- GC: manual
- requests DLL 1 object A
- GC knows about object A
DLL/Thread 1:
- GC: conservative
- allocates new object A -> addRoot(object A), return to EXE (out
param)
- requests DLL 2 object B
- GC knows about object A and object B
- requests sub objects of object B later
DLL/Thread 2:
- GC: manual
- allocates new object B -> addRoot(object B), return to DLL 1
(out param)
- GC knows about object B
- allocates sub objects over object B when DLL 1 requests it,
return to DLL 1 (out param)
- sub objects are stored in object B
- object B sub objects memory gets corrupted after DLL 1 becomes
active thread again
In this scenario only DLL 1 can cause the corruption as it does
not occur if all GCs are set to manual.
At this point I am confused about how memory allocation is
ensured. Each thread should have assigned its own memory area.
Each GC adopts the root by the returned object and knows about
that area too. But if DLL 1 becomes active it writes into sub
memory of DLL 2. It only can because it has adopted the root of
object B - but why does not see DLL 1 then that sub objects of B
are still alive?
More information about the Digitalmars-d-learn
mailing list