#1645 embedded interp crashes on win 2000

obsolete: 8.3.2
closed-invalid
5
2002-05-28
2001-10-03
jesse
No

A very simple test program has been attached that
crashes on windows 2000, after being compiled with VC6
(sp5). This has been tested on two win 2000 machines
with consistent behaviour.

This code successfully Evals some commands,
(i.e. "puts $auto_path") but crashes on many other
commands. A couple of these other commands have been
included with in the comments of the source code.

This has also been tested on windows NT compiled under
VC5 (sp3) and works fine (i.e. No Crash!).

Discussion

  • jesse

    jesse - 2001-10-03

    test application that demonstrates the win 2000 crash

     
  • jesse

    jesse - 2001-10-03

    Logged In: YES
    user_id=339882

    With further investigation, it seems this also happens with
    the latest version of tcl (8.4a3) on windows 2000.

    "Normal" tcl commands seems to function, (i.e. puts, for,
    if...) the 'info' command seems to consistently crash the
    interpreter, as well attempting to access functions in
    loaded packages also seems to crash the interpreter.

    Ex. package require simple //functions fine
    puts [simple::upper SoMeStRiNg] //unhandled exception

     
  • Don Porter

    Don Porter - 2001-10-03
    • labels: --> 105684
    • assigned_to: nobody --> dgp
     
  • David Gravereaux

    Logged In: YES
    user_id=7549

    The bug is in Win2K and Tcl. Tcl_MakeFileChannel() was repaired in 8.4 more than a year ago.

    The STARTUPINFO handed to the GUI application that embedds Tcl, has invalid data in the 3 standard handles:

    .hStdInput
    .hStdOutput
    .hStdError

    They were previously accepted without question and only tested if == NULL || == INVALID_HANDLE_VALUE. But Win2K
    is putting garbage there. See Tcl_MakeFileChannel() in tclWinChan.c (HEAD code in CVS) for the big effort I did with __try/__except.

    A possibly better check might be to use HasConsole() first, to see if the data in the STARTUPINFO should be worth checking. The belt and suspender exception handling in Tcl_MakeFileChannel() could be left in place, though.

    The error you should be getting is:
    can not find channel named "stdout"

    [puts ""] will never work in your case anyways, as there is no destination in a GUI application unless it calls AllocConsole() to create one.

    I'll have a look at your code...

     
  • David Gravereaux

    Logged In: YES
    user_id=7549

    Ok, you are using a console app. Sorry about my GUI comments.

    I don't think you should be mixing Tcl_WriteObj() [<- the deep end of puts] and cout. I have some stream code that'll set cout to use Tcl_WriteObj() instead, if you want it (?)

    They do eventually land in the same place, but take very different paths to get there. I've always been leary of mixing the two, but I can't say it is wrong, either.

     
  • David Gravereaux

    Logged In: YES
    user_id=7549

    PS.

    where they both land together is here, BTW:
    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msg, _tcslen(msg), &dwWritten, NULL);

    And GetStdHandle(STD_OUTPUT_HANDLE) returns garbage on Win2K within a GUI application.

     
  • Don Porter

    Don Porter - 2001-11-09

    Logged In: YES
    user_id=80530

    Judging from davygrvy's comments, the trouble
    here is in Tcl's handling of std channels
    on Win2K. Assigning to that category.

     
  • Don Porter

    Don Porter - 2001-11-09
    • assigned_to: dgp --> andreas_kupries
    • labels: 105684 --> 27. Channel Types
     
  • Andreas Kupries

    Andreas Kupries - 2001-12-11

    Logged In: YES
    user_id=75003

    David, I just compared the head of tcl (8.4.aXXX) against
    the head of core-8-3-1-branch (= head of 8.3.4+) and the
    only difference I saw in "tclWinChan.c" was an adaption
    of "TclpOpenFileChannel" to the new VFS
    code. "Tcl_MakeFileChannel" is the same in both files. And
    I am unable to see the big __try/__except sections you are
    refering too. Can you give me line numbers ? Is that the
    code for FILE_TYPE_UNKNOWN where you try to dup a handle to
    check its validity ?

    Assigned to you so that you see my question.

     
  • Andreas Kupries

    Andreas Kupries - 2001-12-11
    • assigned_to: andreas_kupries --> davygrvy
     
  • David Gravereaux

    Logged In: YES
    user_id=7549

    Calls to Tcl_Eval() must use writable strings as per the docs.

    r = Tcl_Eval(g_interp, "puts [info patchlevel]");

    that is guarenteed crash. Change it to this:

    char cmd[] = "puts [info patchlevel]";
    r = Tcl_Eval(g_interp, cmd);

     
  • David Gravereaux

    • status: open --> closed-invalid
     

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

Sign up for the SourceForge newsletter:





No, thanks