[Mono-dev] Mono 2.0 (arm): Reverse PInvoke can cause memory corruption?

Zoltan Varga vargaz at gmail.com
Fri Oct 10 15:41:22 EDT 2008


Hi,

  The GC only stops threads registered with it. This can be done multiple ways:
- all threads started by the runtime are automatically registered.
- an embedding app can register its threads by calling the
mono_thread_attach () API
  function.
- a non-registered thread is automatically registered the first time
it calls into managed
  code.

The third way is the easiest for applications, but it might have race
condition: if a GC
happens inside the call, I'm not sure what happens.

                 Zoltan

2008/10/10 FirstName LastName <mousse_man at hotmail.com>:
> Hi,
>
> Recently, I asked about doing reverse pinvoke from a native thread that
> caused an assert in mini-arm.c.
>
> A fix was done and I'm able to do it.  But know, I have a feeling that I
> have memory corruption.  My application is crashing at different times
>
> and display different stack traces.
>
> I have a general question regarding GC.  When the GC runs, does it stop all
> threads in the process, even those created in unmanaged.
>
> I asking the following because I'm wondering what would happen if the GC
> collects and at the same time, a reverse pinvoke is done from a native
> thread (back to managed code)?
>
> Can this be an issue?
>
>
>
> ________________________________
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>


More information about the Mono-devel-list mailing list