Bug 8449 - Definition of System.Threading.NativeOverlapped structure does not correspond to Win32 OVERLAPPED
Summary: Definition of System.Threading.NativeOverlapped structure does not correspond...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-11-15 21:59 UTC by Alex
Modified: 2012-12-11 08:38 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Alex 2012-11-15 21:59:01 UTC

NativeOverlapped should represent a Win32 OVERLAPPED structure. In Mono it is declared as follows

public struct NativeOverlapped {
	public IntPtr EventHandle;
	public IntPtr InternalHigh;
	public IntPtr InternalLow;
	public int OffsetHigh;
	public int OffsetLow;
	// additional fields

however Win32 OVERLAPPED is

typedef struct _OVERLAPPED {
  ULONG_PTR Internal;
  ULONG_PTR InternalHigh;
  union {
    struct {
      DWORD Offset;
      DWORD OffsetHigh;
    PVOID  Pointer;
  HANDLE    hEvent;

therefore definition of NativeOverlapped should be something like

public struct NativeOverlapped
    public IntPtr  InternalLow; 
    public IntPtr  InternalHigh;
    public int     OffsetLow; 
    public int     OffsetHigh;
    public IntPtr  EventHandle;
    // additional fields

Win32 overlapped IO depends on NativeOverlapped, particularly the SerialPort class is affected - it is not possible to run concurrent reads and writes on serial ports. Please correct the order of fields of NativeOverlapped.
Comment 1 Jonathan Pryor 2012-11-15 23:38:07 UTC
For reference, the WinAPI documentation for OVERLAPPED:

Comment 2 Marek Safar 2012-11-20 07:04:59 UTC
Fixed in master