Re: [Mono-list] mscoree.dll crash

2009-05-01 Thread Kornél Pál
Hi,

MSVCRT is calling CorExitProcess on exit if mscoree.dll is loaded. 
mono.dll is hooking some mscoree.dll exports (including CorExitProcess) 
to itself but is not removing these hooks on unload.

I suggest you to keep an extra reference to mono.dll so that it will not 
be unloaded until process termination.

This is a bug that should definitely be fixed but I will need some time 
to come up with an optimal solution.

Kornél

fozzie wrote:
 The problem occurs when a separate DLL is pulled into the central executable
 via LoadLibrary(). On shutdown of the executable the DLL is freed via
 FreeLibrary() and this results in unload of mono.dll, which changes the
 mscoree.dll address space.
 
 The debug work directory should be set to $(OutDir) or mscorlib.dll will not
 be found. There is a breakpoint immediately after mono_jit_init_version() to
 allow examination of the address of CorExitProcess. 
 
 The lib and etc directories from the Mono 2.4 install should be copied below
 bin\mono\. 
 
 The following are copied from the install directories to the bin\debug
 directory. They aren't big so i kept them in the zip:
 libglib-2.0-0.dll
 libgmodule-2.0-0.dll
 libgthread-2.0-0.dll
 
 I tried uploading the file in both Chrome and IE 8, but it doesn't seem to
 work so i've stuck it at
 http://rapidshare.com/files/226924363/mscoree_crash.zip.html. Hopefully it
 helps to track this down.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] mscoree.dll crash

2009-04-28 Thread fozzie

hi all..

I'm running Mono 2.4 on Vista 32-bit using the windows debug build with MSVC
2008.

Immediately after calling mono_jit_init_version() the MSVC 2008 output
window shows loading of mscoree.dll and mscorlib.dll. On terminating the
application, the __crtExitProcess() detects that mscoree is loaded in memory
and decides to GetProcAddress(CorExitProcess). This address remains the
same since initial load of mscorlib.dll, but at the time of the crash the
memory pointed to is garbage. I'm about to get into it with windbg, but
thought someone else might have had a similar experience. I suspect the
libraries are injected into the process since i haven't found a dependency
on them in the mono libs. 

thanks!
-- 
View this message in context: 
http://www.nabble.com/mscoree.dll-crash-tp23271960p23271960.html
Sent from the Mono - General mailing list archive at Nabble.com.

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mscoree.dll crash

2009-04-28 Thread fozzie

On application shutdown, FreeLibrary() is called to unload the DLL which
calls mono_jit_init_version(). The debugger shows that the final
NtUnmapViewOfSection() during the FreeLibrary() processing causes unload of
mono.dll and trashing of the mscoree.dll memory area holding the executable
instructions for CorExitProcess(). But mscoree.dll is not unloaded for some
reason so a crash occurs later when the CRT shuts down. Still digging..
-- 
View this message in context: 
http://www.nabble.com/mscoree.dll-crash-tp23271960p23283664.html
Sent from the Mono - General mailing list archive at Nabble.com.

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mscoree.dll crash

2009-04-28 Thread Kornél Pál
Could you please provide a test project (source and executable) that 
causes this crash?

Thanks.

Kornél

fozzie wrote:
 On application shutdown, FreeLibrary() is called to unload the DLL which
 calls mono_jit_init_version(). The debugger shows that the final
 NtUnmapViewOfSection() during the FreeLibrary() processing causes unload of
 mono.dll and trashing of the mscoree.dll memory area holding the executable
 instructions for CorExitProcess(). But mscoree.dll is not unloaded for some
 reason so a crash occurs later when the CRT shuts down. Still digging..
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mscoree.dll crash

2009-04-28 Thread Kornél Pál
Hi,

I've written the things in coree.c and it is hooking exported functions 
in mscoree.dll to functions in mono.dll. This may cause the crash you 
have described but I need a test case to fix that.

Kornél

fozzie wrote:
 Unfortunately the source in question is proprietary, but i'll try to create a
 smaller sample to reproduce the crash. For some reason, the sample teste
 project does not. It looks like coree.c is doing a fair bit of lifetime
 management :).
 
 I'm using source checked out via 
 svn co svn://anonsvn.mono-project.com/source/branches/mono-2-4/mono
 with the standard Mono 2.4 install on Windows Vista 32-bit. Perhaps i'm
 missing some patches?
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mscoree.dll crash

2009-04-28 Thread fozzie

The problem occurs when a separate DLL is pulled into the central executable
via LoadLibrary(). On shutdown of the executable the DLL is freed via
FreeLibrary() and this results in unload of mono.dll, which changes the
mscoree.dll address space.

The debug work directory should be set to $(OutDir) or mscorlib.dll will not
be found. There is a breakpoint immediately after mono_jit_init_version() to
allow examination of the address of CorExitProcess. 

The lib and etc directories from the Mono 2.4 install should be copied below
bin\mono\. 

The following are copied from the install directories to the bin\debug
directory. They aren't big so i kept them in the zip:
libglib-2.0-0.dll
libgmodule-2.0-0.dll
libgthread-2.0-0.dll

I tried uploading the file in both Chrome and IE 8, but it doesn't seem to
work so i've stuck it at
http://rapidshare.com/files/226924363/mscoree_crash.zip.html. Hopefully it
helps to track this down.
-- 
View this message in context: 
http://www.nabble.com/mscoree.dll-crash-tp23271960p23288309.html
Sent from the Mono - General mailing list archive at Nabble.com.

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list