#2419 Crash when std channels not open

obsolete: 8.4.3
closed-fixed
8
2004-02-17
2003-07-16
No

The following script crashes both the HEAD and the 8.4
branch:
open /dev/null
when run like this (from BASH, but there are other
equivalent situations):
tclsh bug.tcl <&-

The effect of the invokation is to make tclsh run
without stdin opened (the same also happens with stdout
and stderr.) This is caused by leaving the
initialisation of the channel table until the call to
Tcl_RegisterChannel() as part of the closing stages of
the [open] implementation, which ensures that fd0 (or 1
or 2) is put in the table twice, once for stdin/out/err
and once for the newly created channel for [open], with
the second time being the crash.

The attached patch fixes this, but causes test
encoding-24.3 to fail, and will break any script that
depends on setting [encoding system] early so as to
alter the encodings of the std channels.

This problem was discovered by rmax

Discussion

  • Donal K. Fellows

    Patch against tip of 8.4 branch

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-07-18
    • priority: 9 --> 8
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-07-18

    Logged In: YES
    user_id=72656

    I want a much better understanding of the implications of this
    bug before placing it into 8.4.x

     
  • Reinhard Max

    Reinhard Max - 2003-10-02

    Logged In: YES
    user_id=124643

    Any news here, Jeff?
    Today another colleague got hit by this bug, because stdin
    is closed on processes started from fvwm2 buttons or menus.

     
  • Reinhard Max

    Reinhard Max - 2003-10-02

    Logged In: YES
    user_id=124643

    How about this patch, at least as a workaround to prevent
    the crash until a better solution is found? Unlike Donal's
    proposal no tests fail with this patch applied. There might
    be better places for adding these lines, but
    TclpInitPlatform was the most reasonable place I have found.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-11-06

    Logged In: YES
    user_id=72656

    The alternate patch ignores Windows ... but is that 100%
    valid? I recently had to solve this by checking for the
    standard channels being NULL on Windows. I can't repro this
    with a variation of bug.tcl though.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-02-06

    Logged In: YES
    user_id=72656

    we should have a test case for this.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-02-06
    • assigned_to: andreas_kupries --> hobbs
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-02-17

    Logged In: YES
    user_id=72656

    test unixInit-7.1 {closed standard channel} -body {
    set tclsh [interpreter]
    makeFile {puts [open /dev/null]} crash.tcl
    makeFile [subst -nocommands {
    close stdin
    exec $tclsh crash.tcl
    }] crashtest.tcl
    exec $tclsh crashtest.tcl
    } -returnCodes 0

    in 8.4.6 and 8.5a1.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-02-17
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks