Opened 8 years ago

Closed 7 years ago

#738 closed defect (fixed)

Fix remote backend on 64-bit MS Windows

Reported by: Olly Betts Owned by: Olly Betts
Priority: low Milestone: 1.4.6
Component: Backend-Remote Version: 1.4.0
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: Microsoft Windows

Description (last modified by Olly Betts)

The remote backend code assumes it can cast HANDLE to int and back and preserve the value. But HANDLE is an unsigned integer type with the same width as a pointer so that fails for the 64-bit version of this platform.

The inherent problem is that sockets aren't just normal fds on this platform, which doesn't match the POSIX model. I think the simplest fix is probably to allocate a large int value (well above the max possible fd supported) for each HANDLE value, and then have a suitable data structure to map these back to the HANDLE values.

Doesn't affect the library ABI so could be implemented in 1.4.x. Also affects 1.2.x.

Not actually reported by users (I just noticed this while working on the code) to setting as "low" priority.

Change History (4)

comment:1 by Olly Betts, 8 years ago

Summary: FIx remote backend on 64-bit MS WindowsFix remote backend on 64-bit MS Windows

comment:2 by Olly Betts, 7 years ago

Description: modified (diff)

comment:3 by Olly Betts, 7 years ago

Milestone: 1.4.x1.4.6

Having done a bit of digging, it seems that actually it's always safe to cast HANDLE to int - the values what occur all map to unsigned int values, except INVALID_HANDLE which maps to -1 (which matches the -1 for invalid fd that BSD sockets uses).

I've pushed f006fc9325443bd93d1429fd19d68109a2d73eea to git master which adds a check that the cast doesn't mangled the value (and for 32-bit SOCKET, that we don't end up with a negative int value except from INVALID_HANDLE).

Marking for backport for 1.4.6.

comment:4 by Olly Betts, 7 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.