Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e1782f79899d1406ef8abe796a3daed9326a3189508b0da86017edc40bb44f4a
Ticket: fec0c17d39db02faffa101ebb605d0958dbf3466
segfault compiling deeply nested [catch]
User & Date: sebres on 2017-11-28 17:32:32
Changes

  1. icomment:
    I was a bit too fast with my explaining example (I made dual counting there), below the correct example:
    <pre><code>
    proc gencode_lengths {nr} {
        # initial length:
        set codelen 0
        set initlen [string length "set a foo"]
        set levincr [string length "catch \{\}"]
        set codelen2 0
        # unfold "recursion" to count each body length:
        for {set i 0} {$i < $nr} {incr i} {
            # length of this level body (new catch + from prev. recursion level):
            set levlen [expr {$initlen + $levincr * $i}]
            # + length of addition in current body:
            incr codelen $levlen
            # to debug each level:
            # puts "**$i** $codelen (+ $levlen) - [gencode $i]"
        }
        # lengths of all body objects (that will be compiled)
        return $codelen
    }
    
    % puts [set len [gencode_lengths 100000]]
    40000500000
    </code></pre>
    
    But the conclusion still the same: no memory, at least in 32-bit env I can pretty see allocation panic...
    Possibly by x64 (and enough memory) somewhere in interim structures we've signed int (instead of long), that overflows into negative...
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"