Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-02-09
10:20 • Closed ticket [1350946fff]: Tcl_CreateSlave forgets tcl_library plus 6 other... artifact: a77bd5c5b0 user: sf-robot
2006-01-25
23:07 • Ticket [1350946fff]: 2 changes artifact: f118d4e779 user: dgp
23:07 • Pending ticket [1350946fff]. artifact: 19c2bc6092 user: dgp
2005-11-09
04:49 • Ticket [1350946fff]: 4 changes artifact: b455ad2fa9 user: dgp
2005-11-08
05:19 • New ticket [1350946fff]. artifact: 36acee154b user: nobody

Tcl_CreateSlave forgets tcl_library

Closed / Invalid1350946fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-11-08 05:19:08
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)
dgpplain2005-11-09 04:49:11
Logged In: YES 
user_id=80530


There may be a bug or
a feature request here, but
I need some help figuring it out.
Excerpting...

"<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"

Ok, first the whole thing sounds pretty
dicey to me, but assuming you make
it work, why does each Tcl_Interp
need to have ::tcl_library set to
find "the right path" for finding init.tcl ?
Any properly installed Tcl library
ought to be able to find "the right" init.tcl
without assistance.  

If you find that not to be true, I'd suggest
that's the real bug needing to be tracked
down and corrected.

It is true that Tcl_CreateSlave() doesn't
offer the same hooks as Tcl_Main() for
getting at the interp prior to the Tcl_Init()
call.  That might suggest the need for
an enhancement, but I'll want to understand
your motivating case better before I go there.
dgpplain2006-01-25 23:07:58
Logged In: YES 
user_id=80530


Without additional comment on
this, there's nothing more I
can do.  set to pending...
dgp Ticket [1350946fff]: 2 changes [History diff]2006-01-25 23:07:59
sf-robotplain2006-02-09 10:20:20
Logged In: YES 
user_id=1312539

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).
Log in (anonymous is fine) to add a comment.