Não tenho certeza se essa pergunta deve ser postada aqui ou melhor no StackOverflow.com, mas vamos tentar aqui primeiro.
A configuração é um servidor Windows 2008 R2 64bit executando um site ASP.NET 2.0. O projeto é implantado na forma de uma compilação de depuração já e criado para "Qualquer CPU". Está fazendo uso de métodos externos (veja abaixo) e também inicia processos de terceiros para realizar certas tarefas.
Os servidores travam com freqüência sem mostrar nenhum rastreamento de pilha gerenciado. O processo de trabalho do IIS7 simplesmente morre. Eu não posso fixá-lo em uma ação específica que poderia causar isso. Configurar contadores de desempenho não mostrou nada de estranho. Os servidores são 64bit Win 2008 R2. Meu melhor palpite é que as falhas são causadas por um dos métodos externos usados no código. Alguém pode fazer sentido a partir da saída do depurador e os métodos listados aqui? Existe uma maneira de ver se um dos métodos abaixo é responsável pelo acidente? Eu não tenho experiência em inspecionar despejos de memória, então espero obter alguma ajuda ou inspiração aqui.
O depurador mostra na seção "Fields" algo que me parece um monte de parâmetros sendo colocados na pilha. Eu estou querendo saber se isso se relaciona com um dos métodos abaixo?
Alguma outra ideia de como proceder e o que tentar?
Suspeito que as falhas são causadas por uma destas chamadas:
[DllImport( "urlmon.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false )]
static extern int FindMimeFromData( IntPtr pBC,
[MarshalAs( UnmanagedType.LPWStr )] string pwzUrl,
[MarshalAs( UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1, SizeParamIndex = 3 )]
byte[] pBuffer,
int cbSize,
[MarshalAs( UnmanagedType.LPWStr )] string pwzMimeProposed,
int dwMimeFlags,
out IntPtr ppwzMimeOut,
int dwReserved );
[DllImport( "advapi32.dll", SetLastError = true )]
private static extern int LogonUser( string lpszUserName,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken );
[DllImport( "advapi32.dll", CharSet = CharSet.Auto, SetLastError = true )]
private static extern int DuplicateToken( IntPtr hToken,
int impersonationLevel,
ref IntPtr hNewToken );
[DllImport( "advapi32.dll", CharSet = CharSet.Auto, SetLastError = true )]
private static extern bool RevertToSelf();
[DllImport( "kernel32.dll", CharSet = CharSet.Auto )]
private static extern bool CloseHandle( IntPtr handle );
[DllImport("kernel32.dll")]
private static extern bool SetProcessWorkingSetSize (IntPtr oProc, int iMin, int iMax);
[DllImport( "query.dll", SetLastError = true, CharSet = CharSet.Unicode )]
static extern int LoadIFilter( string pwcsPath, [MarshalAs( UnmanagedType.IUnknown )] object pUnkOuter, ref IFilter ppIUnk );
[DllImport( "query.dll", SetLastError = true, CharSet = CharSet.Unicode )]
static extern int BindIFilterFromStream( Stream pStm, [MarshalAs( UnmanagedType.IUnknown )] object pUnkOuter, ref IFilter ppIUnk );
[ComImport, Guid( "89BCB740-6119-101A-BCB7-00DD010655AF" )]
[InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
private interface IFilter
{
[DllImport(@"CMCOnBehalf_dll.dll", SetLastError = true,
CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern int DoEnrollForMe(
string sUserId,
string sPFXPwd,
string strSysPwd,
string sCAConfigName,
string wszCATemplateName,
string sCertSubjectName,
string sCertFileName,
string strAltEmail,
string strAltPrincipal
);
// Late-binding...
[DllImport(@"CMCOnBehalf_dll.dll", SetLastError = true,
CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern int DoRenewForMe(
string sUserId,
string sPFXPwd,
string strSysPwd,
string sCAConfigName,
string wszCATemplateName,
string sInputSerial,
string strInputSubject,
string sCertFileName,
string strAltEmail,
string strAltPrincipal,
ref string wszOutputSerial
);
// Late-binding...
[DllImport(@"CMCOnBehalf_dll.dll", SetLastError = true,
CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern int DoRevokeForMe(
string sSerialID,
string sCAConfigName
);
// Late-binding...
[DllImport(@"CMCOnBehalf_dll.dll", SetLastError=true,
CharSet = CharSet.Auto, CallingConvention=CallingConvention.StdCall
)]
public static extern int SetLogLevelForBlogger(
string logFile,
int cbLogLevel
);
Esta é a informação que recebo do WinDbg e dos despejos de memória:
MANAGED_OBJECT: !dumpobj 1a1583c80
Name: System.String
MethodTable: 000007fef9127ca0
EEClass: 000007fef8d2e550
Size: 2296(0x8f8) bytes
GC Generation: 0
(C:\Windows\assembly\GAC_64\mscorlib.0.0.0__b77a5c561934e089\mscorlib.dll)
String: at System.Web.Hosting.UnsafeIISMethods.MgdIsLastNotification(IntPtr pRequestContext, RequestNotificationStatus dwStatus)
at System.Web.HttpRuntime.FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, RequestNotificationStatus& status)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
Fields:
MT Field Offset Type VT Attr Value Name
000007fef912ef10 4000096 8 System.Int32 1 instance 1136 m_arrayLength
000007fef912ef10 4000097 c System.Int32 1 instance 1135 m_stringLength
000007fef91296e8 4000098 10 System.Char 1 instance 20 m_firstChar
000007fef9127ca0 4000099 20 System.String 0 shared static Empty
>> Domain:Value 00000000002d1980:00000001bf690370 0000000001ab43f0:00000001bf690370 <<
000007fef9129598 400009a 28 System.Char[] 0 shared static WhitespaceChars
>> Domain:Value 00000000002d1980:00000001bf690b60 0000000001ab43f0:00000001df690390 <<
EXCEPTION_MESSAGE: Attempted to read or write protected memory. This is often an indication that other memory is corru
MANAGED_OBJECT_NAME: SYSTEM.ACCESSVIOLATIONEXCEPTION
MANAGED_STACK_COMMAND: ** Check field _remoteStackTraceString **;!do 1002be1e8;!do 1a1583c80
LAST_CONTROL_TRANSFER: from 000007fef9d99413 to 000007fefd4fcacd
PRIMARY_PROBLEM_CLASS: WRONG_SYMBOLS
BUGCHECK_STR: APPLICATION_FAULT_WRONG_SYMBOLS_CLR_EXCEPTION
STACK_TEXT:
00000000'00000000 00000000'00000000 unknown!System.Web.Hosting.UnsafeIISMethods.MgdIsLastNotification+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.HttpRuntime.FinishRequestNotification+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.HttpRuntime.ProcessRequestNotificationPrivate+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper+0x0
00000000'00000000 00000000'00000000 unknown!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification+0x0
0:048> !aspxpages
Going to dump the HttpContexts found in the heap.
Loading the heap objects into our cache.
HttpContext Timeout Completed Running ThreadId ReturnCode Verb RequestPath+QueryString
0x0000000100233f88 11647 Sec no 14 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x0000000100292250 36000 Sec no 7 Sec XXX 200 GET /systools/lbchecker.aspx
0x0000000160286d10 36000 Sec no 14 Sec XXX 200 GET /fs/getcustomerfile.aspx sconfigvalue=1%3a%3a2%3a%3a-1%3a%3a-1%3a%3av8.20-login-image.png&iheight=320&iwidth=-1&h=0e9784b59a8712a7518401629a908709b32f724f8b7c831ba045743a81a5fef0
0x0000000160293a30 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x00000001602ae740 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x00000001602c9450 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x00000001602e4160 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x00000001602fee70 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x0000000160319b80 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x0000000160334890 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x000000016034f5a0 11647 Sec no 13 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x000000016036a378 11647 Sec no 13 Sec 50 200 POST /testwebservice/v3/services.svc/IHome
0x000000018f6e4818 36000 Sec no 68676 Sec XXX 200 GET /systools/lbchecker.aspx
0x00000001903a2fc8 36000 Sec no 14 Sec XXX 200 GET /default.aspx cookieCheck=true
0x00000001904496c8 36000 Sec no 14 Sec XXX 200 POST /testadminservice/testadminservice.asmx
0x00000001b040efd8 36000 Sec no 26 Sec XXX 200 GET /newdr/drcontent.aspx intID=5538807
0x00000001b0435b60 36000 Sec no 5 Sec XXX 200 GET /systools/lbchecker.aspx
0x00000001c0383688 36000 Sec no 25 Sec XXX 200 GET /newdr/drcontent.aspx intID=5538807
0x00000001c0732f50 36000 Sec no 9 Sec XXX 200 POST /testadminservice/testadminservice.asmx/SystemTest
0x00000001d0661a60 11647 Sec no 14 Sec XXX 200 POST /testwebservice/v3/services.svc/IHome
0x00000001e051dd68 36000 Sec no 8 Sec XXX 200 GET /systools/lbchecker.aspx
0x00000001f0e03ff0 36000 Sec no 5 Sec XXX 200 GET /systools/lbchecker.aspx
Total 22 HttpContext objects