Tcl Source Code

View Ticket
Login
Ticket UUID: ea39ab591e47448f448a85da8489864c17a1c23c
Title: Tcl_StaticPackage allows case sensitvity; [load] prevents it
Type: Bug Version: all
Submitter: dgp Created on: 2020-11-06 15:03:46
Subsystem: 40. Dynamic Loading Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2021-10-31 15:19:36
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2021-10-31 15:19:36
Description:
This is the real issue touched on by the reforms proposed in TIP 590.  The
management of loaded module names has always been an inconsistent, incoherent
mess. This is a bug, but one long-standing enough, and the change potentially
disruptive enough that a TIP on the subject is sensible.

Tcl_StaticPackage() allows for multiple modules to be registered that have names
the differ only by case.

The [load] command blocks that, and does lookups without respecting case.

You cannot make sensible use of a system that is inconsistent with itself.
User Comments: jan.nijtmans added on 2021-10-31 15:19:36:

TIP #595 now accepted and implemented in Tcl 9.0. Closing


jan.nijtmans added on 2020-11-09 16:16:53:

Possible solution here: [7ec4c7e11a43340f]. This breaks any extension which assumes a case-insensitive "load" command, e.g. Itcl and sampleextension.

I fixed Itcl and sampleextension on that now, but it's clear that this cannot be done until Tcl 9.0. And we need a good TIP and documentation and code-cleanup...

So, far from finished yet, just consider this a small demo that it can be made to work.


jan.nijtmans added on 2020-11-06 17:27:59:
Hm it originally gave 25 test-failures. For completeness:


Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  winDde.test
Tests began at Fri Nov 06 17:53:50 CET 2020
winDde.test


==== winDde-4.1 DDE execute remotely FAILED
==== Contents of test case:

    set \xe1 ""
    set name ch\xEDld-4.1
    set child [createChildProcess $name]
    dde execute TclEval $name [list set \xe1 foo]
    dde execute TclEval $name {set done 1}
    update
    set \xe1

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: dde command failed
    while executing
"dde execute TclEval $name [list set \xe1 foo]"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE FAILED
==== winDde-4.1 FAILED



==== winDde-4.2 DDE execute async remotely FAILED
==== Contents of test case:

    set \xe1 ""
    set name ch\xEDld-4.2
    set child [createChildProcess $name]
    dde execute -async TclEval $name [list set \xe1 foo]
    update
    dde execute TclEval $name {set done 1}
    update
    set \xe1

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: dde command failed
    while executing
"dde execute -async TclEval $name [list set \xe1 foo]"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE FAILED
==== winDde-4.2 FAILED



==== winDde-4.3 DDE request remotely FAILED
==== Contents of test case:

    set \xe1 ""
    set name ch\xEDld-4.3
    set child [createChildProcess $name]
    dde execute TclEval $name [list set \xe1 foo]
    set \xe1 [dde request TclEval $name \xe1]
    dde execute TclEval $name {set done 1}
    update
    set \xe1

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: dde command failed
    while executing
"dde execute TclEval $name [list set \xe1 foo]"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE FAILED
==== winDde-4.3 FAILED



==== winDde-4.4 DDE eval remotely FAILED
==== Contents of test case:

    set \xe1 ""
    set name ch\xEDld-4.4
    set child [createChildProcess $name]
    set \xe1 [dde eval $name set \xe1 foo]
    dde execute TclEval $name {set done 1}
    update
    set \xe1

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: invalid data returned from server
    while executing
"dde eval $name set \xe1 foo"
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE BAD_RESPONSE
==== winDde-4.4 FAILED



==== winDde-6.5 DDE remote servername collision FAILED
==== Contents of test case:

    dde servername -- $name

---- Result was:
chíld-6.5
---- Result should have been (exact matching):
chíld-6.5 #2
==== winDde-6.5 FAILED



==== winDde-7.1 Load DDE in child interpreter FAILED
==== Contents of test case:

    child eval [list load $::ddelib Dde]
    child eval [list dde servername -- dde-interp-7.1]

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child eval [list load $::ddelib Dde]"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: WIN_LOAD BAD_EXE_FORMAT
==== winDde-7.1 FAILED



==== winDde-7.2 DDE child cleanup FAILED
==== Contents of test case:

    dde services TclEval {}
    set s [dde services TclEval {}]
    set m [list [list TclEval dde-interp-7.5]]
    if {$m in $s} {
        set s
    }

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child eval [list load $::ddelib Dde]"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-7.2 FAILED



==== winDde-7.3 DDE present in child interp FAILED
==== Contents of test case:

    dde services TclEval dde-interp-7.3

---- Test setup failed:
interpreter named "child" already exists, cannot create
---- errorInfo(setup): interpreter named "child" already exists, cannot create
    while executing
"interp create child"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): NONE
==== winDde-7.3 FAILED



==== winDde-7.4 interp name collision with -force FAILED
==== Contents of test case:

    dde servername -force -- dde-interp-7.4

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child eval [list load $::ddelib Dde]"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-7.4 FAILED



==== winDde-7.5 interp name collision without -force FAILED
==== Contents of test case:

    dde servername -- dde-interp-7.5

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child eval [list load $::ddelib Dde]"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-7.5 FAILED



==== winDde-8.1 Safe DDE load FAILED
==== Contents of test case:

    child eval dde servername child

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.1 FAILED



==== winDde-8.2 Safe DDE set servername FAILED
==== Contents of test case:

    child invokehidden dde servername child

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.2 FAILED



==== winDde-8.3 Safe DDE check handler required for eval FAILED
==== Contents of test case:

    catch {dde eval child set a 1} msg

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.3 FAILED



