https://bugs.winehq.org/show_bug.cgi?id=31438
--- Comment #185 from Heiko lil_tux@web.de --- Ok, looks like I tackled it this time, with the help of the simplistic app
54891.535:0020:CALL Qt5Core._ZN9QIODevice4readEPcx(01cf6528,0000058a,00000000) ret=69710353 54891.535:0020:Call msvcrt.memcpy(01cf6528,00000000,00000000) ret=68998689 54891.535:0020:Ret msvcrt.memcpy() retval=01cf6528 ret=68998689 54891.535:0020:CALL Qt5Core._ZNK15QSocketNotifier9isEnabledEv() ret=6978e219 54891.535:0020:RET Qt5Core._ZNK15QSocketNotifier9isEnabledEv() retval=00000001 ret=6978e219 54891.535:0020:Call ws2_32.WSARecv(000000cc,022bc4c8,00000001,022bc4c4,022bc4c0,00000000,00000000) ret=6979dab9 54891.535:0020:trace:winsock:WSARecv socket 00cc, wsabuf 0x22bc4c8, nbufs 1, flags 0, ovl (nil), func (nil) 54891.535:0020:Call KERNEL32.GetTickCount() ret=7ea6353c 54891.535:0020:Ret KERNEL32.GetTickCount() retval=0345940f ret=7ea6353c 54891.535:0020:trace:winsock:WS2_recv_base socket 00cc, wsabuf 0x22bc4c8 ([0]: 0x1cf6528, 1418), nbufs 1, flags 0, from (nil), fromlen -1, ovl (nil), func (nil) 54891.535:0020:Call ntdll.wine_server_handle_to_fd(000000cc,00000001,022bc380,022bc338) ret=7ea63616 54891.535:0020:Ret ntdll.wine_server_handle_to_fd() retval=00000000 ret=7ea63616 54891.535:0020:trace:winsock:WS2_recv_base fd=26, options=0 54891.535:0020:Call KERNEL32.IsBadWritePtr(01cf6528,0000058a) ret=7ea63709 54891.535:0020:Ret KERNEL32.IsBadWritePtr() retval=00000000 ret=7ea63709 54891.535:0020:trace:winsock:WS2_recv_base -> 1418 bytes 54891.535:0020:Call ntdll.wine_server_release_fd(000000cc,0000001a) ret=7ea63837 54891.535:0020:Ret ntdll.wine_server_release_fd() retval=00000000 ret=7ea63837 0020: enable_socket_event( handle=00cc, mask=00000001, sstate=00000000, cstate=00000000 ) sock_reselect(0x9fe9d40): new mask 3 0020: enable_socket_event() = 0 54891.535:0009:trace:heap:RtlAllocateHeap (0x1ca0000,70000062,00000008): returning 0x1cf6ac8 54891.535:0009:Ret ntdll.RtlAllocateHeap() retval=01cf6ac8 ret=7ef12496 54891.535:0020:Ret ws2_32.WSARecv() retval=00000000 ret=6979dab9 54891.535:0009:Ret msvcrt.malloc() retval=01cf6ac8 ret=6fcacdf7 54891.535:0020:Call ws2_32.WSAGetLastError() ret=6979dac7 54891.535:0009:RET libstdc++-6._Znwj() retval=01cf6ac8 ret=697e95fc 54891.535:0020:Ret ws2_32.WSAGetLastError() retval=00002733 ret=6979dac7 54891.535:0009:Call msvcrt.tolower(00000078) ret=6973ce43 54891.535:0020:CALL Qt5Core._ZNK15QSocketNotifier9isEnabledEv() ret=6978e219 54891.535:0009:Ret msvcrt.tolower() retval=00000078 ret=6973ce43 54891.535:0020:RET Qt5Core._ZNK15QSocketNotifier9isEnabledEv() retval=00000001 ret=6978e219 54891.535:0009:CALL Qt5Core._Z8qstricmpPKcS0_() ret=6973b5dd 54891.535:0020:RET Qt5Core._ZN9QIODevice4readEPcx() retval=00000000 ret=69710353
QIODevice::read does in fact want to read 1418 bytes, WSArecv also returns successful with those 1418 bytes. Unfortunately there's a check in Qt:
if (WSAGetLastError() == WSAEWOULDBLOCK) ret = -2; else ret = qint64(bytesRead);
which we take the first and false branch, because of some EWOULDBLOCK before this WSARecv. Thus Qt thinks, there's still nothing there. I don't honestly know why Qt does check for the error if WSARecv returned 0, but I guess setting a proper errno value can't be wrong, can it? It's done in WSASendTo anyway.
Adding a simple WSASetLastError(0) in the successful receiving path fixes the simplistic app and Origin's download problem.