我的程序遇到了麻烦:当GC执行垃圾收集时,我的程序总是在一个函数崩溃,这个函数在主流之前被多次调用
崩溃,这个函数的第一行是GC.Collect()。函数主要动作是将一些字节发送到串口并从
接收一些字节相同的串口(发送和接收的字节都低于256字节)每次.GC.Collect()调用用于定位崩溃点,它将被删除
发布版。
我不知道确切的原因,但我知道程序崩溃的确切功能。所以,我必须在函数调用期间禁用GC或暂停GC。
我该怎么做?
友好的回应将不胜感激!
此致 jizhiguo
电子邮件:jizhiguo@gmail.com
PS:
环境:winxp(sp3),vs2005,.net 2.0,c#,oracle 10g
以下是我的windbg追踪信息: *注意:IFDMgr和NSIISys的命名空间是我自己创建的。
--------------------------WinDbg tracing info --------------------------
Microsoft (R) Windows Debugger Version 6.11.0001.404 X86
Copyright (c) Microsoft Corporation. All rights reserved.
*** wait with pending attach
Symbol search path is: SRV*d:\websymbols*http://msdl.microsoft.com/download/symbols;D:\jizg\NSIISys\bin\Debug;D:\Symbols
Executable search path is:
ModLoad: 00400000 00512000 D:\jizg\NSIISys\bin\Debug\NSIISys.exe
ModLoad: 7c920000 7c9b6000 C:\WINDOWS\system32\ntdll.dll
ModLoad: 79000000 79046000 C:\WINDOWS\system32\mscoree.dll
ModLoad: 7c800000 7c91e000 C:\WINDOWS\system32\KERNEL32.dll
ModLoad: 77da0000 77e49000 C:\WINDOWS\system32\ADVAPI32.dll
ModLoad: 77e50000 77ee2000 C:\WINDOWS\system32\RPCRT4.dll
ModLoad: 77fc0000 77fd1000 C:\WINDOWS\system32\Secur32.dll
ModLoad: 77f40000 77fb6000 C:\WINDOWS\system32\SHLWAPI.dll
ModLoad: 77ef0000 77f39000 C:\WINDOWS\system32\GDI32.dll
ModLoad: 77d10000 77da0000 C:\WINDOWS\system32\USER32.dll
ModLoad: 77be0000 77c38000 C:\WINDOWS\system32\msvcrt.dll
ModLoad: 76300000 7631d000 C:\WINDOWS\system32\IMM32.DLL
ModLoad: 62c20000 62c29000 C:\WINDOWS\system32\LPK.DLL
ModLoad: 73fa0000 7400b000 C:\WINDOWS\system32\USP10.dll
ModLoad: 79e70000 7a400000 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
ModLoad: 78130000 781cb000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\MSVCR80.dll
ModLoad: 7d590000 7dd84000 C:\WINDOWS\system32\shell32.dll
ModLoad: 77180000 77283000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll
ModLoad: 5d170000 5d20a000 C:\WINDOWS\system32\comctl32.dll
ModLoad: 790c0000 79bb7000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\6d667f19d687361886990f3ca0f49816\mscorlib.ni.dll
ModLoad: 76990000 76acd000 C:\WINDOWS\system32\ole32.dll
ModLoad: 5adc0000 5adf7000 C:\WINDOWS\system32\uxtheme.dll
ModLoad: 10000000 1002f000 C:\Program Files\360safe\safemon\safemon.dll
ModLoad: 770f0000 7717b000 C:\WINDOWS\system32\OLEAUT32.dll
ModLoad: 3e410000 3e4f6000 C:\WINDOWS\system32\WININET.dll
ModLoad: 00df0000 00df9000 C:\WINDOWS\system32\Normaliz.dll
ModLoad: 43ce0000 43e12000 C:\WINDOWS\system32\urlmon.dll
ModLoad: 3eab0000 3ec98000 C:\WINDOWS\system32\iertutil.dll
ModLoad: 76bc0000 76bcb000 C:\WINDOWS\system32\PSAPI.DLL
ModLoad: 71a20000 71a37000 C:\WINDOWS\system32\WS2_32.dll
ModLoad: 71a10000 71a18000 C:\WINDOWS\system32\WS2HELP.dll
ModLoad: 77bd0000 77bd8000 C:\WINDOWS\system32\VERSION.dll
ModLoad: 74680000 746cc000 C:\WINDOWS\system32\MSCTF.dll
ModLoad: 79060000 790bb000 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll
ModLoad: 7a440000 7abc5000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System\80978a322d7dd39f0a71be1251ae395a\System.ni.dll
ModLoad: 7ade0000 7af68000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Drawing\3da96ee075bab9202626ae44c18d226c\System.Drawing.ni.dll
ModLoad: 7afd0000 7bbae000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32
\System.Windows.Forms\63406259e94d5c0ff5b79401dfe113ce\System.Windows.Forms.ni.dll
ModLoad: 76d70000 76d92000 C:\WINDOWS\system32\apphelp.dll
ModLoad: 73640000 7366e000 C:\WINDOWS\system32\msctfime.ime
ModLoad: 4ae90000 4b03b000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.6001.22319_x-ww_f0b4c2df\gdiplus.dll
ModLoad: 03900000 03e49000 C:\WINDOWS\system32\xpsp2res.dll
ModLoad: 03810000 0381c000 D:\jizg\NSIISys\bin\Debug\CoreControl.dll
ModLoad: 041b0000 041f8000 C:\WINDOWS\assembly\GAC_MSIL\mscorlib.resources\2.0.0.0_zh-CHS_b77a5c561934e089\mscorlib.resources.dll
ModLoad: 040f0000 040f8000 D:\jizg\NSIISys\bin\Debug\DBLibrary.dll
ModLoad: 04190000 0419e000 D:\jizg\NSIISys\bin\Debug\CRWOperator.dll
ModLoad: 637a0000 63cd6000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Xml\773a9786013451d3baaeff003dc4230f\System.Xml.ni.dll
ModLoad: 64890000 64981000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Configuration\b82c00e2d24305ad6cb08556e3779b75
\System.Configuration.ni.dll
ModLoad: 68000000 68036000 C:\WINDOWS\system32\rsaenh.dll
ModLoad: 76750000 76759000 C:\WINDOWS\system32\shfolder.dll
ModLoad: 65150000 657a3000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Data\c70731047b0022638b3f9fb158948a03\System.Data.ni.dll
ModLoad: 64e70000 65144000 C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll
ModLoad: 765e0000 76673000 C:\WINDOWS\system32\CRYPT32.dll
ModLoad: 76db0000 76dc2000 C:\WINDOWS\system32\MSASN1.dll
ModLoad: 67af0000 67b8c000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.Transactions\5a555c9ae6984c40157cf940bb519f7c\System.Transactions.ni.dll
ModLoad: 67aa0000 67ae3000 C:\WINDOWS\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll
ModLoad: 75e00000 75eae000 C:\WINDOWS\system32\sxs.dll
ModLoad: 76fa0000 7701f000 C:\WINDOWS\system32\CLBCATQ.DLL
ModLoad: 77020000 770ba000 C:\WINDOWS\system32\COMRes.dll
ModLoad: 72d70000 72de7000 C:\Program Files\Common Files\system\ole db\oledb32.dll
ModLoad: 75b50000 75b75000 C:\WINDOWS\system32\MSDART.DLL
ModLoad: 76320000 76367000 C:\WINDOWS\system32\comdlg32.dll
ModLoad: 74fa0000 74fb1000 C:\Program Files\Common Files\system\ole db\OLEDB32R.DLL
ModLoad: 1b570000 1b5c4000 C:\WINDOWS\system32\msjetoledb40.dll
ModLoad: 1b000000 1b170000 C:\WINDOWS\system32\msjet40.dll
ModLoad: 1b5d0000 1b665000 C:\WINDOWS\system32\mswstr10.dll
ModLoad: 1b2c0000 1b2cd000 C:\WINDOWS\system32\msjter40.dll
ModLoad: 1b2d0000 1b2f6000 C:\WINDOWS\system32\MSJINT40.DLL
ModLoad: 75690000 757cc000 C:\WINDOWS\system32\comsvcs.dll
ModLoad: 75090000 750a4000 C:\WINDOWS\system32\colbact.DLL
ModLoad: 75050000 75063000 C:\WINDOWS\system32\MTXCLU.DLL
ModLoad: 71a40000 71a4b000 C:\WINDOWS\system32\WSOCK32.dll
ModLoad: 5fdd0000 5fe25000 C:\WINDOWS\system32\NETAPI32.dll
ModLoad: 762a0000 762b2000 C:\WINDOWS\system32\CLUSAPI.DLL
ModLoad: 75010000 75022000 C:\WINDOWS\system32\RESUTILS.DLL
ModLoad: 759d0000 75a7f000 C:\WINDOWS\system32\USERENV.dll
ModLoad: 673f0000 6748d000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.EnterpriseSe#\4267bd908175603006c6c90bb5d900c7
\System.EnterpriseServices.ni.dll
ModLoad: 09ce0000 09d28000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System.EnterpriseSe#\4267bd908175603006c6c90bb5d900c7
\System.EnterpriseServices.Wrapper.dll
ModLoad: 09d30000 09d50000 C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll
ModLoad: 1b800000 1b83a000 C:\WINDOWS\system32\msjtes40.dll
ModLoad: 0f9a0000 0f9ab000 C:\WINDOWS\system32\VBAJET32.DLL
ModLoad: 0f9c0000 0fa22000 C:\WINDOWS\system32\expsrv.dll
ModLoad: 099a0000 099a8000 D:\jizg\NSIISys\bin\Debug\FileMgr.dll
ModLoad: 09ae0000 09aea000 D:\jizg\NSIISys\bin\Debug\Log.dll
ModLoad: 09af0000 09b08000 D:\jizg\NSIISys\bin\Debug\IFDMgr.dll
ModLoad: 09b90000 09b9a000 D:\jizg\NSIISys\bin\Debug\SysUtilities.dll
ModLoad: 719c0000 719fe000 C:\WINDOWS\system32\mswsock.dll
ModLoad: 60fd0000 61025000 C:\WINDOWS\system32\hnetcfg.dll
ModLoad: 71a00000 71a08000 C:\WINDOWS\System32\wshtcpip.dll
ModLoad: 09c20000 09c29000 D:\jizg\NSIISys\bin\Debug\JC_6200D.dll
ModLoad: 73d30000 73e2e000 C:\WINDOWS\system32\MFC42.DLL
ModLoad: 61be0000 61bed000 C:\WINDOWS\system32\MFC42LOC.DLL
ModLoad: 5e430000 5e5d6000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\Microsoft.VisualBas#\1c86afc399d0fdd8e069266ffbe748d1
\Microsoft.VisualBasic.ni.dll
(1f0.b64): Break instruction exception - code 80000003 (first chance)
eax=7ffdb000 ebx=00000001 ecx=00000002 edx=00000003 esi=00000004 edi=00000005
eip=7c92120e esp=0ac9ffcc ebp=0ac9fff4 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246
ntdll!DbgBreakPoint:
7c92120e cc int 3
Missing image name, possible paged-out or corrupt data.
0:014> kbn
# ChildEBP RetAddr Args to Child
00 0ac9ffc8 7c971e40 00000005 00000004 00000001 ntdll!DbgBreakPoint
01 0ac9fff4 00000000 00000000 00000000 00000000 ntdll!DbgUiRemoteBreakin+0x2d
0:014> .loadby sos mscorwks
0:014> !clrstack
OS Thread Id: 0xb64 (14)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
0:014> !threads
ThreadCount: 7
UnstartedThread: 0
BackgroundThread: 6
PendingThread: 0
DeadThread: 0
Hosted Runtime: no
PreEmptive GC Alloc Lock
ID OSID ThreadOBJ State GC Context Domain Count APT Exception
0 1 f98 0015b260 6020 Enabled 0155a190:0155acf8 001634d8 0 STA
2 2 8f8 00165038 b220 Enabled 00000000:00000000 001634d8 0 MTA (Finalizer)
7 3 268 001a11a8 200b220 Enabled 0148b480:0148c134 001634d8 0 MTA
8 4 a6c 001b6880 80a220 Enabled 00000000:00000000 001634d8 0 MTA (Threadpool Completion Port)
10 5 aec 001d9138 200b220 Enabled 00000000:00000000 001634d8 0 MTA
11 6 e9c 001bc838 200b220 Enabled 014a49f8:014a6134 001634d8 0 MTA
12 7 818 0022e0e8 200b220 Enabled 01554210:01554cf8 001634d8 0 MTA
0:014> g
ModLoad: 0ada0000 0adca000 D:\jizg\NSIISys\bin\Debug\AghwLib_N.dll
ModLoad: 5f400000 5f4e5000 C:\WINDOWS\system32\MFC42D.DLL
ModLoad: 10200000 10264000 C:\WINDOWS\system32\MSVCRTD.dll
ModLoad: 65860000 658db000 System.Data.OracleClient.dll
ModLoad: 65860000 658db000 C:\WINDOWS\assembly\GAC_32\System.Data.OracleClient\2.0.0.0__b77a5c561934e089\System.Data.OracleClient.dll
ModLoad: 0b060000 0b0b7000 D:\oracle\product\10.2.0\db_1\bin\oci.dll
ModLoad: 7c340000 7c396000 C:\WINDOWS\system32\MSVCR71.dll
ModLoad: 61c20000 61e72000 D:\oracle\product\10.2.0\db_1\bin\OraClient10.Dll
ModLoad: 60870000 60953000 D:\oracle\product\10.2.0\db_1\bin\oracore10.dll
ModLoad: 60a80000 60b44000 D:\oracle\product\10.2.0\db_1\bin\oranls10.dll
ModLoad: 63690000 636a8000 D:\oracle\product\10.2.0\db_1\bin\oraunls10.dll
ModLoad: 60eb0000 60eb7000 D:\oracle\product\10.2.0\db_1\bin\orauts.dll
ModLoad: 76b10000 76b3a000 C:\WINDOWS\system32\WINMM.dll
ModLoad: 636b0000 636b6000 D:\oracle\product\10.2.0\db_1\bin\oravsn10.dll
ModLoad: 0b0c0000 0b1b2000 D:\oracle\product\10.2.0\db_1\bin\oracommon10.dll
ModLoad: 60300000 60857000 D:\oracle\product\10.2.0\db_1\bin\orageneric10.dll
ModLoad: 63430000 63457000 D:\oracle\product\10.2.0\db_1\bin\orasnls10.dll
ModLoad: 0b1c0000 0b320000 D:\oracle\product\10.2.0\db_1\bin\oraxml10.dll
ModLoad: 0b010000 0b021000 C:\WINDOWS\system32\MSVCIRT.dll
ModLoad: 60960000 60a6d000 D:\oracle\product\10.2.0\db_1\bin\oran10.dll
ModLoad: 62740000 6277d000 D:\oracle\product\10.2.0\db_1\bin\oranl10.dll
ModLoad: 62790000 627a7000 D:\oracle\product\10.2.0\db_1\bin\oranldap10.dll
ModLoad: 627f0000 628f9000 D:\oracle\product\10.2.0\db_1\bin\orannzsbb10.dll
ModLoad: 62530000 62583000 D:\oracle\product\10.2.0\db_1\bin\oraldapclnt10.dll
ModLoad: 62670000 6268b000 D:\oracle\product\10.2.0\db_1\bin\orancrypt10.dll
ModLoad: 62920000 6296c000 D:\oracle\product\10.2.0\db_1\bin\oranro10.dll
ModLoad: 626b0000 626b7000 D:\oracle\product\10.2.0\db_1\bin\oranhost10.dll
ModLoad: 62660000 62666000 D:\oracle\product\10.2.0\db_1\bin\orancds10.dll
ModLoad: 629c0000 629c8000 D:\oracle\product\10.2.0\db_1\bin\orantns10.dll
ModLoad: 60b50000 60ea8000 D:\oracle\product\10.2.0\db_1\bin\orapls10.dll
ModLoad: 0aff0000 0aff9000 D:\oracle\product\10.2.0\db_1\bin\oraslax10.dll
ModLoad: 63080000 63284000 D:\oracle\product\10.2.0\db_1\bin\oraplp10.dll
ModLoad: 61ed0000 61f5b000 D:\oracle\product\10.2.0\db_1\bin\orahasgen10.dll
ModLoad: 62ab0000 62b1a000 D:\oracle\product\10.2.0\db_1\bin\oraocr10.dll
ModLoad: 62b20000 62b60000 D:\oracle\product\10.2.0\db_1\bin\oraocrb10.dll
ModLoad: 62980000 62990000 D:\oracle\product\10.2.0\db_1\bin\orantcp10.dll
ModLoad: 0b320000 0b3ba000 D:\oracle\product\10.2.0\db_1\bin\orasql10.dll
ModLoad: 0b880000 0b896000 D:\jizg\NSIISys\bin\Debug\Crwicc.dll
(1f0.e9c): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=00ba1020 ecx=000146b1 edx=0146b198 esi=013c0000 edi=00000155
eip=79f9423a esp=0aa8ec5c ebp=0aa8ed3c iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210246
mscorwks!WKS::gc_heap::plan_phase+0x5c3:
Missing image name, possible paged-out or corrupt data.
79f9423a f70000000080 test dword ptr [eax],80000000h ds:0023:00000000=????????
*** WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\6d667f19d687361886990f3ca0f49816\mscorlib.ni.dll
0:011> kbn
# ChildEBP RetAddr Args to Child
00 0aa8ed3c 79f92d5b 00000002 7a3b8ae0 00000001 mscorwks!WKS::gc_heap::plan_phase+0x5c3
01 0aa8ed5c 79f932d5 00000000 7a3b8bc8 00080101 mscorwks!WKS::gc_heap::gc1+0x6e
02 0aa8ed70 79f92fea 00000002 00000001 001bc838 mscorwks!WKS::gc_heap::garbage_collect+0x253
03 0aa8ed9c 79f3d2a9 00000002 00000000 0aa8edcc mscorwks!WKS::GCHeap::GarbageCollectGeneration+0x1a9
04 0aa8edac 79f3d2e5 00000002 00000000 001bc838 mscorwks!WKS::GCHeap::GarbageCollectTry+0x33
05 0aa8edcc 79f3d1a4 ffffffff 00000000 00000000 mscorwks!WKS::GCHeap::GarbageCollect+0x67
06 0aa8ee78 79777d16 09bb99aa 09bb98b8 00e95117 mscorwks!GCInterface::CollectGeneration+0xaa
07 0aa8efbc 79e96c8c 655f10e0 0aa8f028 0aa8f010 mscorlib_ni+0x6b7d16
08 0aa8efdc 79eb4afa 79eb4b13 01453830 01453830 mscorwks!MethodDescCallSite::Call_RetI4+0x1c
09 0aa8f0dc 00000000 00000000 00000000 00000000 mscorwks!SafeHandle::RunReleaseMethod+0x89
0:011> !clrstack
OS Thread Id: 0xe9c (11)
ESP EIP
0aa8ee28 79f9423a [HelperMethodFrame: 0aa8ee28] System.GC.nativeCollectGeneration(Int32, Int32)
0aa8ee80 79777d16 System.GC.Collect()
0aa8ee84 09bb99aa IFDMgr.ArtcCardGeniusI200Mgr.ExecCmd(System.String, Byte[] ByRef, Int32)
0aa8ef8c 09bb990f IFDMgr.ArtcCardGeniusI200Mgr.IFDMgr.IIFDMgr.ExecCmd(System.String, System.String ByRef, Int32)
0aa8efc0 0b00b4f7 NSIISys.CardMachineForm.InitDF(System.String, CPUCardKit.ICPUCardOperator, CoreControl.DFInfo)
0aa8f410 0b0087ad NSIISys.CardMachineForm.InitCard()
0aa8f5a4 09bb8d5b NSIISys.CardMachineForm.IssueCard()
0aa8f684 09bb8952 NSIISys.CardMachineForm.ProcessMsg(CardMachineMessage)
0aa8f760 09bb5356 NSIISys.CardMachineForm.CardMachineMsgProcessor()
0aa8f7c0 792d6d66 System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
0aa8f7cc 792e01ef System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0aa8f7e4 792d6ce4 System.Threading.ThreadHelper.ThreadStart()
0aa8fa0c 79e71b4c [GCFrame: 0aa8fa0c]
0:011> g
(1f0.e9c): Break instruction exception - code 80000003 (first chance)
eax=00000001 ebx=00000000 ecx=00000001 edx=0aa8e788 esi=00000000 edi=7a0979c6
eip=7c92120e esp=0aa8e2e8 ebp=0aa8e794 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00200202
ntdll!DbgBreakPoint:
7c92120e cc int 3
0:011> kbn
# ChildEBP RetAddr Args to Child
00 0aa8e2e4 7a096467 0aa8e788 79f7762b 54504fde ntdll!DbgBreakPoint
01 0aa8e794 7a096796 80131506 7a0979c6 00000000 mscorwks!EEPolicy::LogFatalError+0x2b5
02 0aa8e7ac 7a0979d1 80131506 7a0979c6 00000000 mscorwks!EEPolicy::HandleFatalError+0x4d
03 0aa8e7d0 79f5f503 0aa8e850 5450404e 001bc838 mscorwks!CLRVectoredExceptionHandlerPhase3+0xbc
04 0aa8e804 79f5f3a5 0aa8e850 54504072 0aa8e990 mscorwks!CLRVectoredExceptionHandlerPhase2+0x20
05 0aa8e838 79edc2f8 0aa8e850 00004000 001bc838 mscorwks!CLRVectoredExceptionHandler+0x10a
06 0aa8e864 79edc4f5 0aa8e974 0aa8f81c 0aa8e948 mscorwks!CPFH_RealFirstPassHandler+0x607
07 0aa8e888 7c9232a8 0aa8e974 0aa8f81c 0aa8e990 mscorwks!COMPlusFrameHandler+0x15a
08 0aa8e8ac 7c92327a 0aa8e974 0aa8f81c 0aa8e990 ntdll!ExecuteHandler2+0x26
09 0aa8e95c 7c92e48a 00000000 0aa8e990 0aa8e974 ntdll!ExecuteHandler+0x24
0a 0aa8e95c 79f9423a 00000000 0aa8e990 0aa8e974 ntdll!KiUserExceptionDispatcher+0xe
0b 0aa8ed3c 79f92d5b 00000002 7a3b8ae0 00000001 mscorwks!WKS::gc_heap::plan_phase+0x5c3
0c 0aa8ed5c 79f932d5 00000000 7a3b8bc8 00080101 mscorwks!WKS::gc_heap::gc1+0x6e
0d 0aa8ed70 79f92fea 00000002 00000001 001bc838 mscorwks!WKS::gc_heap::garbage_collect+0x253
0e 0aa8ed9c 79f3d2a9 00000002 00000000 0aa8edcc mscorwks!WKS::GCHeap::GarbageCollectGeneration+0x1a9
0f 0aa8edac 79f3d2e5 00000002 00000000 001bc838 mscorwks!WKS::GCHeap::GarbageCollectTry+0x33
10 0aa8edcc 79f3d1a4 ffffffff 00000000 00000000 mscorwks!WKS::GCHeap::GarbageCollect+0x67
11 0aa8ee78 79777d16 09bb99aa 09bb98b8 00e95117 mscorwks!GCInterface::CollectGeneration+0xaa
12 0aa8efbc 79e96c8c 655f10e0 0aa8f028 0aa8f010 mscorlib_ni+0x6b7d16
13 0aa8efdc 79eb4afa 79eb4b13 01453830 01453830 mscorwks!MethodDescCallSite::Call_RetI4+0x1c
0:011> !clrstack
OS Thread Id: 0xe9c (11)
ESP EIP
0aa8ee28 7c92120e [HelperMethodFrame: 0aa8ee28] System.GC.nativeCollectGeneration(Int32, Int32)
0aa8ee80 79777d16 System.GC.Collect()
0aa8ee84 09bb99aa IFDMgr.ArtcCardGeniusI200Mgr.ExecCmd(System.String, Byte[] ByRef, Int32)
0aa8ef8c 09bb990f IFDMgr.ArtcCardGeniusI200Mgr.IFDMgr.IIFDMgr.ExecCmd(System.String, System.String ByRef, Int32)
0aa8efc0 0b00b4f7 NSIISys.CardMachineForm.InitDF(System.String, CPUCardKit.ICPUCardOperator, CoreControl.DFInfo)
0aa8f410 0b0087ad NSIISys.CardMachineForm.InitCard()
0aa8f5a4 09bb8d5b NSIISys.CardMachineForm.IssueCard()
0aa8f684 09bb8952 NSIISys.CardMachineForm.ProcessMsg(CardMachineMessage)
0aa8f760 09bb5356 NSIISys.CardMachineForm.CardMachineMsgProcessor()
0aa8f7c0 792d6d66 System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
0aa8f7cc 792e01ef System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0aa8f7e4 792d6ce4 System.Threading.ThreadHelper.ThreadStart()
0aa8fa0c 79e71b4c [GCFrame: 0aa8fa0c]
0:011> g
eax=00000000 ebx=00000000 ecx=7c800000 edx=0aa8e418 esi=7c92de6e edi=80131506
eip=7c92e514 esp=0aa8e468 ebp=0aa8e564 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00200246
ntdll!KiFastSystemCallRet:
7c92e514 c3 ret
0:011> kbn
# ChildEBP RetAddr Args to Child
00 0aa8e464 7c92de7a 7c81cace ffffffff 80131506 ntdll!KiFastSystemCallRet
01 0aa8e468 7c81cace ffffffff 80131506 c0000005 ntdll!NtTerminateProcess+0xc
02 0aa8e564 7c81cb26 80131506 77e8f3b0 ffffffff KERNEL32!_ExitProcess+0x62
03 0aa8e578 79fdc444 80131506 001bc838 0aa8e990 KERNEL32!ExitProcess+0x14
04 0aa8e7a0 7a09679e 80131506 0aa8e7d0 7a0979d1 mscorwks!SafeExitProcess+0x157
05 0aa8e7ac 7a0979d1 80131506 7a0979c6 00000000 mscorwks!EEPolicy::HandleFatalError+0x55
06 0aa8e7d0 79f5f503 0aa8e850 5450404e 001bc838 mscorwks!CLRVectoredExceptionHandlerPhase3+0xbc
07 0aa8e804 79f5f3a5 0aa8e850 54504072 0aa8e990 mscorwks!CLRVectoredExceptionHandlerPhase2+0x20
08 0aa8e838 79edc2f8 0aa8e850 00004000 001bc838 mscorwks!CLRVectoredExceptionHandler+0x10a
09 0aa8e864 79edc4f5 0aa8e974 0aa8f81c 0aa8e948 mscorwks!CPFH_RealFirstPassHandler+0x607
0a 0aa8e888 7c9232a8 0aa8e974 0aa8f81c 0aa8e990 mscorwks!COMPlusFrameHandler+0x15a
0b 0aa8e8ac 7c92327a 0aa8e974 0aa8f81c 0aa8e990 ntdll!ExecuteHandler2+0x26
0c 0aa8e95c 7c92e48a 00000000 0aa8e990 0aa8e974 ntdll!ExecuteHandler+0x24
0d 0aa8e95c 79f9423a 00000000 0aa8e990 0aa8e974 ntdll!KiUserExceptionDispatcher+0xe
0e 0aa8ed3c 79f92d5b 00000002 7a3b8ae0 00000001 mscorwks!WKS::gc_heap::plan_phase+0x5c3
0f 0aa8ed5c 79f932d5 00000000 7a3b8bc8 00080101 mscorwks!WKS::gc_heap::gc1+0x6e
10 0aa8ed70 79f92fea 00000002 00000001 001bc838 mscorwks!WKS::gc_heap::garbage_collect+0x253
11 0aa8ed9c 79f3d2a9 00000002 00000000 0aa8edcc mscorwks!WKS::GCHeap::GarbageCollectGeneration+0x1a9
12 0aa8edac 79f3d2e5 00000002 00000000 001bc838 mscorwks!WKS::GCHeap::GarbageCollectTry+0x33
13 0aa8edcc 79f3d1a4 ffffffff 00000000 00000000 mscorwks!WKS::GCHeap::GarbageCollect+0x67
0:011> !clrstack
OS Thread Id: 0xe9c (11)
ESP EIP
0aa8ee28 7c92e514 [HelperMethodFrame: 0aa8ee28] System.GC.nativeCollectGeneration(Int32, Int32)
0aa8ee80 79777d16 System.GC.Collect()
0aa8ee84 09bb99aa IFDMgr.ArtcCardGeniusI200Mgr.ExecCmd(System.String, Byte[] ByRef, Int32)
0aa8ef8c 09bb990f IFDMgr.ArtcCardGeniusI200Mgr.IFDMgr.IIFDMgr.ExecCmd(System.String, System.String ByRef, Int32)
0aa8efc0 0b00b4f7 NSIISys.CardMachineForm.InitDF(System.String, CPUCardKit.ICPUCardOperator, CoreControl.DFInfo)
0aa8f410 0b0087ad NSIISys.CardMachineForm.InitCard()
0aa8f5a4 09bb8d5b NSIISys.CardMachineForm.IssueCard()
0aa8f684 09bb8952 NSIISys.CardMachineForm.ProcessMsg(CardMachineMessage)
0aa8f760 09bb5356 NSIISys.CardMachineForm.CardMachineMsgProcessor()
0aa8f7c0 792d6d66 System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
0aa8f7cc 792e01ef System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0aa8f7e4 792d6ce4 System.Threading.ThreadHelper.ThreadStart()
0aa8fa0c 79e71b4c [GCFrame: 0aa8fa0c]
0:011> g
^ No runnable debuggees error in 'g'
答案 0 :(得分:2)
GC中的崩溃(非例外)意味着非托管(即C ++ - CLR,不安全或非.NET)代码已损坏堆。检查您的非.NET代码是否存在潜在问题!特别是D:\jizg\NSIISys\bin\Debug
.NET中的那些文件?如果没有,他们看起来对我很怀疑。
答案 1 :(得分:1)
编辑:这是正在发生的事情。您有一个包含非托管资源作为成员的某种类型的对象实例。该类型具有调用Dispose()
的终结器(看起来像C#中的析构函数语法)。应用程序的某些部分依赖于此对象持有的非托管资源 - 可能是类型为IntPtr
的句柄。只要对象保持活动状态(不是由GC收集),就永远不会调用Dispose()
,句柄仍然有效。问题是由于程序保留原始句柄(可能是IntPtr
)而没有保留对保留资源的托管对象的引用。如果不保留该引用,该对象就有资格进行最终化/收集。 解决方案:确定管理资源的托管类型,并确保在不再需要其资源之前保留其副本。当您不再需要该资源时,请自行调用托管对象上的Dispose()
以清理内容,而无需致电GC.Collect()
。
答案 2 :(得分:1)
就是不要这样做。找到问题并修复它,而不仅仅是快速修补它。它只会移动到其他地方。
答案 3 :(得分:0)
有几条消息似乎很有趣:
WARNING: Unable to verify checksum for C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\6d667f19d687361886990f3ca0f49816\mscorlib.ni.dll
您可能想知道为什么会出现此错误,因为它可能是非托管API的问题。
你有没有写过的非托管C ++ dll?
图像名称可能已损坏似乎有问题,因此您可能希望删除引用图像的代码并查看发生的情况,然后一次添加一段代码,直到找到该块为止导致问题。
答案 4 :(得分:0)
缺陷是由堆栈损坏引起的。这是我们在公司中使用的一种技术,用于在发布代码中查找这些问题。
首先,下载并运行appverifier。这是一个微软工具,只适用于Windows。
如果存在任何指针问题,AppVerifier将强制您的非托管代码抛出一个exeption。但是,由于.NET初始化的方式,.NET可执行文件也会在启动过程中因崩溃而崩溃。你需要做的是,在本机C中仔细编写一个测试应用程序,它将调用与.NET代码相同的非托管函数。
在调试器中运行您的代码。代码将崩溃,导致问题的指针的确切地址。
您的代码运行速度非常慢。这是因为AppVerifier将使Windows在您的测试程序上加载一系列测试。
答案 5 :(得分:0)
问题已经解决了!
实际原因是非托管函数有一个野指针。我用这个函数的托管版本替换它,问题就消失了。
感谢所有关心这个问题的人。