==== winDde-8.4 Safe DDE check that execute is denied FAILED
==== Contents of test case:

    child eval set a 1
    dde execute TclEval child {set a 2}
    child eval set a

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.4 FAILED



==== winDde-8.5 Safe DDE check that request is denied FAILED
==== Contents of test case:

    child eval set a 1
    dde request TclEval child a

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.5 FAILED



==== winDde-8.6 Safe DDE assign handler procedure FAILED
==== Contents of test case:

    child invokehidden dde servername -handler DDEACCEPT child

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.6 FAILED



==== winDde-8.7 Safe DDE check simple command FAILED
==== Contents of test case:

    dde eval child set x 1

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.7 FAILED



==== winDde-8.8 Safe DDE check non-list command FAILED
==== Contents of test case:

    set s "c:\\Program Files\\Microsoft Visual Studio\\"
    dde eval child $s
    string equal [child eval set DDECMD] $s

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.8 FAILED



==== winDde-8.9 Safe DDE check command evaluation FAILED
==== Contents of test case:

    dde eval child set \xe1 1
    child eval set \xe1

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.9 FAILED



==== winDde-8.10 Safe DDE check command evaluation (2) FAILED
==== Contents of test case:

    dde eval child [list set x 1]
    child eval set x

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.10 FAILED



==== winDde-8.11 Safe DDE check command evaluation (3) FAILED
==== Contents of test case:

    dde eval child [list [list set x 1]]
    child eval set x

---- Test setup failed:
couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
---- errorInfo(setup): couldn't load library "C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib": Bad exe format. Possibly a 32/64-bit mismatch.
    while executing
"load C:/Users/jan.nijtmans/workspace/tcl8.7/win/Release_AMD64_VC1923/tcldde14s.lib Dde"
    invoked from within
"child invokehidden load $::ddelib Dde"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $setup"
---- errorCode(setup): WIN_LOAD BAD_EXE_FORMAT
==== winDde-8.11 FAILED



==== winDde-9.1 External safe DDE check string passing FAILED
==== Contents of test case:

    dde eval $name set x 1
    gets $child line
    set line

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: invalid data returned from server
    while executing
"dde eval $name set x 1"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE BAD_RESPONSE
---- Test cleanup failed:
dde command failed
---- errorInfo(cleanup): dde command failed
    while executing
"dde execute TclEval $name stop"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $cleanup"
---- errorCode(cleanup): TCL DDE FAILED
==== winDde-9.1 FAILED



==== winDde-9.2 External safe DDE check command evaluation FAILED
==== Contents of test case:

    dde eval $name set x 1
    gets $child line
    set line

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: invalid data returned from server
    while executing
"dde eval $name set x 1"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE BAD_RESPONSE
---- Test cleanup failed:
dde command failed
---- errorInfo(cleanup): dde command failed
    while executing
"dde execute TclEval $name stop"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $cleanup"
---- errorCode(cleanup): TCL DDE FAILED
==== winDde-9.2 FAILED



==== winDde-9.3 External safe DDE check prefixed arguments FAILED
==== Contents of test case:

    dde eval $name set x 1
    gets $child line
    set line

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: invalid data returned from server
    while executing
"dde eval $name set x 1"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE BAD_RESPONSE
---- Test cleanup failed:
dde command failed
---- errorInfo(cleanup): dde command failed
    while executing
"dde execute TclEval $name stop"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $cleanup"
---- errorCode(cleanup): TCL DDE FAILED
==== winDde-9.3 FAILED



==== winDde-9.4 External safe DDE check null data passing FAILED
==== Contents of test case:

    dde execute TclEval $name ""
    gets $child line
    set line

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: dde command failed
    while executing
"dde execute TclEval $name """
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: TCL DDE FAILED
---- Test cleanup failed:
dde command failed
---- errorInfo(cleanup): dde command failed
    while executing
"dde execute TclEval $name stop"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $cleanup"
---- errorCode(cleanup): TCL DDE FAILED
==== winDde-9.4 FAILED


Tests ended at Fri Nov 06 17:53:51 CET 2020
all.tcl:        Total   50      Passed  22      Skipped 3       Failed  25
Sourced 1 Test Files.
Files with failing tests: winDde.test
Number of tests skipped for each constraint:
        3       debug

jan.nijtmans added on 2020-11-06 17:26:23:

> If we have a build configuration never used by anyone, let's please eliminate it.

Or fix it, what I did now.

The only way to build a "staticpackage" build is using makefile.vc, the win/configure script doesn't have an enable-staticpkg or something like that.

So I made a "nmake -f makefile.vc OPTS=static,staticpkg" build and added it to Travis. It gave 2 test failures, due to Tcl_StaticPackage called with a lowercase package name: such libraries can never be "loaded" in in an interpreter.

I turned out that winDde.test contained another error: It didn't account for ::ddelib to be {}, which is the case with statically loaded dde package. That's corrected now.

Maybe we don't use such a configuration, I'm sure that tclkit builds use it!

Anyway, it should be fixed now.


dgp added on 2020-11-06 16:47:13:
If we have a build configuration never used by anyone, let's please eliminate it.

jan.nijtmans added on 2020-11-06 16:24:58:

Exactly this is the reason for commit [d8e520bee8]: If Tcl_StaticPackage() is called with a non-camel-cased package name, it can later never be found by the "load" command. No-one ever builds a tclsh with TCL_USE_STATIC_PACKAGES on Windows, that's why no-one discovered this yet.

I'm sure that testcases fail in such a Windows build, but I'll check this.