https://bugs.winehq.org/show_bug.cgi?id=45333
--- Comment #6 from Anastasius Focht focht@gmx.net --- Hello Louis,
it seems the cause of crash is stack imbalance. I added a FIXME stub without message box:
--- snip --- $ WINEDEBUG=+seh,+relay wine "c:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update >>log.txt 2>&1 ... 0009:Call KERNEL32.__wine_kernel_init() ret=7bc6d4e4 ... 000f:Call KERNEL32.CreateProcessW(00000000,00023210 L"C:\windows\Microsoft.NET\Framework\v4.0.30319\mscorsvw.exe",00000000,00000000,00000000,00000400,00350000,00000000,0023fa90,0023fb00) ret=7fe15b09ee88 ... 0012:Call KERNEL32.__wine_kernel_init() ret=7bc6d4e4 000f:Ret KERNEL32.CreateProcessW() retval=00000001 ret=7fe15b09ee88 ... 0019:Call PE DLL (proc=0x790851d4,module=0x79060000 L"MSVCR100_CLR0400.dll",reason=THREAD_ATTACH,res=(nil)) ... 0019:Call KERNEL32.GetEnvironmentVariableW(0079fd54 L"COMPlus_NGENServiceBreakOnStart",00000000,00000000) ret=608fa946 0019:Ret KERNEL32.GetEnvironmentVariableW() retval=00000000 ret=608fa946 0019:Call advapi32.RegOpenKeyExW(80000001,608d8360 L"Software\Microsoft\.NETFramework",00000000,00020019,0079fe30) ret=608faa84 0019:Ret advapi32.RegOpenKeyExW() retval=00000002 ret=608faa84 0019:Call advapi32.RegOpenKeyExW(80000002,608d8360 L"Software\Microsoft\.NETFramework",00000000,00020019,0079fe0c) ret=608faafa 0019:Ret advapi32.RegOpenKeyExW() retval=00000000 ret=608faafa 0019:Call advapi32.RegQueryValueExW(0000005c,608d9f40 L"NGENServiceBreakOnStart",00000000,0079fe14,0079fe10,0079fe04) ret=608fab1f 0019:Ret advapi32.RegQueryValueExW() retval=00000002 ret=608fab1f 0019:Call advapi32.RegCloseKey(0000005c) ret=608fab30 0019:Ret advapi32.RegCloseKey() retval=00000000 ret=608fab30 0019:Call KERNEL32.GetModuleHandleW(608d1fa0 L"mscorsvc.dll") ret=608e0537 0019:Ret KERNEL32.GetModuleHandleW() retval=608d0000 ret=608e0537 0019:Call KERNEL32.GetModuleFileNameW(608d0000,0079fa00,00000104) ret=608e0554 0019:Ret KERNEL32.GetModuleFileNameW() retval=0000003a ret=608e0554 ... 0019:Call KERNEL32.LoadLibraryExW(608d44d8 L"mscoree.dll",00000000,00000000) ret=608fbf41 0019:Ret KERNEL32.LoadLibraryExW() retval=7e620000 ret=608fbf41 0019:Call KERNEL32.GetProcAddress(7e620000,608d44f0 "CorIsLatestSvc") ret=608e3bbd 0019:Ret KERNEL32.GetProcAddress() retval=7e62a174 ret=608e3bbd 0019:Call mscoree.CorIsLatestSvc() ret=608ed0cf 0019:fixme:mscoree:CorIsLatestSvc stub ! 0019:Ret mscoree.CorIsLatestSvc() retval=00000000 ret=608ed0cf 0019:trace:seh:raise_exception code=c0000005 flags=0 addr=(nil) ip=00000000 tid=0019 0019:trace:seh:raise_exception info[0]=00000008 0019:trace:seh:raise_exception info[1]=00000000 0019:trace:seh:raise_exception eax=0079fc38 ebx=00000000 ecx=0079fe74 edx=007a2f44 esi=1ca3cfcf edi=0079fc38 0019:trace:seh:raise_exception ebp=0079fe50 esp=0079fdfc cs=0023 ds=002b es=002b fs=0063 gs=006b flags=00010246 0019:trace:seh:call_stack_handlers calling handler at 0x6090b321 code=c0000005 flags=0 ... 0019:Call KERNEL32.GetLastError() ret=790703b8 0019:Ret KERNEL32.GetLastError() retval=00000000 ret=790703b8 0019:Call KERNEL32.GetLastError() ret=790703b8 0019:Ret KERNEL32.GetLastError() retval=00000000 ret=790703b8 0019:trace:seh:__regs_RtlUnwind code=c0000005 flags=2 0019:trace:seh:__regs_RtlUnwind eax=00000000 ebx=60913d04 ecx=60913d14 edx=00000000 esi=0079f920 edi=60913d5c 0019:trace:seh:__regs_RtlUnwind ebp=0079f7e4 esp=0079f7d0 eip=79084533 cs=0023 ds=002b fs=0063 gs=006b flags=00000246 0019:trace:seh:__regs_RtlUnwind calling handler at 0x7bc92dd5 code=c0000005 flags=2 0019:trace:seh:__regs_RtlUnwind handler at 0x7bc92dd5 returned 1 0019:Call KERNEL32.GetLastError() ret=790703b8 0019:Ret KERNEL32.GetLastError() retval=00000000 ret=790703b8 ... 0009:Ret KERNEL32.CreateFileW() retval=00000048 ret=10013e64 0009:Call KERNEL32.CreateFileW(0014c378 L"c:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.log",40000000,00000001,00000000,00000004,00000080,00000000) ret=100136a7 ... 0009:Call KERNEL32.GetLastError() ret=1000f417 0009:Ret KERNEL32.GetLastError() retval=000000b7 ret=1000f417 0009:Call KERNEL32.CloseHandle(00000048) ret=10013e9a 0009:Ret KERNEL32.CloseHandle() retval=00000001 ret=10013e9a 0009:Call KERNEL32.RaiseException(80000100,00000001,00000002,0033f9bc) ret=7efeb13a 0009:trace:seh:raise_exception code=80000100 flags=1 addr=0x7b446fe6 ip=7b446fe6 tid=0009 0009:trace:seh:raise_exception info[0]=7efeb160 0009:trace:seh:raise_exception info[1]=7efeb27d wine: Call from 0x7b446fe6 to unimplemented function mscoree.dll.CorGetSvc, aborting --- snip ---
'mscoree.CorIsLatestSvc()' is called on the NGEN service process side and causes an exception on return due to stack being 8 bytes off -> 2 integer args = return address 0. It gets caught within a SEH, letting the service not to crash. The NGEN service will exit with following message though:
--- snip --- 0019:err:eventlog:ReportEventW L".NET Runtime Optimization Service (clr_optimization_v4.0.30319_32) - Tried to start a service that wasn't the latest version of CLR Optimization service. Will shutdown\n" --- snip ---
This will not be seen by most users as they don't start apps from terminal and most don't pay attention at all to such kind of messages.
The client side 'ngen.exe' calls unimplemented 'mscoree.dll.CorGetSvc'. That one is actually documented:
https://github.com/dotnet/coreclr/blob/master/src/inc/mscorsvc.idl#L21
--- snip --- #pragma midl_echo("STDAPI CorGetSvc(IUnknown **pIUnknown);") --- snip ---
With a stub added, returning default 'CLR_E_SHIM_RUNTIMEEXPORT':
--- snip --- 0009:Call mscoree.CorGetSvc(0033f9f8) ret=1000df20 0009:fixme:mscoree:CorGetSvc stub(0x33f9f8)! 0009:Ret mscoree.CorGetSvc() retval=80131701 ret=1000df20 0009:Call KERNEL32.GetLastError() ret=1000f4c7 0009:Ret KERNEL32.GetLastError() retval=000000b7 ret=1000f4c7 ... 0009:Call KERNEL32.GetLastError() ret=1000f417 0009:Ret KERNEL32.GetLastError() retval=000000b7 ret=1000f417 ... 0009:Call KERNEL32.RaiseException(e06d7363,00000001,00000003,0033f9a4) ret=79084c0f 0009:trace:seh:raise_exception code=e06d7363 flags=1 addr=0x7b446fe6 ip=7b446fe6 tid=0009 0009:trace:seh:raise_exception info[0]=19930520 0009:trace:seh:raise_exception info[1]=0033f9e4 0009:trace:seh:raise_exception info[2]=1001a760 0009:trace:seh:raise_exception eax=7b4356b1 ebx=00000000 ecx=00000000 edx=0033f990 esi=0033f990 edi=0033f950 0009:trace:seh:raise_exception ebp=0033f928 esp=0033f8c4 cs=330023 ds=33002b es=f7bc002b fs=f7bc0063 gs=f7bc006b flags=00000212 0009:trace:seh:call_stack_handlers calling handler at 0x10018276 code=e06d7363 flags=1 ... Failed to find a required export in the runtime. (Exception from HRESULT: 0x80131701) ... --- snip ---
I'm not sure if it's really wise to put a message box to an API which is called from within a service process. It might be better to add the message box to 'mscoree.dll.CorGetSvc()' which is called by the client side.
--- snip --- $ wine "c:\windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update 0009:fixme:mscoree:CorGetSvc stub(0x33f9f8)! Failed to find a required export in the runtime. (Exception from HRESULT: 0x80131701) --- snip ---
The NGEN client will change the 32-bit and 64-bit NGEN service start type to 'manual start' after encountering this problem once. The service(s) will not be started any more by design.
--- snip --- [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\clr_optimization_v4.0.30319_32] "DelayedAutostart"=dword:00000001 "Description"="Microsoft .NET Framework NGEN" "DisplayName"="Microsoft .NET Framework NGEN v4.0.30319_X86" "ErrorControl"=dword:00000000 "FailureActions"=hex:84,03,00,00,00,00,00,00,00,00,00,00,03,00,00,00,f9,31,0f,\ 70,01,00,00,00,c0,d4,01,00,01,00,00,00,e0,93,04,00,00,00,00,00,00,00,00,00 "ImagePath"="C:\windows\Microsoft.NET\Framework\v4.0.30319\mscorsvw.exe" "ObjectName"="LocalSystem" "PreshutdownTimeout"=dword:0002bf20 "RequiredPrivileges"=hex(7):... "Start"=dword:00000003 "Type"=dword:00000010 "WOW64"=dword:00000001
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\clr_optimization_v4.0.30319_64] "DelayedAutostart"=dword:00000001 "Description"="Microsoft .NET Framework NGEN" "DisplayName"="Microsoft .NET Framework NGEN v4.0.30319_X64" "ErrorControl"=dword:00000000 "FailureActions"=hex:84,03,00,00,00,00,00,00,00,00,00,00,03,00,00,00,f9,31,0f,\ 70,01,00,00,00,c0,d4,01,00,01,00,00,00,e0,93,04,00,00,00,00,00,00,00,00,00 "ImagePath"="C:\windows\Microsoft.NET\Framework64\v4.0.30319\mscorsvw.exe" "ObjectName"="LocalSystem" "PreshutdownTimeout"=dword:0002bf20 "RequiredPrivileges"=hex(7):... "Start"=dword:00000003 "Type"=dword:00000010 "WOW64"=dword:00000001 --- snip ---
Regards