Skip to content
Tcl Source Code History Of Ticket 579617ffffffffff
Login

History Of Ticket 579617ffffffffff

Artifacts Associated With Ticket 579617ffffffffff

  1. Ticket change [3ef925ec77] (rid 121372) by jcw on 2002-07-10 13:09:22:

    1. assignee initialized to: "dgp"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Context: tclkit, which uses the std unix/tclAppInit.c, 
      but overrides Tcl_AppInit (using TCL_LOCAL_APPINIT).
      
      Basic logic, from my (fragmentary) understanding:
         std main starts
         does a Tcl_FindExecutable
         launches custom tclkit_AppInit
         loads a few static extensions
         sets up a preinit script [1]
         call Tcl_Init
      
      The tclkit init code is relatively small, it's at:
         http://www.equi4.com/metakit/viewcvs.cgi/*checkout*/
      tclkit/src/kitInit.c?rev=1.9
      
      [1] The preinit script is the one that loads TclVFS 
      which provides scripting access to the VFS C layer in 
      the Tcl core.
      
      ----
      Observed behavior: on Unix/Linux, "encoding system" 
      returns "identity".  UNLESS the executable is run on the 
      build machine - THEN it find the installed encodings due 
      to the fact that it remembers (!) a static absolute path 
      of where the tcl8.4/ area is installed.
      ----
      
      The special situation in Tclkit is that it stores 
      encoding files inside a VFS, and that it uses a bit of 
      Tcl scripting to set things up *before* encoding files 
      can be accessed.
      
      Therefore the first call to Tcl_FindExecutable will not 
      be able to get encodings right - nor even a call to 
      Tcl_SetDefaultEncodingDir - because at least one interp 
      has to run scripts before VFS is ready.
      
      For that reason, Tclkit includes a "librarypath" command 
      coded in C, written by Vince Darley, which gets called 
      from Tcl as soon as the VFS mount is in place.  The code 
      for this is a few dozen lines, see:
         http://www.equi4.com/metakit/viewcvs.cgi/*checkout*/
      tclkit/src/pwb.c?rev=1.6
      
      The essential calls there are:
              TclSetLibraryPath(Tcl_NewListObj(1,&path));
              TclpSetInitialEncodings();
              Tcl_FindExecutable(Tcl_GetVar(interp, "argv0", 
      TCL_GLOBAL_ONLY));
      
      What happens, is that Tcl_FindeExecutable gets called a 
      second time - not sure why this is needed.
      
      Any help on this issue would be greatly appreciated - 
      I'm sort of way beyond my understanding of how things 
      work or could be made to work...
      
      Perhaps unrelated, but worth noting, is that tclkit also 
      has trouble when run through a symlink (this is 
      definitely of secondary imortance to me for now).
      
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "jcw"
    9. subsystem initialized to: "38. Init - Library - Autoload"
    10. title initialized to: "encodings can't be found"
    11. type initialized to: "Bug"
  2. Ticket change [a42b8d9dcc] (rid 110167) by jcw on 2002-07-10 20:26:22:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      Whoops, bad title description: the encodings do get loaded 
      fine, "encoding names" gives the subset I expect.  It's just 
      that the init is not happening, "encoding system" ends up 
      being "identity" on startup.
      
      Win32 works fine, different code path.
      
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  3. Ticket change [23bef29134] (rid 130991) by jenglish on 2002-07-11 07:45:06:

    1. icomment:
      Logged In: YES 
      user_id=68433
      
      Part of the problem is that Tcl_FindExecutable() does a
      whole lot more than just finding the executable.  It also
      (indirectly) initializes all subsystems, sets the library
      path, and sets the encoding path.
      
      This presents something of a catch-22 for TclKit and similar
      programs: they need to find the executable to mount the VFS
      to set the library and encoding paths, but by the time
      Tcl_FindExecutable() returns these have already been set
      (after crawling up the filesystem looking for something that
      either isn't there or shouldn't be used!)
      
      We can't change Tcl_FindExecutable() (too many custom Tcl
      shells rely on this behaviour), but having a different
      routine that _only_ finds the executable would be helpful. 
      This wouldn't even need to go in the stubs table -- it, like
      Tcl_Main, is only needed for application initialization. 
      
      
    2. login: "jenglish"
    3. mimetype: "text/plain"
    4. username: "jenglish"
  4. Ticket change [368b74b8a1] (rid 107120) by jcw on 2002-07-11 07:55:27:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      It's more complex, I think.  I need to find the exe, init all 
      subsystems, create an interp, *and* run a script.  Only then 
      is the VFS ready to be mounted.  And only after that mount 
      can I tell Tcl where to find encoding files.
      
      One could pull out things, turn them to C code, so Tcl gets 
      used less in the above sequence.  But that seems a step back.
      
      Note also that in the end, I do get the proper encoding files 
      known to the system.  The only issue seems to be that the 
      default encoding is not set (no longer, perhaps?).
      
      Preventing TclKit from finding encoding files outside itself 
      (unless directed to do so) is less important, since it'll 
      just reset the encoding path later.  Then again, it seems odd 
      that one cannot somehow prevent Tcl from doing all that.
      
      Appreciate the comments though - it's becoming a bit clearer.
      
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  5. Ticket change [b66c1a2fae] (rid 125420) by dgp on 2003-11-13 08:01:13:

    1. foundin changed to: "obsolete: 8.5a0"
  6. Ticket change [395b727b62] (rid 112375) by dgp on 2004-12-11 04:24:19:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      In Tcl 8.5a2, Tcl_FindExecutable()
      and its components got a substantial
      rewrite.  The body of T_FE now
      clearly show the various things it does:
      {
          TclInitSubsystems();
          TclpSetInitialEncodings();
          TclpFindExecutable(argv0);
      }
      
      The TclInitSubsystems() call 
      represents the fundamental initialization
      of the Tcl library.  Without this call coming
      first, many of the routines (even public ones)
      of the Tcl library will fail or even crash.
      
      Currently there are two public routines
      that in turn call TclInitSubsystems,
      Tcl_FindExecutable() and Tcl_CreateInterp().
      Any code making calls into the Tcl library
      should be written so that its know one of these
      routines has been called first.
      
      It may be to our advantage to make
      TclInitSubsystems() itself a public
      routine (with the name Tcl_Initialize() ?)
      so that the responsibilities of callers
      are easier to describe (call Tcl_Initialize()
      first; call Tcl_Finalize() when the library
      won't be called anymore).
      
      After TclInitSubsystems() returns, all
      of Tcl's public routines should be
      "crash safe" when called according to
      their documentation.
      
      TclpSetInitialEncodings makes an
      attempt to initialize [encoding system]
      according to the environment of the
      process.  Its implementation is:
      {
          Tcl_DString encodingName;
          Tcl_SetSystemEncoding(NULL,
                  TclpGetEncodingNameFromEnvironment(&encodingName));
          Tcl_DStringFree(&encodingName);
      }
      
      TclpSetInitialEncodings() might
      correctly initialize [encoding system],
      or it might not.  When it cannot, it will
      leave [encoding system] with the value
      of "identity".  Tclkit will face this situation,
      because at the time Tcl_FindExecutable
      is called, the *.enc files will not be found
      on the encoding search path yet.
      
      We should make
      TclpGetEncodingNameFromEnvironment()
      a public routine so that callers of the
      Tcl library can check at any time whether
      the value of [encoding system] agrees
      with what Tcl thinks the environment
      expects it to be.  With that routine public,
      Tclkit can easily repeat the [encoding system]
      initialization attempt after it is satisfied that
      a proper encoding search path is in place.
      
      Finally, TclpFindExecutable() performs
      the function of initializing [info nameofexecutable].
      The value is stored as a ProcessGlobalValue
      - a new kid of struct in the Tcl library - that automatically
      adapts itself to any changes in [encoding system].
      
      With Tcl 8.4, Tclkit's LibraryPathObjCmd had to
      make a second call to Tcl_FindExecutable to
      reset the proper encoding for the [info noe] value.
      That is no longer required, and in fact causes a
      problem.
      
      Startup sequence recommendation for Tclkit
      is now:
      
          TclInitSubsystems();
          TclSetEncodingSearchPath(Tcl_NewObj());
          Tcl_Main(...)
      
      and within LibraryPathObjCmd():
      
          Tcl_DString encodingName;
          TclSetEncodingSearchPath(objv[1]);
          Tcl_SetSystemEncoding(NULL,
                  TclpGetEncodingNameFromEnvironment(&encodingName));
          Tcl_DStringFree(&encodingName);
      
      and within boot.tcl:
      
          libraryPath [file join [info library] encoding]
      
      Additional cosmetic change might be to rename
      [libraryPath] to [encodingPath] since that's what's
      really being set.
      
      Tcl should expose a script level command to allow
      setting of the encoding search path.  That might
      lead to a line in boot.tcl something like:
      
          encoding dirs [file join [info library] encoding]
      
      A re-attempt to set [encoding system] would then
      be needed, and that might mean exposing 
      TclpGetEncodingNameFromEnvironment at
      the script level as well.
      
      I think working source code changes for Tclkit 8.5a2
      have been fed back now.  Comments on continuing
      plans are invited.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [5b111644ca] (rid 118250) by dgp on 2004-12-11 04:29:27:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      > Currently there are two public routines
      > that in turn call TclInitSubsystems,
      > Tcl_FindExecutable() and Tcl_CreateInterp().
      > Any code making calls into the Tcl library
      > should be written so that its know one of these
      > routines has been called first.
      
      Some readers might want to know
      that Tcl_Main() and Tk_Main(Ex)() are
      on the "safe list".  Each of them calls
      the routines above.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  8. Ticket change [84e4d11618] (rid 117638) by dgp on 2004-12-11 05:35:24:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      > Startup sequence recommendation for Tclkit
      > is now:
      
      >    TclInitSubsystems();
      >    TclSetEncodingSearchPath(Tcl_NewObj());
      >    Tcl_Main(...)
      
      Worth noting that those changes are
      optional.  All they would so is set
      Tcl's encoding search path to an
      empty path before the Tcl_FindExecutable()
      within Tcl_Main() gets called.  The result
      is the same either way -- Tcl in Tclkit won't be able
      to find any *.enc files -- but it can "not find anything"
      faster when it doesn't have to search anything. 
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  9. Ticket change [0b68fd7ffe] (rid 113981) by jcw on 2004-12-11 06:27:11:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      Ok, looks like TIS and TSESP could be done via a #define 
      TCL_LOCAL_APPINIT 
      (tclkit uses the standard tcl/unix/tclAppInit.c).  The LibraryPathObjCmd 
      change is clear (and yes, make "encoding dirs ..." a core cmd, please, so I 
      can get rid of pwb.c altogether.
      
      FWIW, I'm removing classic Mac support from kitInit.c, the rest is 
      97.138% clean - only thing left, for another time, is a pesky irregularity in 
      calling TclSetStartupScriptPath too late.
      
      Thanks for a wonderful explanation and a great leap forward in startup 
      logic clarity!
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  10. Ticket change [4dbe249f39] (rid 127101) by dgp on 2005-10-03 23:16:01:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      TIP 258 proposes the public
      versions of the routines and
      commands mentioned in prior
      comments.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [e26f1992d5] (rid 87625) by dgp on 2006-02-21 21:44:59:

    1. closedate changed to: "2006-02-21T14:44:59"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      
      TIP 258 is in the HEAD.
      Please confirm that it
      resolves this bug.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Pending"
    8. username: "dgp"
  12. Ticket change [0b64ee120f] (rid 113978) by jcw on 2006-03-03 22:02:08:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      I've removed the "pwb" extension from 8.5 builds of tclkit, and changed the 
      ini sequence to use "encoding dirs".  Result verified to find iso8859-1 on a 
      Linux build, when the build dir is not reachable.
      
      I'm not 100% sure that it solves everything, though.  See the new boot.tcl at 
      http://www.equi4.com/pub/tk/tars/runtime85-sh.kit/boot.tcl - there is still 
      'if {[encoding system] eq "identity"} { ...}' code in there, and it cannot be 
      dropped.
      
      My take on it is that encodings were absent during startup, tclkit correctly 
      adjusted them later on with the new "encoding dirs" call, and now it has to fix 
      the fact that the encoding started out as unset (i.e. "identity").
      
      If that's as expected, then I think this issue can be closed.
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "jcw"
  13. Ticket change [5ddc1bb7b7] (rid 115539) by dgp on 2006-03-03 23:38:57:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      
      Not exactly what I imagined, but
      perhaps it will work.
      
      I expected to see a C level call
      to Tcl_GetEncodingNameFromEnvironment()
      so Tcl can tell you what it thinks
      [encoding system] ought to be.  Then
      you can check Tcl_GetEncoding(NULL)
      and find out if [encoding system] has
      in fact been set to that desired value.
      
      The script level check
      {[encoding system] eq "identity"}
      isn't precisely the same test, but might
      well have equivalent results.
      
      The open Q which is really for Tclkit
      instead of Tcl is how you want to
      react when the correct [encoding system]
      has not been set.  It looks like you plan
      to just leave the "identity" value in place
      for the code in a starkit to detect and
      possibly replace after mounting more
      virtual filesystems?  How is that starkit
      code supposed to know what the correct
      [encoding system] value ought to be?
      Do we need to expose
      Tcl_GetEncodingNameFromEnvironment() to
      the script level to complete the
      script-level toolkit required to deal
      with these matters?  Or is there some
      way Tclkit can take care of this and
      relieve each starkit author of that burden?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  14. Ticket change [fb77c7a49c] (rid 92069) by jcw on 2006-03-04 00:22:43:

    1. icomment:
      Logged In: YES 
      user_id=1983
      
      All I can do in tclkit is modify either kitInit.c, the startup, or boot.tcl, the second 
      step.  Given that boot.tcl is already running by the time VFS is ok, I don't think 
      anything can be done at the C level anymore (unless the pwb extension is 
      brought back, which I was so happy to get rid of).  So yes, if we had an 
      "encoding default" or some such to wrap Tcl_GENFE, I could simply get VFS set 
      up and finish off with "encoding system [encoding default]" instead of the 
      current platform-specific guesswork.
      
      
    2. login: "jcw"
    3. mimetype: "text/plain"
    4. username: "jcw"
  15. Ticket change [dd25bda0bb] (rid 114612) by dgp on 2008-04-15 22:57:51:

    1. closedate changed to: "2008-04-15T15:57:51"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Doesn't appear to be a bug left here now.
      
      If that's incorrect, open a new one.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. status changed to: "Pending"
    7. username: "dgp"
  16. Ticket change [bc489f835b] (rid 101726) by sf-robot on 2008-04-30 09:20:25:

    1. closedate changed to: "2008-04-30T02:20:25"
    2. closer changed to: "sf-robot"
    3. icomment:
      Logged In: YES 
      user_id=1312539
      Originator: NO
      
      This Tracker item was closed automatically by the system. It was
      previously set to a Pending status, and the original submitter
      did not respond within 14 days (the time period specified by
      the administrator of this Tracker).
      
      
    4. login: "sf-robot"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "sf-robot"