[Mono-list] gc handles not thread safe?
chris at ochsnet.com
Thu Oct 17 02:56:50 UTC 2013
I'm embedding mono in a java app and when using gchandles it's obvious that
memory is getting stomped on somehow. When I don't use gc handles, or just
use gc handles within a single thread, everything is fine.
The same gc handle is never accessed concurrently from different threads,
although I do pass them around to different threads.
Reading/writing memory streams triggers the problem regularly, it usually
segfaults in BlockCopy with various errors about the stream not containing
the expected data, or sometimes division by zero.
I'm fairly sure the code that handles threading is not at fault, I'm using
Akka which has a well established concurrency model I don't explicitly
create any threads myself.
FYI I see this in mono 2 and the latest mono 3 from master.
Is there another technique I can use to keep a MonoObject around and keep
the gc from collecting it without using gc handles? I was thinking of
just having a thread safe dictionary in C# that keeps references to these
objects, and just make all my calls into managed code via static methods
that can get the object and call methods on it in C#.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list