Artifacts Associated With Ticket 1176470
Ticket change [0a81fa3767] (rid 113829) by eriklns on 2005-04-04 16:31:24:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
L.S. Two unexpected results occur when importing packages which load compiled code: 1. When doing [package forget], the entry of the corresponding shared library is not removed from what's returned by [info loaded]. 2. After having done [package forget], and issuing again [package require], an error message is returned: "can't find package ..." An example session that exercises the above sequence for Tkhtml and Tktable is appended to this message. A discussion in c.l.t. (started at 4-Apr-2005, featuring Michael Schlenker, Don Porter and yours truly) arrived at the point where dgp judges there is either a bug here or a misfeature. Erik Leunissen ============== Example Tcl session: --------------- % info loaded {{} Tk} % package require Tkhtml 2.0 % info loaded {/usr/lib/tk8.4/../libtk8.4.so Tk} {/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk} % package forget Tkhtml % info loaded {/usr/lib/tk8.4/../libtk8.4.so Tk} {/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk} % package require Tkhtml can't find package Tkhtml % package require Tktable 2.8 % info loaded {/usr/local/lib/Tktable2.8/libTktable2.8.so Tktable} {/usr/lib/tk8.4/../libtk8.4.so Tk} {/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk} % info loaded {/usr/local/lib/Tktable2.8/libTktable2.8.so Tktable} {/usr/lib/tk8.4/../libtk8.4.so Tk} {/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk} % package forget Tktable % info loaded {/usr/local/lib/Tktable2.8/libTktable2.8.so Tktable} {/usr/lib/tk8.4/../libtk8.4.so Tk} {/usr/local/lib/Tkhtml2.0/libTkhtml2.0.so Tkhtml} {{} Tk} % package require Tktable can't find package Tktable -- end of message -- -- leunissen@ nl | Merge the left part of these two lines into one, e. hccnet. | respecting a character's position in a line. - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "eriklns"
- subsystem initialized to: "None"
- title initialized to: "Registration of [loaded] packages"
- type initialized to: "RFE"
Ticket change [ac956bacdd] (rid 101323) by dgp on 2005-04-04 23:48:21:
- assignee changed to: "kennykb"
- foundin changed to: "obsolete: 8.5a3"
- icomment:
Logged In: YES user_id=80530 I'd have expected each [load] command to call the *_Init() routine again. That said, [package forget] is a rather specialized operation; not really meant for much use in programs. Avoid if possible.
- login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "40. Dynamic Loading"
- username: "dgp"
Ticket change [aa0ea21484] (rid 99256) by hobbs on 2005-04-05 00:30:58:
- closedate changed to: "2005-04-04T17:30:58"
- closer changed to: "hobbs"
- icomment:
Logged In: YES user_id=72656 This is clearly a misunderstanding on the part of the user. Maybe the docs need clarification, but it's not a bug. package forget forgets the 'ifneeded' part, which is of course why the next package require will fail. It does nothing else - it does not unload any packages. The 'info loaded' is still 100% correct, as those dlls are still loaded. You could still say 'load {} Tkhtml|Tktable' and they will load. - login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "hobbs"
Ticket change [71a73c4031] (rid 100724) by dgp on 2005-04-05 00:40:04:
- icomment:
Logged In: YES user_id=80530 "package forget forgets the 'ifneeded' part, which is of course why the next package require will fail." Not so. [package forget] will forget all the ifneeded scripts for all versions of Tkhtml, so the next [package require Tkhtml] will invoke [package unknown] to find those scripts again. Nothing in the report suggests that second search fails. The ifneeded script(s) get restored back to the package database, but the report is that they do not work the second time because [load] doesn't work on the second pass. "You could still say 'load {} Tkhtml|Tktable' and they will load." As I understand the report, this is not working. - login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Remind"
- status changed to: "Open"
- username: "dgp"
- icomment:
Ticket change [116e8bf59d] (rid 95143) by dgp on 2005-04-05 01:02:12:
- assignee changed to: "dgp"
- closedate changed to: "2005-04-04T18:02:12"
- closer changed to: "dgp"
- icomment:
Logged In: YES user_id=80530 Thinking more about this, having [load] call the same Foo_Init() routine a second time also has problems. It's quite likely many existing packages haven't had their Foo_Init() routines written to handle that case. Seems the only reasonable advice that can be given is: DO NOT USE [package forget].
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Pending"
- username: "dgp"
Ticket change [d71e5a7285] (rid 123924) by hobbs on 2005-04-05 02:17:46:
- closedate changed to: "2005-04-04T19:17:46"
- closer changed to: "hobbs"
- icomment:
Logged In: YES user_id=72656 As to the 'load {} Tkhtml|Tktable', it certainly does still work, as would be expected when the library is still loaded. Tested with Tktable just fine. I would agree that 'package forget' mostly sucks in terms of being confusing/useless. - login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
Ticket change [f5c81f51dc] (rid 130173) by eriklns on 2005-04-06 23:52:09:
- icomment:
Logged In: YES user_id=113903 The manual page for [load] says: "If a given fileName is loaded into multiple interpreters, then the first load will load the code and call the initialization procedure; subsequent loads will call the initialization procedure without loading the code again. It is not possible to unload or reload a package." I've tested this with a small package "loadtest", by letting Loadtest_Init emit a message to stdout. When exercising the following at the Tcl prompt you will find that the message is emitted with the first [load] command. I didn't see that message when issuing the command the second time and the namespace ::loadtest, created at the first load, then deleted with ::loadtest::terminate, was not recreated with the second [load]. % load ./loadtest/loadtest.so % namespace exists ::loadtest 1 % loadtest::terminate % namespace exists ::loadtest 0 % info loaded {./loadtest/loadtest.so Loadtest} {{} Tk} % load {} Loadtest % namespace exists ::loadtest 0 % Therefore, I believe that the _Init proc is not called a second time as the man page desscribes. The C code with build script has been uploaded. - login: "eriklns"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "eriklns"
- icomment:
Ticket change [ea67940070] (rid 103377) by eriklns on 2005-04-06 23:52:42:
- closedate changed to: "2005-04-06T16:52:42"
- closer changed to: "eriklns"
- status changed to: "Pending"
Ticket change [765eae797e] (rid 105576) by eriklns on 2005-04-06 23:59:40:
- icomment:
Logged In: YES user_id=113903 I withdraw the last post. The case that I tested was when loading into the same main interp and that is not what the man page describes. _Init will only be called a second time when loading into a different interp. Sorry.
- login: "eriklns"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "eriklns"
- icomment:
Ticket change [340d968478] (rid 106697) by dgp on 2005-11-17 01:39:24:
- icomment:
Logged In: YES user_id=80530 Converting this into a Feature Request for Tcl 8.5
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [39cff83c40] (rid 112453) by dgp on 2005-11-17 01:45:23:
- icomment:
data_type - 360894
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [637b1e17cc] (rid 92588) by dgp on 2005-11-17 01:45:24:
- assignee changed to: "kennykb"
- foundin changed to: "None"
- subsystem changed to: "40. Dynamic Loading"
Ticket change [50ae7d64d0] (rid 126017) by dgp on 2005-11-17 01:45:25:
- icomment:
Logged In: YES user_id=80530 Converting this into a Feature Request for Tcl 8.5 Thing to watch out for is whether there are existing Foo_Init() routines that are not robust enough to accept multiple calls with the same interp argument. Note that the ability for a second [load] to call Foo_Init() to correct possible errors from the first Foo_Init() is more important since Bug 1162286 was fixed.
- login: "dgp"
- mimetype: "text/plain"
- title changed to: "Invoke *_*Init() for each [load] "
- username: "dgp"
- icomment: