Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-14
03:19 • Ticket [217984ffff] variable is not checked correctly in stopping condition of w... artifact: 78502972c2 user: dgp
2000-10-26
08:12 • Closed ticket [217984ffff]. artifact: bbee67c6f2 user: welch
00:47 • New ticket [217984ffff]. artifact: 4ff1181826 user: nobody

variable is not checked correctly in stopping condition of w

Closed / Invalid217984ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:47:09
OriginalBugID: 5965 Bug
Version: 8.3.1
SubmitDate: '2000-06-29'
LastModified: '2000-06-30'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: ericm
RelatedBugIDs: 5964
OS: Linux
OSVersion: linux kernel 2.2.14, TCL built with GCC (egcs-2.91.66)
Machine: i386
FixedDate: '2000-06-30'
ClosedDate: '2000-10-25'


Name:
thomas park

Extensions:
none

CustomShell:
none

Comments:
also observed bug in TCL v. 8.0.4

ReproducibleScript:
This is a proc that creates a unique filename based on POSIX time, with a monotonic numerical extension if there was already a file created that second.  The error occurs when the script has already created a file:

proc get_ref_id { } {

    # ns_time gives POSIX time
    set ref_no [ format %x [ ns_time ] ]

    set base_ref ""
    append base_ref [msg_path] $ref_no
    set ref_id $base_ref

    set suffix 0

    while [ set result [file exists $ref_id] ] {
        # DEBUG
        puts [ concat "ref_id is" $ref_id ]
        puts [ concat "exists gives" [file exists $ref_id] ]
        puts [ concat "result is" $result ]

        set ref_id ""
        append ref_id $base_ref "." $suffix
        set suffix [ incr suffix ]
    }

    return [ list $ref_id $ref_no ]
}

ObservedBehavior:
infinite loop.  although the file DOESN'T exist, the while loops infinitely.

...
ref_id is /usr/local/crm/395b4604.1811
exists gives 0
result is 1
ref_id is /usr/local/crm/395b4604.1812
exists gives 0
result is 1
ref_id is /usr/local/crm/395b4604.1813
exists gives 0
result is 1
ref_id is /usr/local/crm/395b4604.1814
exists gives 0
result is 1
ref_id is /usr/local/crm/395b4604.1815
exists gives 0
result is 1
ref_id is /usr/local/crm/395b4604.1816
exists gives 0
result is 1
ref_id is /usr/local/crm/395b4604.1817
exists gives 0
result is 1
...

DesiredBehavior:
when the while loop iterates, i would expect red_id (which was set in the while loop) to be evaluated with the new value in the while condition!
welch Closed ticket [217984ffff]. [History diff]2000-10-26 08:12:10
dgp Ticket [217984ffff]: 4 changes [History diff]2001-04-14 03:19:24
Log in (anonymous is fine) to add a comment.