Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c38707a0e890e9cfe1fdfb053e3015ae0f9976f8
Ticket: 670042ffffffffffffffffffffffffffffffffff
Tcl_StaticPackage fails interp registration.
User & Date: dgp on 2003-01-17 22:58:32
Changes

  1. assignee changed to: "kennykb"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    dgpIs line 481 of tclLoad.c a bug?
    kennykbyes, dgp?
    dgpRather than a return, shouldn't that be a goto down
    to where the package is registered as loaded in a
    non-NULL interp?
    kennykbOK, let me walk through this slowly.
    dgpAs is, Tcl_StaticPackage(one,...);
    Tcl_StaticPackage(two,...);
    kennykbWe've discovered that there's a package with
    the same name and procedures statically loaded in SOME
    interp.
    dgpwill cause [info loaded {}] in interp one, to
    include foo, but [info loaded {}] in interp two will not.
    kennykbBut it doesn't have to be the current one.
    dgp"statically loaded" is a per-process question.
    kennykbHmm, but then the code down below actually has
    to check that the package ISN'T already loaded in the
    current interp?
    dgpfirstPkgPtr is a process-wide resource.
    Out of a cloud of smoke, miguel appears!
    dgpAs I understand it, it's up to the caller to get
    this right.
    kennykbexcuse me.  we've discovered that a static
    package is provided in the process... but we don't know
    that it's in [info loaded] in the current interp.
    dgpSo if the caller calls Foo_Init(two) directly, it's
    up to that caller to also call
    Tcl_StaticPackage(two,...) to keep the [info loaded]
    results correct.
    kennykbSo, you want to replace the Tcl_MutexUnlock and
    return with a break, then condition the next paragraph
    upon pkgPtr == null, yes?
    kennykbHmm, I was more concerned with two
    Tcl_StaticPackage calls for the same package in the
    same interp.
    kennykbIs that illegal, or should it simply do nothing?
    dgpthat's cleaner than the goto, yes.
    dgpIt would seem that s per-interp search for already
    registered packages would be need then, yes.
    kennykb... probably up at the top, so we can do it
    without acquiring the lock.
    kennykbHmm, then we need two more test cases, one to
    make sure that Tcl_StaticPackage gets [imfo loaded]
    right in the second interp, and one to make sure that
    you can Tcl_StaticPackage the same package twice.
    
    
    ....
    
    dgpWhat got me started was trying to grok the intent
    of Tcl_StaticPackage's modes of operation.
    kennykbOK, well, you did indeed find a bug.
    kennykbAnd you're right that the 'package' there is a
    misnomer, I quite forgot the conversation where I
    argued you into that position. 
    dgpapparently, the interp==NULL mode is just for
    saying "hey, there are two routines available, Foo_Init
    and Foo_SafeInit, and the [load] command in the future
    should associate them with the "Foo" value in its
    "package" argument.
    dgp...in all interps.
    dgpThe (interp!=NULL) mode, though, seems intended to
    make a stronger claim.
    dgpHey, that association should be made, *and*, btw,
    I've called one of those routines on this interp already.
    dgpIf that understanding is correct, I'd note that I
    derived that from looking at the code, not at the docs
    for Tcl_StaticPackage, which could be clearer.
    kennykb... and we ought to update the docs to reflect
    that understanding.
    
    
    
  4. foundin changed to: "obsolete: 8.4.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "dgp"
  9. subsystem changed to: "40. Dynamic Loading"
  10. title changed to: "Tcl_StaticPackage fails interp registration."
  11. type changed to: "Bug"