Attached is the output of +relay,+file,+comm.
It looks like ClearCommError is returning 20, which is "ERROR_BAD_UNIT", system cannot find the device specified. Shouldn't this be returning ERROR_IO_PENDING for overlapped io?
I changed files/file.c to call SetLastError(ERROR_IO_PENDING) after the call to read(...) in the FD_TYPE_OVERLAPPED case instead of calling FILE_SetDosError, but that caused my app to not even be able to talk to the modem to get it to connect, so apparently that's not the problem.
08d06170:Call kernel32.CreateFileA(41f4f34c "COM1",c0000000,00000000,00000000,00000003,40000080,00000000) ret=6c11415d trace:file:CreateFileA COM1 GENERIC_READ GENERIC_WRITE OPEN_EXISTING FILE_FLAG_OVERLAPPED attributes 0x40000080 trace:file:CreateFileA opening device 'COM1' trace:file:DOSFS_CreateCommPort COM1 c0000000 40000080 trace:file:CreateFileA returning 00000328 08d06170:Ret kernel32.CreateFileA() retval=00000328 ret=6c11415d 08d06170:Call kernel32.SetupComm(00000328,00005f38,00002000) ret=6c1144eb fixme:comm:SetupComm insize 24376 outsize 8192 unimplemented stub 08d06170:Ret kernel32.SetupComm() retval=00000001 ret=6c1144eb 08d06170:Call kernel32.GetCommState(00000328,443e6e6c) ret=6c114503 trace:comm:GetCommState handle 808, ptr 0x443e6e6c trace:comm:GetCommState OK trace:comm:GetCommState bytesize 8 baudrate 115200 fParity 1 Parity 0 stopbits 1 trace:comm:GetCommState ~IXON ~IXOFF trace:comm:GetCommState CRTSCTS 08d06170:Ret kernel32.GetCommState() retval=00000001 ret=6c114503 08d06170:Call kernel32.SetCommState(00000328,443e6e6c) ret=6c114565 trace:comm:SetCommState handle 808, ptr 0x443e6e6c trace:comm:SetCommState bytesize 8 baudrate 115200 fParity 1 Parity 0 stopbits 1 trace:comm:SetCommState ~IXON ~IXOFF trace:comm:SetCommState CRTSCTS 08d06170:Ret kernel32.SetCommState() retval=00000001 ret=6c114565 08d06170:Call kernel32.SetCommTimeouts(00000328,443e6ea0) ret=6c1141ca trace:comm:SetCommTimeouts (328,0x443e6ea0) 08d06170:Ret kernel32.SetCommTimeouts() retval=00000001 ret=6c1141ca 08d06170:Call kernel32.PurgeComm(00000328,0000000f) ret=6c1141f2 trace:comm:PurgeComm handle 808, flags f 08d06170:Ret kernel32.PurgeComm() retval=00000001 ret=6c1141f2 08d06170:Call kernel32.EscapeCommFunction(00000328,00000005) ret=6c114224 trace:comm:EscapeCommFunction handle 808, function=5 trace:comm:EscapeCommFunction SETDTR 08d06170:Ret kernel32.EscapeCommFunction() retval=00000001 ret=6c114224 08d06170:Call kernel32.CreateEventA(41f51260,00000001,00000000,00000000) ret=6c111bfc 08d06170:Ret kernel32.CreateEventA() retval=0000032c ret=6c111bfc 08d06170:Call kernel32.CreateThread(00000000,00000000,78002432,41f511f0,00000000,443e6e8c) ret=78002426 08b947e0:Ret kernel32.CreateThread() retval=00000320 ret=78002426 08b947e0:Call kernel32.Sleep(00000001) ret=6c1106ce 08b947e0:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08b947e0:Call kernel32.Sleep(00000001) ret=6c1106ce 08b947e0:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08b947e0:Call user32.PeekMessageA(405b620c,00000000,00000000,00000000,00000003) ret=60f0119b 08b947e0:Ret user32.PeekMessageA() retval=00000001 ret=60f0119b 08b947e0:Call user32.TranslateMessage(405b620c) ret=60f011b4 08b947e0:Ret user32.TranslateMessage() retval=00000000 ret=60f011b4 08b947e0:Call user32.DispatchMessageA(405b620c) ret=60f011ba 08b947e0:Call window proc 0x60f05450 (hwnd=0001002a,msg=WM_USER+04d8,wp=00000000,lp=00000000) 08b947e0:Call kernel32._llseek(00000108,00430e24,00000000) ret=60f0f86e trace:file:SetFilePointer handle 264 offset 4394532 high 0 origin 0 08b947e0:Ret kernel32._llseek() retval=00430e24 ret=60f0f86e 08b947e0:Call kernel32._hread(00000108,405b5eac,0000001a) ret=60f0f883 trace:file:ReadFile 264 0x405b5eac 26 0x405b5db4 (nil) 08b947e0:Ret kernel32._hread() retval=0000001a ret=60f0f883 08b947e0:Call kernel32._llseek(00000108,00430e3e,00000000) ret=60f0f027 trace:file:SetFilePointer handle 264 offset 4394558 high 0 origin 0 08b947e0:Ret kernel32._llseek() retval=00430e3e ret=60f0f027 08b947e0:Call kernel32._hread(00000108,41f511a0,00000040) ret=60f0f048 trace:file:ReadFile 264 0x41f511a0 64 0x405b5dd4 (nil) 08b947e0:Ret kernel32._hread() retval=00000040 ret=60f0f048 08d06360:Starting thread (entryproc=0x78002432) 08d06360:Call PE DLL (proc=0xbfe21038,module=bfe20000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0xbfe21038,module=bfe20000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x40839b80,module=40829000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x40839b80,module=40829000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x4079f7d0,module=40791000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x4079f7d0,module=40791000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x40a90350,module=40a82000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x40a90350,module=40a82000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x40682b1c,module=4065a000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x40682b1c,module=4065a000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x41c7bc80,module=41c75000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x41c7bc80,module=41c75000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x405ee65c,module=405d4000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x405ee65c,module=405d4000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x78001c48,module=78000000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x78001c48,module=78000000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x408d2220,module=408c1000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x408d2220,module=408c1000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x658417c0,module=65840000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x658417c0,module=65840000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x6509f2bb,module=65080000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x6509f2bb,module=65080000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x657820d0,module=65780000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x657820d0,module=65780000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x65943315,module=65940000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x65943315,module=65940000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x65f21fcb,module=65f00000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x65f21fcb,module=65f00000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x10005fd2,module=10000000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x10005fd2,module=10000000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x40a4c3d0,module=40a40000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x40a4c3d0,module=40a40000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x6534d03b,module=65340000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x6534d03b,module=65340000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x701015a4,module=70100000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x701015a4,module=70100000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7f9617fd,module=7f960000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7f9617fd,module=7f960000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x70201631,module=70200000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x70201631,module=70200000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x428a800a,module=428a7000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x428a800a,module=428a7000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x655c15f0,module=655c0000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x655c15f0,module=655c0000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x6510fe71,module=65100000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x6510fe71,module=65100000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7f841536,module=7f840000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7f841536,module=7f840000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7f99102a,module=7f990000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7f99102a,module=7f990000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7fb41269,module=7fb40000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7fb41269,module=7fb40000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7fb0195c,module=7fb00000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7fb0195c,module=7fb00000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7f951603,module=7f950000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7f951603,module=7f950000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7fc310d9,module=7fc30000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7fc310d9,module=7fc30000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7f8758af,module=7f870000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7f8758af,module=7f870000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x42e88a2c,module=42e83000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x42e88a2c,module=42e83000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x7f881356,module=7f880000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x7f881356,module=7f880000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x603016bb,module=60300000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x603016bb,module=60300000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x70291483,module=70290000,type=2,res=(nil)) 08d06360:Call kernel32.HeapAlloc(40380000,00000000,00000028) ret=7029181a 08d06360:Ret kernel32.HeapAlloc() retval=441ae1dc ret=7029181a 08d06360:Ret PE DLL (proc=0x70291483,module=70290000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x6600e0e0,module=66000000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x6600e0e0,module=66000000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x3000e449,module=30000000,type=2,res=(nil)) 08d06360:Call kernel32.GlobalAlloc(00000040,000095b6) ret=300011ca 08d06360:Ret kernel32.GlobalAlloc() retval=441ae210 ret=300011ca 08d06360:Call kernel32.lstrcpyA(441ae280,30015d10 "Extract Progress") ret=300011a3 08d06360:Ret kernel32.lstrcpyA() retval=441ae280 ret=300011a3 08d06360:Ret PE DLL (proc=0x3000e449,module=30000000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x6c00868a,module=6c000000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x6c00868a,module=6c000000,type=2,res=(nil)) retval=1 08d06360:Call PE DLL (proc=0x70c31dea,module=70c30000,type=2,res=(nil)) 08d06360:Ret PE DLL (proc=0x70c31dea,module=70c30000,type=2,res=(nil)) retval=1 08d06360:Call kernel32.GetCurrentThreadId() ret=78002476 08d06360:Ret kernel32.GetCurrentThreadId() retval=08d06360 ret=78002476 08d06360:Call kernel32.GetTickCount() ret=6c1145a0 08d06360:Ret kernel32.GetTickCount() retval=0001b1be ret=6c1145a0 08d06360:Call kernel32.CreateEventA(00000000,00000001,00000000,00000000) ret=6c1145d5 08d06360:Ret kernel32.CreateEventA() retval=00000338 ret=6c1145d5 08d06360:Call kernel32.GetTickCount() ret=6c1145f3 08d06360:Ret kernel32.GetTickCount() retval=0001b1be ret=6c1145f3 08d06360:Call kernel32.ClearCommError(00000328,44536214,44536230) ret=6c1146e6 trace:comm:ClearCommError handle 808 cbInQue = 0 cbOutQue = 0 08d06360:Ret kernel32.ClearCommError() retval=00000001 ret=6c1146e6 08d06360:Call kernel32.ResetEvent(00000338) ret=6c11472d 08d06360:Ret kernel32.ResetEvent() retval=00000001 ret=6c11472d 08d06360:Call kernel32.ReadFile(00000328,4453623c,00000c80,44536208,4453621c) ret=6c11474a trace:file:ReadFile 808 0x4453623c 3200 0x44536208 0x4453621c FIXME:pthread_rwlock_rdlock FIXME:pthread_rwlock_unlock trace:file:FILE_SetDosError errno = 11 Resource temporarily unavailable 08d06360:Ret kernel32.ReadFile() retval=00000000 ret=6c11474a 08d06360:Call kernel32.GetLastError() ret=6c114754 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c114754 08d06360:Call kernel32.GetLastError() ret=6c1147c5 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c1147c5 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.GetTickCount() ret=6c1145f3 08d06360:Ret kernel32.GetTickCount() retval=0001b1c1 ret=6c1145f3 08d06360:Call kernel32.GetCommModemStatus(00000328,44536210) ret=6c114615 trace:comm:GetCommModemStatus 4126 -> MS_DSR_ON MS_CTS_ON 08d06360:Ret kernel32.GetCommModemStatus() retval=00000001 ret=6c114615 08d06360:Call kernel32.ClearCommError(00000328,44536214,44536230) ret=6c1146e6 trace:comm:ClearCommError handle 808 cbInQue = 0 cbOutQue = 0 08d06360:Ret kernel32.ClearCommError() retval=00000001 ret=6c1146e6 08d06360:Call kernel32.ResetEvent(00000338) ret=6c11472d 08d06360:Ret kernel32.ResetEvent() retval=00000001 ret=6c11472d 08d06360:Call kernel32.ReadFile(00000328,4453623c,00000c80,44536208,4453621c) ret=6c11474a trace:file:ReadFile 808 0x4453623c 3200 0x44536208 0x4453621c FIXME:pthread_rwlock_rdlock FIXME:pthread_rwlock_unlock trace:file:FILE_SetDosError errno = 11 Resource temporarily unavailable 08d06360:Ret kernel32.ReadFile() retval=00000000 ret=6c11474a 08d06360:Call kernel32.GetLastError() ret=6c114754 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c114754 08d06360:Call kernel32.GetLastError() ret=6c1147c5 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c1147c5 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.GetTickCount() ret=6c1145f3 08d06360:Ret kernel32.GetTickCount() retval=0001b1c3 ret=6c1145f3 08d06360:Call kernel32.ClearCommError(00000328,44536214,44536230) ret=6c1146e6 trace:comm:ClearCommError handle 808 cbInQue = 0 cbOutQue = 0 08d06360:Ret kernel32.ClearCommError() retval=00000001 ret=6c1146e6 08d06360:Call kernel32.ResetEvent(00000338) ret=6c11472d 08d06360:Ret kernel32.ResetEvent() retval=00000001 ret=6c11472d 08d06360:Call kernel32.ReadFile(00000328,4453623c,00000c80,44536208,4453621c) ret=6c11474a trace:file:ReadFile 808 0x4453623c 3200 0x44536208 0x4453621c FIXME:pthread_rwlock_rdlock FIXME:pthread_rwlock_unlock trace:file:FILE_SetDosError errno = 11 Resource temporarily unavailable 08d06360:Ret kernel32.ReadFile() retval=00000000 ret=6c11474a 08d06360:Call kernel32.GetLastError() ret=6c114754 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c114754 08d06360:Call kernel32.GetLastError() ret=6c1147c5 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c1147c5 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.GetTickCount() ret=6c1145f3 08d06360:Ret kernel32.GetTickCount() retval=0001b1c6 ret=6c1145f3 08d06360:Call kernel32.ClearCommError(00000328,44536214,44536230) ret=6c1146e6 trace:comm:ClearCommError handle 808 cbInQue = 0 cbOutQue = 0 08d06360:Ret kernel32.ClearCommError() retval=00000001 ret=6c1146e6 08d06360:Call kernel32.ResetEvent(00000338) ret=6c11472d 08d06360:Ret kernel32.ResetEvent() retval=00000001 ret=6c11472d 08d06360:Call kernel32.ReadFile(00000328,4453623c,00000c80,44536208,4453621c) ret=6c11474a trace:file:ReadFile 808 0x4453623c 3200 0x44536208 0x4453621c FIXME:pthread_rwlock_rdlock FIXME:pthread_rwlock_unlock trace:file:FILE_SetDosError errno = 11 Resource temporarily unavailable 08d06360:Ret kernel32.ReadFile() retval=00000000 ret=6c11474a 08d06360:Call kernel32.GetLastError() ret=6c114754 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c114754 08d06360:Call kernel32.GetLastError() ret=6c1147c5 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c1147c5 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.GetTickCount() ret=6c1145f3 08d06360:Ret kernel32.GetTickCount() retval=0001b1c8 ret=6c1145f3 08d06360:Call kernel32.ClearCommError(00000328,44536214,44536230) ret=6c1146e6 trace:comm:ClearCommError handle 808 cbInQue = 0 cbOutQue = 0 08d06360:Ret kernel32.ClearCommError() retval=00000001 ret=6c1146e6 08d06360:Call kernel32.ResetEvent(00000338) ret=6c11472d 08d06360:Ret kernel32.ResetEvent() retval=00000001 ret=6c11472d 08d06360:Call kernel32.ReadFile(00000328,4453623c,00000c80,44536208,4453621c) ret=6c11474a trace:file:ReadFile 808 0x4453623c 3200 0x44536208 0x4453621c FIXME:pthread_rwlock_rdlock FIXME:pthread_rwlock_unlock trace:file:FILE_SetDosError errno = 11 Resource temporarily unavailable 08d06360:Ret kernel32.ReadFile() retval=00000000 ret=6c11474a 08d06360:Call kernel32.GetLastError() ret=6c114754 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c114754 08d06360:Call kernel32.GetLastError() ret=6c1147c5 08d06360:Ret kernel32.GetLastError() retval=00000020 ret=6c1147c5 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.Sleep(00000001) ret=6c1106ce 08d06360:Ret kernel32.Sleep() retval=00000102 ret=6c1106ce 08d06360:Call kernel32.GetTickCount() ret=6c1145f3 08d06360:Ret kernel32.GetTickCount() retval=0001b1cb ret=6c1145f3 08d06360:Call kernel32.ClearCommError(00000328,44536214,44536230) ret=6c1146e6 trace:comm:ClearCommError handle 808 cbInQue = 0 cbOutQue = 0 08d06360:Ret kernel32.ClearCommError() retval=00000001 ret=6c1146e6 08d06360:Call kernel32.ResetEvent(00000338) ret=6c11472d 08d06360:Ret kernel32.ResetEvent() retval=00000001 ret=6c11472d 08d06360:Call kernel32.ReadFile(00000328,4453623c,00000c80,44536208,4453621c) ret=6c11474a trace:file:ReadFile 808 0x4453623c 3200 0x44536208 0x4453621c FIXME:pthread_rwlock_rdlock FIXME:pthread_rwlock_unlock trace:file:FILE_SetDosError errno = 11 Resource temporarily unavailable