From a3fc75697c61b4a4eb8910367bf6ebec7e87e779 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 8 Feb 2013 14:07:10 +0000 Subject: characterize bug --- tests/oo.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/oo.test b/tests/oo.test index 5d34077..49fe150 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -2204,6 +2204,25 @@ test oo-19.2 {OO: varname method: Bug 2883857} -setup { } -cleanup { SpecialClass destroy } -result ::oo_test::x(y) +test oo-19.3 {OO: varname method and variable decl: Bug 3603695} -setup { + oo::class create testClass { + variable foo + export varname + constructor {} { + variable foo x + } + method bar {obj} { + my varname foo + $obj varname foo + } + } +} -body { + testClass create A + testClass create B + lsearch [list [A varname foo] [B varname foo]] [B bar A] +} -cleanup { + testClass destroy +} -result 0 test oo-20.1 {OO: variable method} -body { oo::class create testClass { -- cgit v0.12 From fbadf81dac9faf5906086942ecb64e4c644b3038 Mon Sep 17 00:00:00 2001 From: dkf Date: Sat, 9 Feb 2013 12:25:36 +0000 Subject: Apply a fix for the bug. Passes the test suite now. --- generic/tclOOBasic.c | 55 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index 0676618..f8cd1a4 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -687,52 +687,51 @@ TclOO_Object_VarName( int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* The actual arguments. */ { - Interp *iPtr = (Interp *) interp; Var *varPtr, *aryVar; - Tcl_Obj *varNamePtr; + Tcl_Obj *varNamePtr, *argPtr; + const char *arg; if (Tcl_ObjectContextSkippedArgs(context)+1 != objc) { Tcl_WrongNumArgs(interp, Tcl_ObjectContextSkippedArgs(context), objv, "varName"); return TCL_ERROR; } + argPtr = objv[objc-1]; + arg = Tcl_GetString(argPtr); /* - * Switch to the object's namespace for the duration of this call. Like - * this, the variable is looked up in the namespace of the object, and not - * in the namespace of the caller. Otherwise this would only work if the - * caller was a method of the object itself, which might not be true if - * the method was exported. This is a bit of a hack, but the simplest way - * to do this (pushing a stack frame would be horribly expensive by - * comparison, and is only done when we'd otherwise interfere with the - * global namespace). + * Convert the variable name to fully-qualified form if it wasn't already. + * This has to be done prior to lookup because we can run into problems + * with resolvers otherwise. [Bug 3603695] + * + * We still need to do the lookup; the variable could be linked to another + * variable and we want the target's name. */ - if (iPtr->varFramePtr == NULL) { - Tcl_CallFrame *dummyFrame; - - TclPushStackFrame(interp, &dummyFrame, - Tcl_GetObjectNamespace(Tcl_ObjectContextObject(context)),0); - varPtr = TclObjLookupVar(interp, objv[objc-1], NULL, - TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG, "refer to",1,1,&aryVar); - TclPopStackFrame(interp); + if (arg[0] == ':' && arg[1] == ':') { + varNamePtr = argPtr; } else { - Namespace *savedNsPtr; - - savedNsPtr = iPtr->varFramePtr->nsPtr; - iPtr->varFramePtr->nsPtr = (Namespace *) + Tcl_Namespace *namespacePtr = Tcl_GetObjectNamespace(Tcl_ObjectContextObject(context)); - varPtr = TclObjLookupVar(interp, objv[objc-1], NULL, - TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG, "refer to",1,1,&aryVar); - iPtr->varFramePtr->nsPtr = savedNsPtr; - } + varNamePtr = Tcl_NewStringObj(namespacePtr->fullName, -1); + Tcl_AppendToObj(varNamePtr, "::", 2); + Tcl_AppendObjToObj(varNamePtr, argPtr); + } + Tcl_IncrRefCount(varNamePtr); + varPtr = TclObjLookupVar(interp, varNamePtr, NULL, + TCL_NAMESPACE_ONLY|TCL_LEAVE_ERR_MSG, "refer to", 1, 1, &aryVar); + Tcl_DecrRefCount(varNamePtr); if (varPtr == NULL) { - Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARIABLE", - TclGetString(objv[objc-1]), NULL); + Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "VARIABLE", arg, NULL); return TCL_ERROR; } + /* + * Now that we've pinned down what variable we're really talking about + * (including traversing variable links), convert back to a name. + */ + varNamePtr = Tcl_NewObj(); if (aryVar != NULL) { Tcl_HashEntry *hPtr; -- cgit v0.12 From 94561c377266d0a78fa2eadbeeaa4145a2cd9dd6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 10 Feb 2013 13:12:20 +0000 Subject: Unbreak msvc builds, by depending on tclPort.h for inclusion of . --- generic/tclCmdAH.c | 1 - generic/tclEncoding.c | 1 - generic/tclFCmd.c | 6 ------ generic/tclFileName.c | 1 - generic/tclIOUtil.c | 1 - generic/tclTest.c | 6 ------ macosx/tclMacOSXFCmd.c | 1 - unix/tclUnixFCmd.c | 1 - unix/tclUnixFile.c | 1 - unix/tclUnixInit.c | 1 - win/tclWinConsole.c | 1 - win/tclWinFile.c | 1 - win/tclWinPipe.c | 2 -- win/tclWinSerial.c | 2 -- win/tclWinThrd.c | 1 - 15 files changed, 27 deletions(-) diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 9b03eab..44f08a3 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -11,7 +11,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclInt.h" #include diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 4a2c5f0..c2f1b4b 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -9,7 +9,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclInt.h" typedef size_t (LengthProc)(const char *src); diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index 2a579c6..c59fb54 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -10,12 +10,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#ifndef _WIN64 -/* See [Bug 3354324]: file mtime sets wrong time */ -# define _USE_32BIT_TIME_T -#endif - -#include #include "tclInt.h" /* diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 0f32d2b..07757d9 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -11,7 +11,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclInt.h" #include "tclRegexp.h" #include "tclFileSystem.h" /* For TclGetPathType() */ diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 488cbb8..295e313 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -18,7 +18,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclInt.h" #ifdef __WIN32__ # include "tclWinInt.h" diff --git a/generic/tclTest.c b/generic/tclTest.c index a96785a..1ba73e7 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -15,13 +15,7 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#ifndef _WIN64 -/* See [Bug 3354324]: file mtime sets wrong time */ -# define _USE_32BIT_TIME_T -#endif - #define TCL_TEST -#include #include "tclInt.h" #include diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c index fb64bb6..dce15fc 100644 --- a/macosx/tclMacOSXFCmd.c +++ b/macosx/tclMacOSXFCmd.c @@ -10,7 +10,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclInt.h" #ifdef HAVE_GETATTRLIST diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index d655990..b5450b1 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -40,7 +40,6 @@ * DAMAGE. */ -#include #include "tclInt.h" #include #include diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 5abac9d..29f1aba 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -10,7 +10,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclInt.h" #include "tclFileSystem.h" diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 8ebd069..f9015b7 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -8,7 +8,6 @@ * All rights reserved. */ -#include #include "tclInt.h" #include #include diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index ea295fe..361fb3d 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -14,7 +14,6 @@ #include #include -#include /* * The following variable is used to tell whether this module has been diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 5717a3f..3817fa4 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -12,7 +12,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include #include "tclWinInt.h" #include "tclFileSystem.h" #include diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index b6764d4..ee088a5 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -12,8 +12,6 @@ #include "tclWinInt.h" -#include - /* * The following variable is used to tell whether this module has been * initialized. diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 62eafda..d5244ac 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -14,8 +14,6 @@ #include "tclWinInt.h" -#include - /* * The following variable is used to tell whether this module has been * initialized. diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 50e8ace..2413a78 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -13,7 +13,6 @@ #include "tclWinInt.h" #include -#include /* Workaround for mingw versions which don't provide this in float.h */ #ifndef _MCW_EM -- cgit v0.12 From 5245e701247fd4691c197151b9551c65e2af0213 Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 11 Feb 2013 08:11:28 +0000 Subject: [Bug 3603553]: Ensure that data gets written to the underlying stream by compressing transforms when the amount of data to be written is one buffer's-worth; problem was particularly likely to occur when compressing large quantities of not-very-compressible data. Many thanks to Piera Poggio (vampiera) for reporting. --- ChangeLog | 9 +++++++++ generic/tclZlib.c | 2 +- tests/zlib.test | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 743c571..64d80c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-02-11 Donal K. Fellows + + * generic/tclZlib.c (ZlibTransformOutput): [Bug 3603553]: Ensure that + data gets written to the underlying stream by compressing transforms + when the amount of data to be written is one buffer's-worth; problem + was particularly likely to occur when compressing large quantities of + not-very-compressible data. Many thanks to Piera Poggio (vampiera) for + reporting. + 2013-02-09 Donal K. Fellows * generic/tclOOBasic.c (TclOO_Object_VarName): [Bug 3603695]: Change diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 47091de..ff887c8 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -3111,7 +3111,7 @@ ZlibTransformOutput( e = deflate(&cd->outStream, Z_NO_FLUSH); produced = cd->outAllocated - cd->outStream.avail_out; - if (e == Z_OK && cd->outStream.avail_out > 0) { + if (e == Z_OK && produced > 0) { if (Tcl_WriteRaw(cd->parent, cd->outBuffer, produced) < 0) { *errorCodePtr = Tcl_GetErrno(); return -1; diff --git a/tests/zlib.test b/tests/zlib.test index 891dba0..96914ca 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -366,6 +366,25 @@ test zlib-8.15 {transformtion and fconfigure} -setup { catch {close $inSide} catch {$strm close} } -result {358 358} +test zlib-8.16 {Bug 3603553: buffer transfer with large writes} -setup { + # Actual data isn't very important; needs to be substantially larger than + # the internal buffer (8kB) and incompressible. + set largeData {} + for {set i 0;expr srand(1)} {$i < 100000} {incr i} { + append largeData [lindex "a b c d e f g h i j k l m n o p" \ + [expr {int(16*rand())}]] + } + set file [makeFile {} test.gz] +} -constraints zlib -body { + set f [open $file wb] + fconfigure $f -buffering none + zlib push gzip $f + puts -nonewline $f $largeData + close $f + file size $file +} -cleanup { + removeFile $file +} -result 57647 test zlib-9.1 "check fcopy with push" -constraints zlib -setup { set sfile [makeFile {} testsrc.gz] -- cgit v0.12 From c42232d2a15a091543947a08d7d45379d19bbfb4 Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 11 Feb 2013 08:54:09 +0000 Subject: Correction to comment in re key buffer size. --- tests/zlib.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zlib.test b/tests/zlib.test index 96914ca..c469eea 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -368,7 +368,7 @@ test zlib-8.15 {transformtion and fconfigure} -setup { } -result {358 358} test zlib-8.16 {Bug 3603553: buffer transfer with large writes} -setup { # Actual data isn't very important; needs to be substantially larger than - # the internal buffer (8kB) and incompressible. + # the internal buffer (32kB) and incompressible. set largeData {} for {set i 0;expr srand(1)} {$i < 100000} {incr i} { append largeData [lindex "a b c d e f g h i j k l m n o p" \ -- cgit v0.12