共用方式為


overlappedFreeError MDA

注意

本文專屬於 .NET Framework。 它不適用於較新的 .NET 實作,包括 .NET 6 和更新版本。

重疊作業完成之前,呼叫 Overlapped.Free(NativeOverlapped*) 方法時,會啟用 overlappedFreeError Managed 偵錯助理 (MDA)。

徵兆

已進行記憶體回收之堆積的存取違規或損毀。

原因

作業完成之前,已釋放重疊結構。 使用重疊指標的函式稍後可能會在釋出之後寫入結構中。 這可能會造成堆積損毀,因為另一個物件現在可能會佔用該區域。

如果未成功啟動重疊的作業,則此 MDA 可能不會呈現錯誤。

解決方法

請確定使用重疊結構的 I/O 作業完成,再呼叫 Free(NativeOverlapped*) 方法。

對執行階段的影響

此 MDA 對 CLR 沒有影響。

輸出

以下是此 MDA 的範例輸出。

An overlapped pointer (0x00ea3430) that was not allocated on the GC heap was passed via Pinvoke to the win32 function 'WriteFile' in module 'KERNEL32.DLL'. If the AppDomain is shut down, this can cause heap corruption when the async I/O completes. The best solution is to pass a NativeOverlappedStructure retrieved from a call to System.Threading.Overlapped.Pack(). If the AppDomain exits, the CLR will keep this structure alive and pinned until the I/O completes.

組態

<mdaConfig>
  <assistants>
    <overlappedFreeError/>
  </assistants>
</mdaConfig>

另請參閱