Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#2019 Tcl_FindExecutable documentation

obsolete: 8.4b2
Don Porter

Using TCL dynamic library tcl84.dll in our process.
The current dir is d:\xyz\some\dir ; have tcl source
script there named "tclExtSource.tcl".

When called Tcl_EvalFile("tclExtSource.tcl");
it fails saying "couldn't read file "tclExtSource.tcl":
no such file or directory"

After investigation, it looks like there is bug in
following method in "tclWinFile.cpp"
int TclpObjNormalizePath(interp, pathPtr,
Tcl_Interp *interp;
Tcl_Obj *pathPtr;
int nextCheckpoint;


-Prashant Hedaoo


  • Logged In: NO

    Please provide more detail on the "bug" you found in
    tclWinFile.c. In particular what were the inputs to the
    function, what were the results and how did those
    results differ from what you expected to see.

  • Vince Darley
    Vince Darley

    Logged In: YES

    Can't reproduce this without further information.

  • Vince Darley
    Vince Darley

    • status: open --> pending-works-for-me
  • Logged In: NO

    Test case:

    1. Create Test Tcl source sctipt ("tclTest.tcl") and put it in a dir "c:\some\dir"
    2. Create a program to use tcl84.dll (Beta 2) which calls Tcl_EvalFile( "tclTest.tcl") after changing current dir to

    Actual result:

    Tcl_EvalFile(..) fails. If you furthur probe, the TclpObjNormalizePath(...) returns path "C:\tclTest.tcl" instead of


  • Logged In: YES

    Step number 2 is the difficult one.
    Please provide your sources.
    Without these sources we might accidentially create an
    application which does not exhibit the problem.
    Maybe your application initialization is wrong or something
    which prevents the normalization code from working correctly.

    If your sources are to big, confidential, etc. reduce your code
    to a minimal example still exhibiting the problem and submit

    Is it possible for you to add your email address so that Vince
    can talk to you more directly ?

    • status: pending-works-for-me --> open-works-for-me
  • Logged In: NO

    I will try to get you source code for step 2.

    Additional info :

    Tcl_EvalFile() worked fine till TCL 8.4 (Alfa 4) release.
    Broke in TCL 8.4 (Beta 1 and 2)

    My email : phedaoo@iss.net


  • Logged In: NO

    Test case setup..............

    Prerequisite for building tcl84.lib and tcl84.dll binaries.
    Otherwise, program crashes due to NULL function pointer. Another bug in TCL code.

    1. Replace line# 86 -> NULL, by following line in ...\win\tclWin32Dll.cpp

    2. Replace line# 125 -> NULL, by following line in ...\win\tclWin32Dll.cpp

    3. Build TCL lib binaries.

    Test program begins here
    // TclTest.cpp : Test program to demonstrate the Tcl_EvalFile() bug.
    #include "stdafx.h"
    #include "direct.h"
    #include <tcl.h>
    #define SCTIPT_FILE "tclTest.tcl"
    #define SCTIPT_DIR "c:\\some\\dir"
    #define SCTIPT_FPATH "c:\\some\\dir\\tclTest.tcl"

    int main(int argc, char* argv[])
    Tcl_Interp* interp = Tcl_CreateInterp();
    if (!interp) {
    fprintf(stderr, "Tcl_CreateInterp failed\n"); return 1;
    if(chdir(SCTIPT_DIR)) {
    fprintf(stderr, "chdir failed\n"); return 2;
    //////////////// Tcl_EvalFile() fails.......
    if (Tcl_EvalFile(interp, SCTIPT_FILE) != TCL_OK) {
    fprintf(stderr, "1: Tcl_EvalFile failed\n\tERROR: %s\n", interp->result);
    //////////////// Tcl_EvalFile() fails.......here too!!!!!
    if (Tcl_EvalFile(interp, SCTIPT_FPATH ) != TCL_OK) {
    fprintf(stderr, "2: Tcl_EvalFile failed\n\tERROR: %s\n", interp->result);
    return 0;

    Output of the test program :
    ----------------------------BEGIN OUTPUT---------------------------
    1: Tcl_EvalFile failed
    ERROR: couldn't read file "tclTest.tcl": no such file or directory
    2: Tcl_EvalFile failed
    ERROR: couldn't read file "c:\some\dir\tclTest.tcl": permission denied
    ----------------------------------END OUTPUT------------------------

    Step through the Tcl_EvalFile() call .......see following stack....

    TclpObjNormalizePath(Tcl_Interp * 0x00000000, Tcl_Obj * 0x007d7198, int 0x00000000) line 1997
    TclNormalizeToUniquePath(Tcl_Interp * 0x00000000, Tcl_Obj * 0x007d7198) line 1086 + 15 bytes
    FSNormalizeAbsolutePath(Tcl_Interp * 0x00000000, Tcl_Obj * 0x007d7228) line 1008 + 13 bytes
    Tcl_FSGetCwd(Tcl_Interp * 0x00000000) line 2025 + 13 bytes
    Tcl_FSGetNormalizedPath(Tcl_Interp * 0x00000000, Tcl_Obj * 0x007d7270) line 4293 + 9 bytes
    Tcl_FSGetFileSystemForPath(Tcl_Obj * 0x007d7270) line 4846 + 11 bytes
    Tcl_FSStat(Tcl_Obj * 0x007d7270, _stati64 * 0x0012febc) line 1554 + 9 bytes
    Tcl_FSEvalFile(Tcl_Interp * 0x007e1100, Tcl_Obj * 0x007d7270) line 1334 + 13 bytes
    Tcl_EvalFile(Tcl_Interp * 0x007e1100, const char * 0x00420090 ??_C@_0M@OJLM@tclTest?4tcl?$AA@) line 234
    + 13 bytes
    main(int 0x00000001, char * * 0x00900e90) line 26 + 17 bytes
    mainCRTStartup() line 206 + 25 bytes
    KERNEL32! GetProcessPriorityBoost + 279 bytes
    ----------------END STACK TRACE------------

    The TclpObjNormalizePath(interp, pathPtr, nextCheckpoint) is entered with pathPtr= Tcl_Obj("c:/some/dir")
    and nextCheckpoint= 0.

    This function is broke.... it returns "<drive>:/" (eg."C:/") for whatever dir path is passed to it.

    Thanks for your support.


  • Vince Darley
    Vince Darley

    Logged In: YES

    As per the documentation, you need to call
    Tcl_FindExecutable first. None of the things you point
    out are bugs. sorry!

  • Vince Darley
    Vince Darley

    • status: open-works-for-me --> closed-invalid
  • Logged In: NO

    Please point me to the document which recommends user need to call Tcl_FindExecutable() before Tcl_EvalFile()

    I could not find it on Man pages for both of the library calls.

    Also Is there any special pre-requisit before loading DLL ?
    Example :

    if {$tcl_platform(os) == {Windows NT}} {
    load libNT.dll



  • Vince Darley
    Vince Darley

    • assigned_to: vincentdarley --> dgp
    • summary: Tcl_EvalFile dosn't look in current dir --> Tcl_FindExecutable documentation
  • Vince Darley
    Vince Darley

    Logged In: YES

    changed name of bug and assigned to dgp to decide
    whether better documentation is needed to avoid this
    overly frequent problem.