From 4aab3a8c321f05ae8af6a39d0ef6a769fb3f70be Mon Sep 17 00:00:00 2001 From: das Date: Wed, 2 Aug 2006 20:04:11 +0000 Subject: * unix/tclUnixPipe.c (TclpCreateProcess): for USE_VFORK: ensure standard channels are initialized before vfork() so that the child doesn't potentially corrupt global state in the parent's address space. --- ChangeLog | 20 ++++++++++++++++++-- unix/tclUnixPipe.c | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2846f73..6100c06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,26 @@ +2006-08-03 Daniel Steffen + + * unix/tclUnixPipe.c (TclpCreateProcess): for USE_VFORK: ensure standard + channels are initialized before vfork() so that the child doesn't + potentially corrupt global state in the parent's address space. + + * tests/compExpr-old.test: add 'oldExprParser' constraint to all tests + * tests/compExpr.test: that depend on the exact format of the error + * tests/compile.test: messages of the pre-2006-07-05 expression + * tests/expr-old.test: parser. The constraint is on by default (i.e. + * tests/expr.test: those test still fail), but it can be turned + * tests/for.test: off by passing '-constraints newExprParser' + * tests/if.test: to tcltest, which will skip the 196 failing + * tests/parseExpr.test: tests in the testsuite that are caused by + * tests/while.test: the new expression parser error messages. + 2006-07-31 Kevin Kenny * generic/tclClock.c (ConvertLocalToUTCUsingC): Corrected a regression that caused dates before 1969 to be one day off in the :localtime time zone if TZ is not set. [Bug 1531530] - + 2006-07-30 Kevin Kenny * generic/tclClock.c (GetJulianDayFromEraYearMonthDay): @@ -44,7 +60,7 @@ * generic/tclExecute.c: * tests/execute.test (execute-9.1): dgp's fix for [Bug 1522803]. -2006-07-20 Daniel Steffen +2006-07-20 Daniel Steffen * macosx/tclMacOSXNotify.c (Tcl_InitNotifier, Tcl_WaitForEvent): create notifier thread lazily upon first call to Tcl_WaitForEvent() rather than diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 8a20bcc..c177f67 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.34 2006/07/20 06:17:39 das Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.35 2006/08/02 20:04:11 das Exp $ */ #include "tclInt.h" @@ -428,6 +428,23 @@ TclpCreateProcess( newArgv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]); } +#ifdef USE_VFORK + /* + * After vfork(), do not call code in the child that changes global state, + * because it is using the parent's memory space at that point and writes + * might corrupt the parent: so ensure standard channels are initialized in + * the parent, otherwise SetupStdFile() might initialize them in the child. + */ + if (!inputFile) { + Tcl_GetStdChannel(TCL_STDIN); + } + if (!outputFile) { + Tcl_GetStdChannel(TCL_STDOUT); + } + if (!errorFile) { + Tcl_GetStdChannel(TCL_STDERR); + } +#endif pid = fork(); if (pid == 0) { int joinThisError = errorFile && (errorFile == outputFile); -- cgit v0.12