Tcl Source Code

View Ticket
Login
Ticket UUID: 734138ded8cca1906d920b837ec1cfd4bc811282
Title: close does not report error which was saved by a failing background flush (socket-14.11.1)
Type: Bug Created on: 2014-05-30 13:43:53
Submitter: oehhar Assigned to: dgp
Subsystem: 25. Channel System Severity: Minor
Priority: 5 Medium Last modified: 2014-06-03 17:47:51
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2014-06-03 17:47:51
Version: trunk
Description:

Symptom

Test socket-14.11.1 fails on Windows and on Linux with a localhost resolving to ::1 and 127.0.0.1

Issue

When a background flush (for example invoked by a reported writable fileevent) fails, the error code is saved. If this socket is closed, the error should show up.

Demo

Correct behaviour

Version [9b3b3adf47] (before commit of [bug-13d3af3ad5]) showed the IMHO correct behaviour.

Here is a log in a windows tclsh:

% set h [socket -async localhost 30001]
sock01AC6220
% fconfigure $h -blocking 0
% puts $h Hi
% flush $h
% fileevent $h writable {set ::x 1}
% vwait x
% close $h
socket is not connected
%

What happens:

  • in the first row, a socket connect on an unopened port is started (which would take on a syncroneous connect up to 10 seconds on windows to report "connection refused" so the following commands are executed while connectiong).
  • then it is set to non-blocking and a write is issued.
  • The drivers send routine is called and returns with "EWOULDBLOCK"
  • fileevent and vwait wait until the connect fails. The fileevent reporting of the driver invokes, that the tclIO will call send on the driver which will report "socket is not connected" posix error code. This is stored by tclIO
  • close is executed. The socket is correctly closed and the stored error is shown to the user.

Trunk behaviour

With the current trunk, one gets:

% set h [socket -async localhost 30001]
sock01A26150
% fconfigure $h -blocking 0
% puts $h Hi
% flush $h
% fileevent $h writable {set ::x 1}
% vwait x
% close $h
%

So, the error does not show up.

User Comments:
dgp added on 2014-05-30 15:23:08:
It would be most helpful if the demo of the issue
can be made into a portable test we can put in
the test suite to track progress fixing and not
re-breaking the issue.

dgp added on 2014-05-30 15:26:41:
Either post it here, or commit to the bug-13d3af3ad5 branch.

oehhar added on 2014-05-30 19:14:08:

The upper mentioned test "socket-14.11.1" is portable and shows the issue on Windows and Unix.

The only condition for Unix is, that localhost must resolve to ::1 and 127.0.0.1 which is normally the case.

Nevertheless this is not the case for (my) CentOS where etc/hosts is:

127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

The "6"s should not be there which breaks the test for my CentOS. Reinhard already creates a test condition for that and forgot to apply it to all relevant tests. He may do that soon.


dgp added on 2014-05-31 13:55:54:
The test failure socket-14.11.1 appears rooted
in the checkin

http://core.tcl.tk/tcl/info/84f992ce503821fd94f25acc28186e53a586afa4

dgp added on 2014-05-31 14:13:33:
see new branch bug-734138ded8

oehhar added on 2014-06-01 20:00:24:

Unfortunately, the branch does not build for me. The error is:

        cl -nologo -c -W3 -DUNICODE -D_UNICODE -QI0f -W3 -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -Fp.\Release\tcl_ThreadedDynamic\ -O2  -Ot -Oi -Op -Gs -YX -MD -I"C:\test\tcl-bug-13d3af3ad5_ipv6_win\win\..\win" -I"C:\test\tcl-bug-13d3af3ad5_ipv6_win\win\..\generic" -I"C:\test\tcl-bug-13d3af3ad5_ipv6_win\win\..\libtommath" -DTCL_TOMMATH -DMP_PREC=4 -Dinline=__inline -DHAVE_ZLIB=1 -DTCL_CFGVAL_ENCODING=\"cp1252\" -DSTDC_HEADERS -DTCL_THREADS=1 -DUSE_THREAD_ALLOC=1 -DNDEBUG -DTCL_CFG_OPTIMIZED -DNO_STRTOI64 -DBUILD_tcl -Fo.\Release\tcl_ThreadedDynamic\ @C:\Users\oehhar\AppData\Local\Temp\nm45B7.tmp
tclStubInit.c
C:\test\tcl-bug-13d3af3ad5_ipv6_win\win\..\generic\tclStubInit.c(596) : error C2152: 'initializing' : pointers to functions with different attributes
C:\test\tcl-bug-13d3af3ad5_ipv6_win\win\..\generic\tclStubInit.c(597) : error C2152: 'initializing' : pointers to functions with different attributes
C:\test\tcl-bug-13d3af3ad5_ipv6_win\win\..\generic\tclStubInit.c(601) : error C2152: 'initializing' : pointers to functions with different attributes
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

Perhaps, I may retry tomorrow with more time.


oehhar added on 2014-06-02 07:47:00:

Branch [bug-734138ded8] checkin [5f5b6fc4b2]: Test on Win Vista 32 bit with ms-vc6:

  • Manual test descriped above ok
  • All socket tests ok
  • chan-io-1.9 fails

I don't know what was wrong yesterday, now it compiles very well.

Sorry, Harald


dgp added on 2014-06-03 12:44:30:
see branch dgp-async-socket for another attempt.