Compare commits

...
Author SHA1 Message Date
dgp 582007b9da Backout failed attempt to fix [32ae34e63a]. 2015-09-25 16:32:55 +00:00
dgp d19ee21333 Remove the backport that causes stack balance panics. 2015-09-24 19:05:27 +00:00
6 changed files with 40 additions and 431 deletions
+15 -23
View File
@@ -615,7 +615,7 @@ static void DeleteExecStack(ExecStack *esPtr);
static void DupExprCodeInternalRep(Tcl_Obj *srcPtr,
Tcl_Obj *copyPtr);
static void FreeExprCodeInternalRep(Tcl_Obj *objPtr);
static ExceptionRange * GetExceptRangeForPc(unsigned char *pc, int searchMode,
static ExceptionRange * GetExceptRangeForPc(unsigned char *pc, int catchOnly,
ByteCode *codePtr);
static const char * GetSrcInfoForPc(unsigned char *pc, ByteCode *codePtr,
int *lengthPtr);
@@ -7347,7 +7347,7 @@ TclExecuteByteCode(
}
#endif
if ((result == TCL_CONTINUE) || (result == TCL_BREAK)) {
rangePtr = GetExceptRangeForPc(pc, result, codePtr);
rangePtr = GetExceptRangeForPc(pc, /*catchOnly*/ 0, codePtr);
if (rangePtr == NULL) {
TRACE_APPEND(("no encl. loop or catch, returning %s\n",
StringForResultCode(result)));
@@ -7453,7 +7453,7 @@ TclExecuteByteCode(
#endif
goto abnormalReturn;
}
rangePtr = GetExceptRangeForPc(pc, TCL_ERROR, codePtr);
rangePtr = GetExceptRangeForPc(pc, /*catchOnly*/ 1, codePtr);
if (rangePtr == NULL) {
/*
* This is only possible when compiling a [catch] that sends its
@@ -7944,14 +7944,13 @@ GetSrcInfoForPc(
* ExceptionRange.
*
* Results:
* If the searchMode is TCL_ERROR, this procedure ignores loop exception
* ranges and returns a pointer to the closest catch range. If the
* searchMode is TCL_BREAK, this procedure returns a pointer to the most
* closely enclosing ExceptionRange regardless of whether it is a loop or
* catch exception range. If the searchMode is TCL_CONTINUE, this
* procedure returns a pointer to the most closely enclosing
* ExceptionRange (of any type) skipping only loop exception ranges if
* they don't have a sensible continueOffset defined. If no matching
* In the normal case, catchOnly is 0 (false) and this procedure returns
* a pointer to the most closely enclosing ExceptionRange structure
* regardless of whether it is a loop or catch exception range. This is
* appropriate when processing a TCL_BREAK or TCL_CONTINUE, which will be
* "handled" either by a loop exception range or a closer catch range. If
* catchOnly is nonzero, this procedure ignores loop exception ranges and
* returns a pointer to the closest catch range. If no matching
* ExceptionRange is found that encloses pc, a NULL is returned.
*
* Side effects:
@@ -7966,12 +7965,10 @@ GetExceptRangeForPc(
* search for a closest enclosing exception
* range. This points to a bytecode
* instruction in codePtr's code. */
int searchMode, /* If TCL_BREAK, consider either loop or catch
* ExceptionRanges in search. If TCL_ERROR
int catchOnly, /* If 0, consider either loop or catch
* ExceptionRanges in search. If nonzero
* consider only catch ranges (and ignore any
* closer loop ranges). If TCL_CONTINUE, look
* for loop ranges that define a continue
* point or a catch range. */
* closer loop ranges). */
ByteCode *codePtr) /* Points to the ByteCode in which to search
* for the enclosing ExceptionRange. */
{
@@ -7997,13 +7994,8 @@ GetExceptRangeForPc(
start = rangePtr->codeOffset;
if ((start <= pcOffset) &&
(pcOffset < (start + rangePtr->numCodeBytes))) {
if (rangePtr->type == CATCH_EXCEPTION_RANGE) {
return rangePtr;
}
if (searchMode == TCL_BREAK) {
return rangePtr;
}
if (searchMode == TCL_CONTINUE && rangePtr->continueOffset != -1){
if ((!catchOnly)
|| (rangePtr->type == CATCH_EXCEPTION_RANGE)) {
return rangePtr;
}
}
+4 -43
View File
@@ -113,30 +113,11 @@ typedef struct CopyState {
Tcl_WideInt total; /* Total bytes transferred (written). */
Tcl_Interp *interp; /* Interp that started the copy. */
Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */
int refCount; /* Claim count on the struct */
int bufInUse; /* Flag to govern access to buffer */
int bufSize; /* Size of appended buffer. */
char buffer[1]; /* Copy buffer, this must be the last
* field. */
} CopyState;
static void
PreserveCopyState(
CopyState *csPtr)
{
csPtr->refCount++;
}
static void
ReleaseCopyState(
CopyState *csPtr)
{
if (--csPtr->refCount) {
return;
}
ckfree((char *) csPtr);
}
/*
* All static variables used in this file are collected into a single instance
* of the following structure. For multi-threaded implementations, there is
@@ -8668,13 +8649,9 @@ TclCopyChannel(
Tcl_IncrRefCount(cmdPtr);
}
csPtr->cmdPtr = cmdPtr;
csPtr->refCount = 1;
csPtr->bufInUse = 0;
inStatePtr->csPtrR = csPtr;
PreserveCopyState(csPtr);
outStatePtr->csPtrW = csPtr;
PreserveCopyState(csPtr);
/*
* Special handling of -size 0 async transfers, so that the -command is
@@ -8726,11 +8703,6 @@ CopyData(
/* Encoding control */
int underflow; /* Input underflow */
if (csPtr->bufInUse) {
return TCL_OK;
}
PreserveCopyState(csPtr);
inChan = (Tcl_Channel) csPtr->readPtr;
outChan = (Tcl_Channel) csPtr->writePtr;
inStatePtr = csPtr->readPtr->state;
@@ -8792,7 +8764,6 @@ CopyData(
sizeb = csPtr->toRead;
}
csPtr->bufInUse = 1;
if (inBinary || sameEncoding) {
size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb);
} else {
@@ -8843,7 +8814,6 @@ CopyData(
TclDecrRefCount(bufObj);
bufObj = NULL;
}
ReleaseCopyState(csPtr);
return TCL_OK;
}
}
@@ -8864,7 +8834,6 @@ CopyData(
} else {
sizeb = WriteChars(outStatePtr->topChanPtr, buffer, sizeb);
}
csPtr->bufInUse = 0;
/*
* [Bug 2895565]. At this point 'size' still contains the number of
@@ -8936,7 +8905,6 @@ CopyData(
TclDecrRefCount(bufObj);
bufObj = NULL;
}
ReleaseCopyState(csPtr);
return TCL_OK;
}
@@ -8959,7 +8927,6 @@ CopyData(
TclDecrRefCount(bufObj);
bufObj = NULL;
}
ReleaseCopyState(csPtr);
return TCL_OK;
}
} /* while */
@@ -8975,14 +8942,15 @@ CopyData(
*/
total = csPtr->total;
if (cmdPtr && interp && csPtr->cmdPtr) {
if (cmdPtr && interp) {
int code;
/*
* Get a private copy of the command so we can mutate it by adding
* arguments. Note that StopCopy frees our saved reference to the
* original command obj.
*/
cmdPtr = Tcl_DuplicateObj(csPtr->cmdPtr);
cmdPtr = Tcl_DuplicateObj(cmdPtr);
Tcl_IncrRefCount(cmdPtr);
StopCopy(csPtr);
Tcl_Preserve(interp);
@@ -9010,7 +8978,6 @@ CopyData(
}
}
}
ReleaseCopyState(csPtr);
return result;
}
@@ -9324,16 +9291,10 @@ StopCopy(
CopyEventProc, csPtr);
}
TclDecrRefCount(csPtr->cmdPtr);
csPtr->cmdPtr = NULL;
}
if (inStatePtr->csPtrR == NULL) {
return;
}
ReleaseCopyState(inStatePtr->csPtrR);
inStatePtr->csPtrR = NULL;
ReleaseCopyState(outStatePtr->csPtrW);
outStatePtr->csPtrW = NULL;
ReleaseCopyState(csPtr);
ckfree((char *) csPtr);
}
/*
+8
View File
@@ -1508,6 +1508,14 @@ ReflectWatch(
mask &= rcPtr->mode;
if (mask == rcPtr->interest) {
/*
* Same old, same old, why should we do something?
*/
return;
}
rcPtr->interest = mask;
/*
-166
View File
@@ -811,172 +811,6 @@ test for-6.18 {Tcl_ForObjCmd: for command result} {
1 {invoked "continue" outside of a loop} \
]
test for-8.0 {Coverity CID 1251203: break vs continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i; list a [eval {}]} {
incr j
}]
incr i
}
list $i $j $k
}}
} {6 5 3}
test for-8.1 {Coverity CID 1251203: break vs continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i;list a [eval break]} {
incr j
}]
incr i
}
list $i $j $k
}}
} {2 1 3}
test for-8.2 {Coverity CID 1251203: break vs continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i;list a [eval continue]} {
incr j
}]
incr i
}
list $i $j $k
}}
} {1 1 3}
test for-8.3 {break in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i; break} {
incr j
}]
incr i
}
list $i $j $k
}}
} {2 1 3}
test for-8.4 {continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i; continue} {
incr j
}]
incr i
}
list $i $j $k
}}
} {1 1 3}
test for-8.5 {break in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i; list a [break]} {
incr j
}]
incr i
}
list $i $j $k
}}
} {2 1 3}
test for-8.6 {continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i; list a [continue]} {
incr j
}]
incr i
}
list $i $j $k
}}
} {1 1 3}
test for-8.7 {break in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i;eval break} {
incr j
}]
incr i
}
list $i $j $k
}}
} {2 1 3}
test for-8.8 {continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
list a [\
for {set i 0} {$i < 5} {incr i;eval continue} {
incr j
}]
incr i
}
list $i $j $k
}}
} {1 1 3}
test for-8.9 {break in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
for {set i 0} {$i < 5} {incr i;eval break} {
incr j
}
incr i
}
list $i $j $k
}}
} {2 1 3}
test for-8.10 {continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
for {set i 0} {$i < 5} {incr i;eval continue} {
incr j
}
incr i
}
list $i $j $k
}}
} {1 1 3}
test for-8.11 {break in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
for {set i 0} {$i < 5} {incr i;break} {
incr j
}
incr i
}
list $i $j $k
}}
} {2 1 3}
test for-8.12 {continue in for-step clause} {
apply {{} {
for {set k 0} {$k < 3} {incr k} {
set j 0
for {set i 0} {$i < 5} {incr i;continue} {
incr j
}
incr i
}
list $i $j $k
}}
} {1 1 3}
# cleanup
::tcltest::cleanupTests
-186
View File
@@ -7886,192 +7886,6 @@ test io-53.15 {[ed29c4da21] DoRead: fblocked seen as error} -setup {
removeFile out
} -result 100
test io-53.18 {[32ae34e63a] recursive CopyData} -setup {
proc driver {cmd args} {
variable buffer
variable index
set chan [lindex $args 0]
switch -- $cmd {
initialize {
set index($chan) 0
set buffer($chan) [encoding convertto utf-8 \
[string repeat a 100]]
return {initialize finalize watch read}
}
finalize {
unset index($chan) buffer($chan)
return
}
watch {
if {"read" in [lindex $args 1]} {
chan postevent $chan read
}
return
}
read {
set n [lindex $args 1]
set new [expr {$index($chan) + $n}]
set result [string range $buffer($chan) $index($chan) $new-1]
set index($chan) $new
return $result
}
}
}
proc more {c outChan bytes args} {
if {[eof $c]} {
set ::done eof
catch {close $c}
return
}
if {[llength $args]} {
set ::done error
} else {
chan copy $c $outChan -command [list [namespace which more] $c $outChan]
}
}
set c [chan create read [namespace which driver]]
chan configure $c -encoding utf-8
set out [makeFile {} out]
set outChan [open $out w]
# Different encoding to force use of DoReadChars()
chan configure $outChan -encoding iso8859-1
} -body {
after 100 {set ::done timeout}
chan copy $c $outChan -size 99 -command [list [namespace which more] $c $outChan]
vwait ::done
set ::done
} -cleanup {
close $outChan
removeFile out
rename driver {}
rename more {}
unset ::done
} -result eof
test io-53.19 {[32ae34e63a] stop ReflectWatch filtering} -setup {
proc driver {cmd args} {
variable buffer
variable index
set chan [lindex $args 0]
switch -- $cmd {
initialize {
set index($chan) 0
set buffer($chan) [encoding convertto utf-8 \
[string repeat a 100]]
return {initialize finalize watch read}
}
finalize {
unset index($chan) buffer($chan)
return
}
watch {
if {"read" in [lindex $args 1]} {
chan postevent $chan read
}
return
}
read {
set n [lindex $args 1]
set new [expr {$index($chan) + $n}]
set result [string range $buffer($chan) $index($chan) $new-1]
set index($chan) $new
return $result
}
}
}
proc more {c outChan bytes args} {
if {[eof $c]} {
set ::done eof
catch {close $c}
return
}
if {[llength $args]} {
set ::done error
} else {
chan copy $c $outChan -size 30 -command [list [namespace which more] $c $outChan]
}
}
set c [chan create read [namespace which driver]]
chan configure $c -encoding utf-8 -buffersize 20
set out [makeFile {} out]
set outChan [open $out w]
# Different encoding to force use of DoReadChars()
chan configure $outChan -encoding iso8859-1
} -body {
after 100 {set ::done timeout}
chan copy $c $outChan -size 30 -command [list [namespace which more] $c $outChan]
vwait ::done
set ::done
} -cleanup {
catch {close $outChan}
removeFile out
rename driver {}
rename more {}
unset ::done
} -result eof
test io-53.20 {[e0a7b3e5f8] DoRead calls to UpdateInterest} -setup {
proc driver {cmd args} {
variable buffer
variable index
set chan [lindex $args 0]
switch -- $cmd {
initialize {
set index($chan) 0
set buffer($chan) [encoding convertto utf-8 \
[string repeat a 100]]
return {initialize finalize watch read}
}
finalize {
unset index($chan) buffer($chan)
return
}
watch {
if {"read" in [lindex $args 1]} {
chan postevent $chan read
}
return
}
read {
set n [lindex $args 1]
set new [expr {$index($chan) + $n}]
set result [string range $buffer($chan) $index($chan) $new-1]
set index($chan) $new
return $result
}
}
}
proc more {c outChan bytes args} {
if {[eof $c]} {
set ::done eof
catch {close $c}
return
}
if {[llength $args]} {
set ::done error
} else {
chan copy $c $outChan -size 10 -command [list [namespace which more] $c $outChan]
}
}
set c [chan create read [namespace which driver]]
chan configure $c -encoding utf-8 -buffersize 20
set out [makeFile {} out]
set outChan [open $out w]
# Same encoding to force use of DoRead()
chan configure $outChan -encoding utf-8
} -body {
after 100 {set ::done timeout}
chan copy $c $outChan -size 10 -command [list [namespace which more] $c $outChan]
vwait ::done
set ::done
} -cleanup {
catch {close $outChan}
removeFile out
rename driver {}
rename more {}
unset ::done
} -result eof
test io-54.1 {Recursive channel events} {socket fileevent} {
# This test checks to see if file events are delivered during recursive
# event loops when there is buffered data on the channel.
+13 -13
View File
@@ -981,7 +981,7 @@ test iocmd-23.1 {chan read, regular data return} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {read rc* 4096} {watch rc* {}} snarfsnarf}
} -result {{read rc* 4096} {read rc* 4096} snarfsnarf}
test iocmd-23.2 {chan read, bad data return, to much} -match glob -body {
set res {}
proc foo {args} {
@@ -993,7 +993,7 @@ test iocmd-23.2 {chan read, bad data return, to much} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {watch rc* {}} 1 {read delivered more than requested}}
} -result {{read rc* 4096} 1 {read delivered more than requested}}
test iocmd-23.3 {chan read, for non-readable channel} -match glob -body {
set res {}
proc foo {args} {
@@ -1016,7 +1016,7 @@ test iocmd-23.4 {chan read, error return} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {watch rc* {}} 1 BOOM!}
} -result {{read rc* 4096} 1 BOOM!}
test iocmd-23.5 {chan read, break return is error} -match glob -body {
set res {}
proc foo {args} {
@@ -1028,7 +1028,7 @@ test iocmd-23.5 {chan read, break return is error} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {watch rc* {}} 1 *bad code*}
} -result {{read rc* 4096} 1 *bad code*}
test iocmd-23.6 {chan read, continue return is error} -match glob -body {
set res {}
proc foo {args} {
@@ -1040,7 +1040,7 @@ test iocmd-23.6 {chan read, continue return is error} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {watch rc* {}} 1 *bad code*}
} -result {{read rc* 4096} 1 *bad code*}
test iocmd-23.7 {chan read, custom return is error} -match glob -body {
set res {}
proc foo {args} {
@@ -1052,7 +1052,7 @@ test iocmd-23.7 {chan read, custom return is error} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {watch rc* {}} 1 *bad code*}
} -result {{read rc* 4096} 1 *bad code*}
test iocmd-23.8 {chan read, level is squashed} -match glob -body {
set res {}
proc foo {args} {
@@ -1064,7 +1064,7 @@ test iocmd-23.8 {chan read, level is squashed} -match glob -body {
close $c
rename foo {}
set res
} -result {{read rc* 4096} {watch rc* {}} 1 *bad code* {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo *bad code*subcommand "read"*}}
} -result {{read rc* 4096} 1 *bad code* {-code 1 -level 0 -errorcode NONE -errorline 1 -errorinfo *bad code*subcommand "read"*}}
test iocmd-23.9 {chan read, no data means eof} -match glob -setup {
set res {}
proc foo {args} {
@@ -1080,7 +1080,7 @@ test iocmd-23.9 {chan read, no data means eof} -match glob -setup {
close $c
rename foo {}
unset res
} -result {{read rc* 4096} {watch rc* {}} {} 1}
} -result {{read rc* 4096} {} 1}
test iocmd-23.10 {chan read, EAGAIN means no data, yet no eof either} -match glob -setup {
set res {}
proc foo {args} {
@@ -1096,7 +1096,7 @@ test iocmd-23.10 {chan read, EAGAIN means no data, yet no eof either} -match glo
close $c
rename foo {}
unset res
} -result {{read rc* 4096} {watch rc* {}} {} 0}
} -result {{read rc* 4096} {} 0}
test iocmd-23.11 {chan read, close pulls the rug out} -match glob -body {
set res {}
proc foo {args} {
@@ -1410,14 +1410,14 @@ test iocmd-25.10 {chan configure, cgetall, level is ignored} -match glob -body {
test iocmd-26.1 {chan configure, set standard option} -match glob -body {
set res {}
proc foo {args} {
oninit configure; onfinal; track; return
oninit configure; onfinal; track; note MUST_NOT_HAPPEN; return
}
set c [chan create {r w} foo]
note [fconfigure $c -translation lf]
close $c
rename foo {}
set res
} -result {{watch rc* {}} {}}
} -result {{}}
test iocmd-26.2 {chan configure, set option, error return} -match glob -body {
set res {}
proc foo {args} {
@@ -1955,7 +1955,7 @@ test iocmd-31.6 {chan postevent, posted events do happen} -match glob -body {
close $c
rename foo {}
set res
} -result {{watch rc* read} {} TOCK {watch rc* read} {} {watch rc* {}}}
} -result {{watch rc* read} {} TOCK {} {watch rc* {}}}
test iocmd-31.7 {chan postevent, posted events do happen} -match glob -body {
set res {}
proc foo {args} {oninit; onfinal; track; return}
@@ -1968,7 +1968,7 @@ test iocmd-31.7 {chan postevent, posted events do happen} -match glob -body {
close $c
rename foo {}
set res
} -result {{watch rc* write} {} TOCK {watch rc* write} {} {watch rc* {}}}
} -result {{watch rc* write} {} TOCK {} {watch rc* {}}}
test iocmd-31.8 {chan postevent after close throws error} -match glob -setup {
proc foo {args} {oninit; onfinal; track; return}
proc dummy args { return }