Infinite Loop in TCL/EDI

1.5k views Asked by At

I am writing a script in TCL that is sourced into Cadence's Encounter Digital Implementation Shell. It recursively executes a number of TCL procs and all of a sudden exits the code saying- 'Too many nested evaluations (infinite loop?)'. I located the proc where it errors out and checked the variables being passed as arguments. All values are normal.

I am attaching the part of the proc where it is erroring out. (THe entire script is 1000 lines+ so only mentioning this part).

for {set i 1} {$i<=[llength $xcoord_sinks_for_clone($clone_to_regroup_ref)]} {incr i} {
        set abs_dist_list($i) ""
        set count 0

        foreach clone $new_clone_index_ref2 {
            set dist($i) [expr [distance [lindex $xcoord_sinks_for_clone($clone_to_regroup_ref) [expr $i-1]] [lindex $xcoord_clones [expr $clone_to_regroup_ref-1]] [lindex $ycoord_sinks_for_clone($clone_to_regroup_ref) [expr $i-1]] [lindex $ycoord_clones [expr $clone_to_regroup_ref-1]]]-[distance [lindex $xcoord_sinks_for_clone($clone_to_regroup_ref) [expr $i-1]] [lindex $xcoord_clones [expr $clone-1]] [lindex $ycoord_sinks_for_clone($clone_to_regroup_ref) [expr $i-1]] [lindex $ycoord_clones [expr $clone-1]]]]
            set dist_abs($i) [expr abs($dist($i))]
            lappend abs_dist_list($i) $dist_abs($i)
            incr count
        }
        set sorted_dist_abs($i) [lsort -real $abs_dist_list($i)]
        lappend min_dist [lindex $sorted_dist_abs($i) 0]
    }

I was able to pin-point the location of the error. Everything happens according to the script till right before the 'set dist($i).....' assignment inside the foreach loop.

Is there some memory-allocation problem? ( The script is running on a Load Sharing Facility)

Please help me out!!

2

There are 2 answers

0
bmk On

You could try to increase your recursion limit, e.g.:

set old_limit [interp recursionlimit {}]
set limit_increment 2000
interp recursionlimit {} [expr {$old_limit + $limit_increment}]

# execute recursive procedure

interp recursionlimit {} $old_limit
0
Bryan Oakley On

If you get an error about recursion, that means a function is calling itself. If the code you posted is part of the distance proc, and the code calls distance itself, that could be the problem.