Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-23
02:53 • Ticket [218820ffff] failure accessing local variables status still Closed wi... artifact: 0c24df6552 user: dgp
2000-10-26
08:29 • Closed ticket [218820ffff]. artifact: 8cceb11136 user: welch
01:05 • New ticket [218820ffff]. artifact: ee15399dee user: nobody

failure accessing local variables

Closed / Fixed218820ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:05:57
OriginalBugID: 2243 Bug
Version: 8.1.1
SubmitDate: '1999-06-16'
LastModified: '1999-07-01'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: foster
OS: Other
OSVersion: WinNT, AIX, Solaris, Linux
Machine: NA
FixedDate: '1999-06-16'
FixedInVersion: 8.2b1
ClosedDate: '2000-10-25'


Name:

Borivoj Tydlitat



CustomShell:

No



ReproducibleScript:

We observed the behavior in a fairly complex script only and were not

    able to reproduce it in a short one due to nature of the problem. This

    the relevant fragment:

    

    set drat [lindex $seg 0]

    if {[info exists drat]} {

    puts "should print drat because it exists"

        puts "after, drat=$drat"

    } else {

       puts "really bad, drat doesn't exist"

    }

    

    Output:

    should print drat because it exists

    can't read "": no such variable

    

    Our analysis:

    If INSTR_LOAD_SCALAR1 bytecode is generated with argument byte > 0x7F,

    the interpreter treats this argument as signed value, resulting in

    negative

    localIndex passed to TclGetIndexedScalar, which fails or returns invalid

    pointer.



ObservedBehavior:

Local variable seems not to exist, though it was created. 

    Occurs in a complex script only.



Patch:

*** tclExecute.old      Wed Jun 16 14:34:27 1999

--- tclExecute.c        Wed Jun 16 13:55:49 1999

***************

*** 1052,1058 ****



        case INST_LOAD_SCALAR1:

  #ifdef TCL_COMPILE_DEBUG

!           opnd = TclGetInt1AtPtr(pc+1);

            DECACHE_STACK_INFO();

            valuePtr = TclGetIndexedScalar(interp, opnd,

                    /*leaveErrorMsg*/ 1);

--- 1052,1058 ----



        case INST_LOAD_SCALAR1:

  #ifdef TCL_COMPILE_DEBUG

!           opnd = TclGetUInt1AtPtr(pc+1);

            DECACHE_STACK_INFO();

            valuePtr = TclGetIndexedScalar(interp, opnd,

                    /*leaveErrorMsg*/ 1);

***************

*** 1067,1073 ****

            TRACE_WITH_OBJ(("%u => ", opnd), valuePtr);

  #else /* TCL_COMPILE_DEBUG */

            DECACHE_STACK_INFO();

!           valuePtr = TclGetIndexedScalar(interp, TclGetInt1AtPtr(pc+1),

                    /*leaveErrorMsg*/ 1);

            CACHE_STACK_INFO();

            if (valuePtr == NULL) {

--- 1067,1073 ----

            TRACE_WITH_OBJ(("%u => ", opnd), valuePtr);

  #else /* TCL_COMPILE_DEBUG */

            DECACHE_STACK_INFO();

!           valuePtr = TclGetIndexedScalar(interp, TclGetUInt1AtPtr(pc+1),

                    /*leaveErrorMsg*/ 1);

            CACHE_STACK_INFO();

            if (valuePtr == NULL) {



PatchFiles:

tclExecute.c





06/16/1999 14:39 - stanton - I have applied the patch and added a test case.
welch Closed ticket [218820ffff]. [History diff]2000-10-26 08:29:17
dgp Ticket [218820ffff]: 3 changes [History diff]2001-04-23 02:53:14
Log in (anonymous is fine) to add a comment.