Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3da5c21232cfd5d458d5386e7ed5a21ee16ab831
Ticket: 2176669fffffffffffffffffffffffffffffffff
Strange seek bug
User & Date: nobody on 2008-10-18 11:57:20
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I've got strange seek behavior executing this simple script (Windows
    XP, tcl 8.4.19/8.5.2/8.6a1):
    
    --- exp.tcl ---
    set fd [open hash.db r+]
    
    seek $fd 100
    puts [tell $fd]
    puts -nonewline $fd 0
    puts [tell $fd]
    read $fd 2
    seek $fd 0
    puts [tell $fd]
    ---
    Result is:
    
    100
    101
    error during seek on "filea3bf40": bad address in system call argument
        while executing
    "seek $fd 0"
        (file "exp.tcl" line 8)
    
    ------------
    It seems that it originates from here:
    
    ----- tclIO.c -----
    ...
    In Tcl_Seek:
    
    /*
     * Compute how much input and output is buffered. If both input and
    output
     * is buffered, cannot compute the current position.
     */
    
    inputBuffered = Tcl_InputBuffered(chan);
    outputBuffered = Tcl_OutputBuffered(chan);
    
    if ((inputBuffered != 0) && (outputBuffered != 0)) {
        Tcl_SetErrno(EFAULT);
        return Tcl_LongAsWide(-1);
    
    }
    
    --------
    
    So, [flush]-ing channel before seeking helps.
    I didn't find this documented anywhere.
    Moreover, as Alexandre Ferrieux said, [seek] is documented to flush the output side. 
    
    
    
  4. foundin changed to: "obsolete: 8.4.19"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "nobody"
  10. subsystem changed to: "25. Channel System"
  11. title changed to: "Strange seek bug"
  12. type changed to: "Bug"