Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 36acee154b90d7dc00c68850999e37794db59937
Ticket: 1350946fffffffffffffffffffffffffffffffff
Tcl_CreateSlave forgets tcl_library
User & Date: nobody on 2005-11-08 05:19:08
Changes

  1. assignee changed to: "dgp"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Cut and paste from the Tcl_Chatroom:
    
    
    <venks> Por favor: Need an answer to a quick question.
    <venks> I have a program that links multiple versions
    of tcl together
    <venks> in the part that I have written, I set
    tcl_library before initiazliing
    the interpreter, so that the right path is used for
    initialization
    <venks> when i do Tcl_CreateSlave
    <venks> the child interpreter fails to init, because it
    does not inherit the
    variable and looks for the init.tcl in the wrong places
    <venks> It seems like the tcl_library isn't
    automatically inherited
    <venks> I can't set the TCL_LIBRARY environment
    variable because it affects
    the other parts of the program that I haven't written.
    <venks> is there a hook from tcl_createslave that I can
    use before the init is
    done to set the tcl_library variable?
    <venks> or is there a way to do a Tcl_CreateSlave
    without an init?
    <venks> I could then set the tcl_libary and then do the
    init?
    <venks> I looked at the source for SlaveCreate in
    tclInterp.c
    <venks> maybe tcl_library should be inherited just like
    the recursion limit?
    <venks> is that a bug or a feature?
    <venks> maybe Tcl_CreateSlave should allow for a
    callback before doing a
    Tcl_Init on the slave interpreter
    <venks> where is tclPreInitScript defined?
    <ijchain> <miguel> venks: are you calling
    Tcl_FindExecutable()? If not ... you
      have to
    <venks> I tried that - but since it is loaded in from a
    shared library (and
    not the main
    <venks> executable) i doesn't help
    <venks> I did manage to fix it, by using
    TclSetPreInitScript
    <venks> which is defined in tclInitScript.h
    <venks> so I added a script like : set ::tcl_library
    "path to my init.tcl"
    <venks> as a parameter to tclSetPreInitScript
    <venks> and all life is good.
    <venks> thanks for listening. And miguel thanks for the
    response
    <ijchain> <miguel> glad that you made it; I can't
    really comment (not
      knowledgeable) but ...
    <ijchain> <miguel> ... if you are including more than
    tcl.h, you are very much
      on your own
    <ijchain> <miguel> Ie, we feel at liberty to modify
    internal apis. As a matter
      of fact, tclInitScript.h seems not to be in the 8.5
    sources anymore
    <ijchain> <miguel> You may be well advised to ask
    around here at some other
      time, when someone familiar with the init process
    can give you the
      right advice
    <venks> not more than one tcl.h
    <venks> onlyone
    <venks> but separate shared libraries use different
    tcl.h files
    <ijchain> <miguel> I mean: you shouldn't be calling
    stuff from tclInitScript,
      nor any function that is not called Tcl_* (note the
    underscore!)
    <ijchain> <miguel> err ... tclInitScript.h
    <venks> miguel - that wasn't an internal API
    <venks> I'm only using tcl.h
    <ijchain> <miguel> well - if it is called
    TclSetPreInitScript, it is
      internal. External functions start with Tcl_
    <venks> hmmm I don't have access to tclInt I thouht
    * venks goes checking even though it seems to work
    <venks> hmmm - seems to give an undefined - but I guess
    still works on 32 bit
    linux at least..  I wonder why it's not marked static.
    <ijchain> <miguel> it is in the internal stubs table
    <ijchain> <miguel> ie: defined in tclInt.decls, then
    generated from there into
      tclIntDecls.h and tclStubInit.c
    <venks> ok - miguel thanks.   It looks like
    TclpInitLibraryPath uses
    Tcl_GetDefaultEncodingDir
    <venks> and Tcl_SetDefaultEncodingDir IS a public function
    <ijchain> <miguel> Tclp... are also internal (and
    platform dependent)
    <ijchain> <miguel> ok - that one is public
    <ijchain> <miguel> if that works, you will be a happier
    man - if we break it,
      *we* are responsible to fix it ;)
    <venks> obrigado
    
    <venks> can I call Tcl_FindExecutable with a
    non-existent file name?
    <ijchain> <Zarutian> venks: well, why not try and see
    the results? ;) (I rekon
      that the function will error with a message telling
    the caller it
      cant find the file)
    <venks> Zarutian thanks...
    <ijchain> <jenglish> venks -- Tcl_FindExecutable has
    some deep voodoo.
    <venks> jenglish - I explained my problem a few lines
    back.   I have a binary
    which loads multiple .sos with different versions of
    Tcl statically
    linked into each
    <ijchain> <jenglish> Normally you pass it argv[0],
    which 9 times out of 10
      will find the actual executable.
    <venks> mine uses tcl 8.4 and works fine.  I set
    tcl_library global before I
    call Tcl_Init.
    <venks> but when I call Tcl_CreateSlave, it fails
    because the slave interp
    can't init because it can't find the right init.tcl
    <venks> I poked around and actually Called
    TclSetPreInitScript with a "set
    tcl_library .."
    <venks> and that works, but is obviously (as miguel
    points out) living
    dangerously
    <ijchain> <jenglish> My only advice is: do whatever
    works; but be aware that
      it's likely to break when you switch to 8.5.
    <ijchain> <jenglish> Or if you go back to 8.3.
    <ijchain> <jenglish> Or move from Windows/Unix/OSX to
    one of the other two.
    <venks> my only hope seems to be
    Tcl_SetDefaultEncodingDir or
    Tcl_FindExecutable
    <ijchain> <jenglish> It's really a horrible mess.  DGP
    is working hard at
      untangling it all, but there's still a long way to go.
    <venks> jenglish thanks for the ears .
    <ijchain> <jenglish> Do file a bug report / FR at
    sourceforge, though, so that
      your use case gets recorded.
    <ijchain> <jenglish> Another thing: in 8.4, you can
    actually get by without
      sourcing 'init.tcl'.  (You lose a few features like
    autoloading and
      history, but many applications can get by without
    those.)
    <ijchain> <jenglish> Not so in 8.5 :-(
    <venks> jenglish one thought was whether
    Tcl_CreateSlave should propagate the
    tcl_library
    <venks> that would've fixed my particular problem.
    
    
    I did later switch to Tcl_FindExecutable with the name
    of a script in the same relative location so that the
    libs would be found - but I doubt if that'll work with
    8.5 either.
    
    - Venks (http://wiki.tcl.tk/vi)
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "38. Init - Library - Autoload"
  10. title changed to: "Tcl_CreateSlave forgets tcl_library"
  11. type changed to: "Bug"