gpt4 book ai didi

c# - 如何禁用 Web 服务器中的 Visual C++ 运行时错误?

转载 作者:太空宇宙 更新时间:2023-11-03 11:13:37 25 4
gpt4 key购买 nike

在 Windows Server 2003 计算机上运行 WCF 的生产 Web 服务没有响应。我在 DebugDiag 1.2 中捕获了一个内存转储文件用于分析.

DebugDiag 显示线程遇到了 OutOfMemoryException。通常,我们会 try catch 所有异常,将它们打印到事件日志中,然后将它们作为 WCF 错误返回。

此 OutOfMemoryException 以某种方式未被捕获并导致 C++ 错误。我承认 .NET 运行时无法处理此错误。当你失忆时,你就失忆了。

分析显示其中一个线程试图显示 Visual C++ 运行时错误:

Microsoft Visual C++ Runtime Library Runtime Error! Program: C:\windows\system32\inetsrv".

堆栈跟踪看起来像这样:

ntdll!KiFastSystemCallRet    
ntdll!ZwRaiseHardError+c
user32!ServiceMessageBox+145
user32!MessageBoxWorker+13e
user32!MessageBoxTimeoutW+7a
user32!MessageBoxTimeoutA+9c
user32!MessageBoxExA+1b
user32!MessageBoxA+45
msvcr71!__crtMessageBoxA+f4 f:\vs70builds\3052\vc\crtbld\crt\src\crtmbox.c @ 118 + 10
msvcr71!_NMSG_WRITE+12e f:\vs70builds\3052\vc\crtbld\crt\src\crt0msg.c @ 240 + 10
msvcr71!abort+7 f:\vs70builds\3052\vc\crtbld\crt\src\abort.c @ 48
kernel32!UnhandledExceptionFilter+12a
kernel32!BaseThreadStart+4a
kernel32!_except_handler3+61
ntdll!ExecuteHandler2+26
ntdll!ExecuteHandler+24
ntdll!RtlRaiseException+3d
kernel32!RaiseException+53
msvcr80!_CxxThrowException+46
mscorwks!ThrowOutOfMemory+24

abort 的文档说:

In a single or multithreaded Windows-based application, abort calls the Windows MessageBox function to create a message box to display the message with an OK button. When the user clicks OK, the program aborts immediately. The message can be suppressed by calling _set_abort_behavior with the appropriate arguments.

此消息框使服务器挂起。一个线程触发了 GC,但该线程禁用了抢占式 GC。其余大部分线程在等待 GC 完成时阻塞。

我如何 disable the Visual C++ Runtime Error dialog对于网络服务器?

-- 编辑--

OutOfMemoryException 是在一个正在处理大型数据集的线程中引发的。一旦抛出,就会抛出跨上下文异常。这导致 WinDbg 中出现以下堆栈跟踪:

1c54eee8 78158e89 e06d7363 00000001 00000003 kernel32!RaiseException+0x53 (FPO: [Non-Fpo])
1c54ef20 7a14fd18 1c54ef30 7a37d92c 7a3c4aa8 **msvcr80**!_CxxThrowException+0x46 (FPO: [Non-Fpo])
1c54ef34 7a1082db f74a69a8 79f38888 1c54f108 mscorwks!ThrowOutOfMemory+0x24 (FPO: [Non-Fpo])
1c54f060 7a10a245 00000000 1c54f098 1c54f108 mscorwks!Thread::RaiseCrossContextException+0x408 (FPO: [Non-Fpo])
1c54f114 79fd882b 00000002 79fd87f6 1c54f20c mscorwks!Thread::DoADCallBack+0x2a2 (FPO: [Non-Fpo])
1c54f130 79e9846b 1c54f20c 1c54f1b8 79f7762b mscorwks!Thread::DoADCallBack+0x310 (FPO: [Non-Fpo])
1c54f1c4 79e98391 1c54f20c f74a6bc8 23e78e00 mscorwks!Thread::ShouldChangeAbortToUnload+0xe3 (FPO: [Non-Fpo])
1c54f200 79e9851d 1c54f20c 00000002 00000000 mscorwks!Thread::ShouldChangeAbortToUnload+0x30a (FPO: [Non-Fpo])
1c54f228 79fd8f6c 00000002 7a0b68a2 1c54f264 mscorwks!Thread::ShouldChangeAbortToUnload+0x33e (FPO: [Non-Fpo])
1c54f240 7a0b6b5b 00000002 7a0b68a2 1c54f264 mscorwks!ManagedThreadBase::ThreadPool+0x13 (FPO: [Non-Fpo])
1c54f294 7a0b6b8d 00000000 00000000 04a47fe0 mscorwks!BindIoCompletionCallbackStubEx+0x95 (FPO: [Non-Fpo])
1c54f2ac 79f3e605 00000000 00000000 04a47fe0 mscorwks!BindIoCompletionCallbackStub+0x13 (FPO: [Non-Fpo])
1c54f314 79f920a5 00000000 00000000 7ffdc000 mscorwks!ThreadpoolMgr::CompletionPortThreadStart+0x430 (FPO: [Non-Fpo])
1c54ffb8 77e64829 23e29018 00000000 00000000 mscorwks!Thread::intermediateThreadProc+0x49 (FPO: [Non-Fpo])
1c54ffec 00000000 79f9205f 23e29018 00000000 kernel32!BaseThreadStart+0x34 (FPO: [Non-Fpo])

并且那个异常导致调用运行时以显示此消息:

1c54e340 7c82775b 773d7a4b 50000018 00000004 ntdll!KiFastSystemCallRet
1c54e344 773d7a4b 50000018 00000004 00000003 ntdll!NtRaiseHardError+0xc
1c54e3a0 773b8377 1d05ff70 1d052e48 00012010 user32!ServiceMessageBox+0x145
1c54e4fc 7739eec9 1c54e508 00000028 00000000 user32!MessageBoxWorker+0x13e
1c54e554 773d7d0d 00000000 1d05ff70 1d052e48 user32!MessageBoxTimeoutW+0x7a
1c54e588 773c42c8 00000000 1c54e62c 7c37f480 user32!MessageBoxTimeoutA+0x9c
1c54e5a8 773c42a4 00000000 1c54e62c 7c37f480 user32!MessageBoxExA+0x1b
1c54e5c4 7c34c224 00000000 1c54e62c 7c37f480 user32!MessageBoxA+0x45
1c54e5f8 7c348e6c 1c54e62c 7c37f480 00212010 msvcr71!__crtMessageBoxA+0xf4 [f:\vs70builds\3052\vc\crtbld\crt\src\crtmbox.c @ 118]
1c54e81c 7c34cf83 0000000a 00000000 1c54ead4 msvcr71!_NMSG_WRITE+0x12e [f:\vs70builds\3052\vc\crtbld\crt\src\crt0msg.c @ 240]
1c54e854 77e761b7 1c54ead4 00000000 00000000 msvcr71!abort+0x7 [f:\vs70builds\3052\vc\crtbld\crt\src\abort.c @ 48]
1c54eaac 77e792a3 1c54ead4 77e61ac1 1c54eadc kernel32!UnhandledExceptionFilter+0x12a
1c54eab4 77e61ac1 1c54eadc 00000000 1c54eadc kernel32!BaseThreadStart+0x4a
1c54eadc 7c828752 1c54ee98 1c54ffdc 1c54ebb8 kernel32!_except_handler3+0x61
1c54eb00 7c828723 1c54ee98 1c54ffdc 1c54ebb8 ntdll!ExecuteHandler2+0x26
1c54eba8 7c82863c 1c549000 1c54ebb8 00010007 ntdll!ExecuteHandler+0x24
1c54ee88 77e4bee7 1c54ee98 00000002 e06d7363 ntdll!RtlRaiseException+0x3d
1c54eee8 78158e89 e06d7363 00000001 00000003 kernel32!RaiseException+0x53

我不确定为什么堆栈中有 2 个版本的 Visual Studio 运行时库。这是不寻常的。我没有在堆栈中看到其他第 3 方 DLL 的证据。

最佳答案

您必须在程序集中调用 Win32 设置中止行为。您可以使用 P/Invoke 来执行此操作。

这是一篇关于类似问题的有趣文章。 http://blogs.msdn.com/b/pfedev/archive/2010/08/25/whodunit-who-threw-the-message-box-and-why.aspx

他们暗示这是一个尚未解决的已知问题,因此建议使用 _set_abort_behavior 将其关闭。

关于c# - 如何禁用 Web 服务器中的 Visual C++ 运行时错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13279350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com