Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f39f7d121843a9795c6162936b237f77faea2aaf
Ticket: 491341ffffffffffffffffffffffffffffffffff
GetsObj: trunc/append confusion @EOF
User & Date: dgp on 2001-12-10 22:31:37
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    When Tcl_GetsObj(chan, obj) receives an obj that
    already has a non-empty string rep, the bytes
    read from chan are supposed to be appended to
    the existing string rep.  It is incorrect to
    assume that obj->bytes is an empty string.
    
    Tcl_GetsObj() gets this right almost everywhere,
    but this part of the spec was forgotten in
    lines 3634-3644 of tclIO.c, where EOF handling
    takes place.  Those lines only work if obj->bytes
    passed in is an empty string.  Since [gets]
    always does pass in such an empty Tcl_Obj, this
    bug isn't visible at the script level, but it
    shows up regularly in the call at line 300 of
    tclMain.c.  Lines 304-306 of tclMain.c even
    appear to be an awkward attempt to work around this
    bug, without ever identifying it as a bug.
    
    To demo the bug, create a file test.tcl with
    a single line:
    
    if 1 {
    
    Then at a shell prompt
    
    $ tclsh < test.tcl
    
    This will stick tclsh in an infinite loop.
    
    Attached is the simple patch that correctly
    tests for "no characters read @ EOF" when
    obj-> bytes is non-empty.
    
  4. foundin changed to: "obsolete: 8.4a4"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dgp"
  9. subsystem changed to: "25. Channel System"
  10. title changed to: "GetsObj: trunc/append confusion @EOF "
  11. type changed to: "Bug"