Uredi

Deli z drugimi prek


overlappedFreeError MDA

Note

This article is specific to .NET Framework. It doesn't apply to newer implementations of .NET, including .NET 6 and later versions.

The overlappedFreeError managed debugging assistant (MDA) is activated when the Overlapped.Free(NativeOverlapped*) method is called before the overlapped operation has completed.

Symptoms

Access violations or corruption of the garbage-collected heap.

Cause

An overlapped structure was freed before the operation completed. The function that is using the overlapped pointer might write to the structure later, after it has been freed. That can cause heap corruption because another object might now occupy that region.

This MDA might not represent an error if the overlapped operation did not start successfully.

Resolution

Ensure that the I/O operation using the overlapped structure has completed before calling the Free(NativeOverlapped*) method.

Effect on the Runtime

This MDA has no effect on the CLR.

Output

The following is sample output for this 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.

Configuration

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

See also