overlappedFreeError MDA

オーバーラップされた操作が完了する前に Overlapped.Free(NativeOverlapped*) メソッドが呼び出されると、overlappedFreeError マネージド デバッグ アシスタント (MDA) がアクティブになります。

現象

アクセス違反またはガベージ コレクションされたヒープの破損。

原因

操作が完了する前に、オーバーラップされた構造が解放されました。 オーバーラップされたポインターを使用する関数は、解放された後に構造に書き込む可能性があります。 その場合、現時点で別のオブジェクトがその領域を占有していることによってヒープが破損する可能性があります。

オーバーラップされた操作が正常に起動しなかった場合、この MDA はエラーを発生しないことがあります。

解決方法

Free(NativeOverlapped*) メソッドを呼び出す前に、オーバーラップされた構造を使用している I/O 操作が必ず完了するようにします。

ランタイムへの影響

この 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>  

関連項目