簡體   English   中英

嘗試從 memory 位置 0x00000000 讀取時訪問沖突異常 (0xC0000005)

[英]Access violation exception (0xC0000005) when trying to read from memory location 0x00000000

我有一個應用程序(我們的應用程序)多線程,有時會崩潰,沒有異常(我們訂閱了你的 UnhandledException)。 我們可以在 2 次崩潰之間有幾天或幾個月的時間。 所有線程都是手動創建的,我們不使用線程池。

我知道非托管 memory 存在問題,但在我的應用程序中,我們沒有非托管 function(沒有 importdll),但我們使用 lib MIL(圖像處理庫),它在我們的應用程序中使用了一些 IntPtr。

我有崩潰的轉儲,但並不總是很容易找到一些東西

這是崩潰線程的結果(來自 DebugDiag):

Entry point   clr!:: 
Create time   16/11/2020 18:12:39 
Time spent in user mode   0 Days 00:03:55.515 
Time spent in kernel mode   0 Days 00:00:03.625 

Call Stack

clr!SVR::gc_heap::mark_object_simple+91    
clr!SVR::gc_heap::mark_through_cards_for_segments+482    
clr!SVR::gc_heap::mark_phase+302    
clr!SVR::gc_heap::gc1+b1    
clr!SVR::gc_heap::garbage_collect+f0    
clr!SVR::gc_heap::gc_thread_function+74    
clr!SVR::gc_heap::gc_thread_stub+9a    
clr!<lambda_984b1062d0d4b010966442b24889003f>::<lambda_invoker_cdecl>+51    
kernel32!BaseThreadInitThunk+22    
ntdll!RtlUserThreadStart+34

這是錯誤的第二個線程(來自 DebugDiag):錯誤是:在 App.exe.6860.dmp 中,GC 正在此進程中運行。 觸發 GC 的線程是 1502 我重命名應用程序,不是 App.exe:D

Entry point   clr!Thread::intermediateThreadProc 
Create time   16/11/2020 18:13:27 
Time spent in user mode   0 Days 21:36:08.437 
Time spent in kernel mode   0 Days 01:01:11.015 

.NET Call Stack

[[HelperMethodFrame]] 
Matrox.MatroxImagingLibrary.MIL_INTArrayToIntArrayConverter..ctor(Matrox.MatroxImagingLibrary.MIL_INT[])+2d 
Matrox.MatroxImagingLibrary.MIL.MimGetResult(Matrox.MatroxImagingLibrary.MIL_ID, Int64, Matrox.MatroxImagingLibrary.MIL_INT[])+2e 
App.VisionEngine.DetectionPresence()+373 
App.VisionEngine.th_ActivationP_Processus()+b19 
App.ClassVisionEngine.b__238_0()+25 
mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+172 
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+15 
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+55 
mscorlib_ni!System.Threading.ThreadHelper.ThreadStart()+55 
[[GCFrame]] 
[[DebuggerU2MCatchHandlerFrame]] 

資源

ntdll!NtWaitForSingleObject+a    
KERNELBASE!WaitForSingleObjectEx+94    
clr!CLREventWaitHelper2+3c    
clr!CLREventWaitHelper+1f    
clr!CLREventBase::WaitEx+71    
clr!SVR::gc_heap::wait_for_gc_done+5a    
clr!SVR::GCHeap::GarbageCollectGeneration+ed    
clr!SVR::gc_heap::trigger_gc_for_alloc+34    
clr!SVR::GCHeap::Alloc+225    
clr!JIT_NewArr1+6dd    
Matrox.MatroxImagingLibrary.MIL_INTArrayToIntArrayConverter..ctor(Matrox.MatroxImagingLibrary.MIL_INT[])+2d    
Matrox.MatroxImagingLibrary.MIL.MimGetResult(Matrox.MatroxImagingLibrary.MIL_ID, Int64, Matrox.MatroxImagingLibrary.MIL_INT[])+2e    
App.VisionEngine.DetectionPresence()+373    
App.VisionEngine.th_ActivationP_Processus()+b19    
App.VisionEngine.<Start>b__238_0()+25    
mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+172    
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+15    
mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+55    
mscorlib_ni!System.Threading.ThreadHelper.ThreadStart()+55    
clr!CallDescrWorkerInternal+83    
clr!CallDescrWorkerWithHandler+4e    
clr!MethodDescCallSite::CallTargetWorker+102    
clr!ThreadNative::KickOffThread_Worker+fffff02f    
clr!ManagedThreadBase_DispatchInner+40    
clr!ManagedThreadBase_DispatchMiddle+6c    
clr!ManagedThreadBase_DispatchOuter+4c    
clr!ManagedThreadBase_FullTransitionWithAD+2f    
clr!ThreadNative::KickOffThread+e6    
clr!Thread::intermediateThreadProc+8b    
kernel32!BaseThreadInitThunk+22    
ntdll!RtlUserThreadStart+34 

Matrox 來自 MIL.lib

我陷入了這次崩潰,有人可以給我一些建議

謝謝

“在我們的應用程序中使用了一些 IntPtr。” 假設它是您的應用程序而不是庫(並且這個假設並不完全可疑),請在將 IntPtr 傳遞給庫的任何地方檢查 NULL。 盡管寫在 C# 中,但您現在正在使用非托管規則。

特定的堆垃圾還表明將數組傳遞給保留數組的本機 function 的可能性,並且您沒有先使用 GCHandle 固定數組。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM