Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2be723385e49494b2fa5129fd513c39c3e1ba7a2b4283573c6913c7e8a7df90d
Ticket: 75ecc0e6cb9899bff0fa9e22a10a76b0c244c0a1
TclInitSubsystems issues: the sporadic lack of encodings
User & Date: sebres on 2018-05-30 18:53:55
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Set the system encoding via environment/locale failed somitimes dependent of the system constellation (distribution and/or some env-settings).
    
    Who saw already the test "unixInit-3.2" failed? :)
    
    This cumulates from two actual issues:
    
    1. setlocale (called from TclpInitPlatform) may overwrite environment "LANG" (to "C"), so the try searching of current encoding later in Tcl_GetEncodingNameFromEnvironment <b>will failback to "C"</b> (so the call of "setlocale" takes place <b>too early</b> in some cases, resp. get initial environment via getenv("LANG") <b>too late</b>);
    
    2. second thing which can happen, if 1st issue with "setlocale" gets repaired, would be the fact, that Tcl_GetEncodingSearchPath (called from TclpSetInitialEncodings/Tcl_SetSystemEncoding) may return "" <b>before still any interpreter instance created</b> (and it is so if TclpInitPlatform called).<br/>
    In this case setting of something other as already available system-encodings going to "C" (iso8859-1), because the load of encoding simply fails.<br/>
    The reason for this trouble is the wrong value returned by callback TclpInitLibraryPath.<br/> But later (after first interp going created) the init.tcl (as well as the counterpart script hard-coded in Tcl_Init) will indirectly call Tcl_SetEncodingSearchPath to the proper value (after tcl_library correct resolved and TclGetProcessGlobalValue(&libraryPath) returns correct value) and then the load of the same encoding works.
    
    Following code can illustrate this behavior:
    <pre style="padding-left:10pt"><code>
    $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese ./tclsh
    
    ==iso8859-1
    ==euc-jp
    </code></pre>
    But setting of proper tcl_library env-variable resolves it:
    <pre style="padding-left:10pt"><code>
    $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese TCL_LIBRARY=../library ./tclsh
    
    ==euc-jp
    ==euc-jp
    </code></pre>
    
    I saw it already too often, but following cases are affected especially:
    
    - usage of portable-like (not installed) tcl's instance or tcl-ed applications (where TCL_LIBRARY environment variable does not set by start);
    
    - call of other tcl-instance from tcl-app via [open "| some-tcl-app"] inside the tcl-interpterer with changed environment (LC_... resp. LANG are changed);
    
    - call of tcl from development environment (also not istalled), like this:
    <pre style="padding-left:10pt"><code>
    $ cd ~projects/tcl8.6/unix
    $ LD_LIBRARY_PATH=. ./tclsh ../tests/all.tcl -file '*unixInit*' -match '*unixInit-3.2*'
    
    ...
    ==== unixInit-3.2 TclpSetInitialEncodings FAILED
    ...
    ---- Result was:
    1
    ---- Result should have been (exact matching):
    0
    ==== unixInit-3.2 FAILED
    ...
    </code></pre>
    
    I've localized the "wrong" places and will try to fix it soon.<br/>
    WiP.
    
  5. foundin changed to: ">= 8.5 (partially), >= 8.6"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Severe"
  11. status changed to: "Open"
  12. submitter changed to: "sebres"
  13. subsystem changed to: "38. Init - Library - Autoload"
  14. title changed to:
    TclInitSubsystems issues: sporadical the lack of of encodings
    
  15. type changed to: "Bug"