2

I have a MVC4 application, which loads some DLLs. Basically, the architecture of the MVC application is this: the app receives some jobs from the user, it calls the processing functions from dlls and in the end, emails the results to the user.

All dlls are compiled on 64bits, I use IIS8 on 64 bits, on Windows Server 2012R2 and VS2013. When I run/deploy the application, its behaviour is:

  • Scenario1: Run from Visual Studio 2013 in VS2013 included web server (IIS Express) in Debug/Release Mode => works fine
  • Scenario2: Run from Visual Studio 2013 deployed in local full IIS8 in Release Mode => works fine
  • Scenario3: Deployed in Release Mode in local full IIS8 and run directly from browser, without having open VS2013 => IIS crashes with An unhandled win32 exception occurred in w3wp.exe.The Just-ln-Time debugger was launched without necessary security permissions. To debug this process, the Just-ln-Time debugger must be run as an Administrator. When I open the debugger, the error is: A heap has been corrupted.

In event viewer, the logs are:

Faulting application name: w3wp.exe, version: 8.5.9600.16384, time     stamp: 0x5215df96
Faulting module name: ntdll.dll, version: 6.3.9600.18821, time stamp: 0x59ba86db
Exception code: 0xc0000374

I know that exception code 0xc0000374 comes from Heap corruption.

I debugged IIS using DebugDiag and Application Verifier, with Full PageHeap flags activated. The relevant part of the stack for the crashing thread is:

.NET Call Stack
mscorlib_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr)+68 
[[InlinedCallFrame] (Microsoft.Win32.Win32Native.LocalFree)] Microsoft.Win32.Win32Native.LocalFree(IntPtr) 
mscorlib_ni!System.Runtime.InteropServices.Marshal.FreeHGlobal(IntPtr)+2d 
Species_DLL.Class1.Species_MetaModel()+b955 
rIAMTestMVC4.Impressions.SpeciesUtil.use_Species_Integrated(Int32)+1efd 


Full Call Stack

vrfcore!VerifierStopMessageEx+6f4 
vrfcore!VfCoreRedirectedStopMessage+90 
verifier!VerifierStopMessage+a0 
verifier!AVrfpDphReportCorruptedBlock+2a7 
verifier!AVrfpDphCheckNormalHeapBlock+c8 
verifier!AVrfpDphNormalHeapFree+27 
verifier!AVrfDebugPageHeapFree+af 
ntdll!RtlDebugFreeHeap+47 
ntdll!RtlpFreeHeap+74c85 
ntdll!RtlFreeHeap+368 
vrfcore!VfCoreRtlFreeHeap+1e 
KERNELBASE!LocalFree+2e 
mscorlib_ni!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr)+68 
[[InlinedCallFrame] (Microsoft.Win32.Win32Native.LocalFree)] Microsoft.Win32.Win32Native.LocalFree(IntPtr) 
mscorlib_ni!System.Runtime.InteropServices.Marshal.FreeHGlobal(IntPtr)+2d 
Species_DLL.Class1.Species_MetaModel()+b955 
rIAMTestMVC4.Impressions.SpeciesUtil.use_Species_Integrated(Int32)+1efd 

Are there any differences between Scenario2 and Scenario3? Is there any heap protection that is done by VS?

I also run the same scenarios on Windows7 with IIS7 and works fine on all three.

I don't have access to DLL code, but as I mentioned, the same code runs perfectly on IIS7/Windows7 and on IIS8 from Visual Studio.

LE: There are two functions shown in call stack:

  • rIAMTestMVC4.Impressions.SpeciesUtil.use_Species_Integrated => This function is from MVC controller, which calls one dll
  • Species_DLL.Class1.Species_MetaModel => This function is from dll, called by previous function.

How can I resolve the problem of scenario3? What are the differences between these scenarios?

Thank you,

banuj
  • 3,080
  • 28
  • 34

2 Answers2

0

I had similar issues but i resolved mine by changing the project build to x86 to compensate for 32 bits.

Ifesinachi Bryan
  • 2,240
  • 1
  • 19
  • 20
  • Thank you for your response. This is not a solution for me, because all dlls are on 64 bits. – banuj Dec 18 '17 at 20:22
0

Did you run VS2013 as an administrator? if so, then this is what prevented the error from happening with VS, and happens with IIS only.

It looks like the IIS application pool is having a problem reaching those DLLs, and this problem didn't occur with VS2013.

Update: Just add the permission to the pool itself to access the folder:

  1. Select the folder that has your DLLs Right click and select "Properties"
  2. Select the "Security" tab Click the "Edit" and then "Add" button
  3. Click the "Locations" button and make sure you select the local machine. (Not the Windows domain if the server belongs to one.)
  4. Enter IIS AppPool\DefaultAppPool in the "Enter the object names to select:" text box. (Don't forget to change "DefaultAppPool" here to whatever you named your application pool.)

note: steps are copied with some changes from here.


To know or change the application pool that runs your application: when you open IIS manager and select your application from the tree on the left, find it in Advanced Settings down the Actions Pane on your right.

To change the identity of the pool , you'll find them under the machine in the tree on your left.

Check this article on how to specify the identity of the application pool.

Majid ALSarra
  • 394
  • 2
  • 7
  • Thank you for your response, Yes, I run VS2013 as an Administrator. How can I run the application pool as Administrator? Right now, in Advanced Settings -> Identity I have only LocalSystem, LocalService, NetworkService & ApplicationPoolIdentity. I tried all of them, but none is working. – banuj Dec 18 '17 at 19:29
  • I just updated my answer, you do not need this, just give the permission to the pool as specified. the pool can be dealt with as a user. – Majid ALSarra Dec 19 '17 at 03:04