Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0dbbeb49466135ac7a6497e21248401c7009cea2
Ticket: b9b2079e6d23fb18b7944fbb4b703223cff6ec44
Segfaults parsing a script. The script works nicely in version 8.5
User & Date: anonymous on 2016-03-08 18:27:18
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    This is the most simplified code I have been able to write triggering the segfault. It crashes in 32 and 64 bit versions of tcl (debian sid package)
    
    ------
    #!/bin/tclsh
    
    foreach i {a b} {set t_$i ""}
    
    proc triggerError {} {
        set var_t ""
        foreach i {a b} {
            set v t_$i
            upvar 1 [coalesce [set var_t] [set v]] t_$i
        }
    }
    
    proc coalesce {args} {
        set res ""
        foreach i $args {
            if {$i != ""} {set res $i;break}
        }
        return $res
    }
    
    triggerError
    
    puts "END"
    ------
    
    I think the problem has something to do with the parsing of line 9 (the one with the upvar). If you change it like this:
    
            set aux [coalesce [set var_t] [set v]]
            upvar 1 $aux t_$i
    
    The problem fades away.
    
  5. foundin changed to: "8.6.5"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "3ff3943d55f2767d3dd1d11b625e46c3cc9479b2"
  10. resolution changed to: "None"
  11. severity changed to: "Severe"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "45. Parsing and Eval"
  15. title changed to:
    Segfaults parsing a script. The script works nicely in version 8.5
    
  16. type changed to: "Bug"