Overview
| Artifact ID: | 23e2517acb32add185eecc9ed884087df4587225 |
|---|---|
| Ticket: | 3545365fffffffffffffffffffffffffffffffff
Crash in io-29.33b (no implicit flush of nonblocking on exit |
| User & Date: | twylite on 2012-07-24 21:20:52 |
Changes
- icomment:
Okay, sources reverted, full rebuild, and full retest (32-bit Tcl on Windows 7 64-bit, built with MSVC10). I have made 3 changes to trunk: (1) Merge bug-3545363 and apply my diff (attached to that bug). Testers on Win7 or WinXP+IPv6 are not going to be able to run the full io.test without doing this. (2) TclpCloseFile() _before_ shutting down the PipeWriterThread (3) Close stdio channels if TclInExit() in TclpCloseFile(). Result: indeterminate. io-29.33b passes on its own, io.test passes on its own, io-29.33b occasionally fails when the entire test suite is executed. I don't have more clarity on the "occasionally" at the moment - trying to reproduce the problem. Caution: with this change PipeClose2Proc becomes non-blocking on exit, even on a blocking channel. If a blocking write is happening in one interp, a different thread that is exiting as part of the Tcl shutdown rip the channel away and close it. --- tclWinPipe.c +++ tclWinPipe.c @@ -820,11 +820,11 @@ * Don't close the Win32 handle if the handle is a standard channel * during the thread exit process. Otherwise, one thread may kill the * stdio of another. */ - if (!TclInThreadExit() + if (TclInExit() || !TclInThreadExit() || ((GetStdHandle(STD_INPUT_HANDLE) != filePtr->handle) && (GetStdHandle(STD_OUTPUT_HANDLE) != filePtr->handle) && (GetStdHandle(STD_ERROR_HANDLE) != filePtr->handle))) { if (filePtr->handle != NULL && CloseHandle(filePtr->handle) == FALSE) { @@ -1871,10 +1871,15 @@ pipePtr->validMask &= ~TCL_READABLE; pipePtr->readFile = NULL; } if ((!flags || flags & TCL_CLOSE_WRITE) && (pipePtr->writeFile != NULL)) { + if (TclpCloseFile(pipePtr->writeFile) != 0) { + if (errorCode == 0) { + errorCode = errno; + } + } if (pipePtr->writeThread) { /* * Wait for the writer thread to finish the current buffer, then * terminate the thread and close the handles. If the channel is * nonblocking, there should be no pending write operations. @@ -1931,15 +1936,10 @@ CloseHandle(pipePtr->writable); CloseHandle(pipePtr->startWriter); CloseHandle(pipePtr->stopWriter); pipePtr->writeThread = NULL; } - if (TclpCloseFile(pipePtr->writeFile) != 0) { - if (errorCode == 0) { - errorCode = errno; - } - } pipePtr->validMask &= ~TCL_WRITABLE; pipePtr->writeFile = NULL; } pipePtr->watchMask &= pipePtr->validMask; - login: "twylite"
- mimetype: "text/plain"
- username: "twylite"