Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2b81c100ce6c493f4b13e6898f0738225290e954edb32189720296f27fb33b2c
Ticket: 28027d8bb7745fb053954276bb62aa4d6e340b16
Per-interp Loaded library structures not cleaned up on interp exit.
User & Date: pooryorick on 2021-05-15 22:30:31
Changes

  1. icomment:
    Fixed in [a4de334c5f297a92].  In order to properly clean up, the loaded
    package, in this case pkgua.c, must be notified when a command is deleted so
    that it can adjust its books accordingly.  A new callback, CommandDeleted, is
    provided to Tcl_CreateObjCommand, and it does the accounting so that the unload
    routine doesn't try to delete a command that has already been deleted.
    
    Additionally, a new routine, UnloadLibrary, serves both Tcl_UnloadObjCmd and
    LoadCleanupProc, which takes care of cleanup when an interpreter is deleted.
    See [723d1eb93779e81b].  UnloadLibrary performs two distinct functions:
    
    * remove the library from an interpreter
    
    * unload the library from the process
    
    It is valid to remove  library from an interpreter without unloading the
    library from the process.  Static libraries, for example, can not be unloaded
    from the process, but unloading them from an interpreter cleans up storage
    allocated to keep track of libraries loaded into interpreters.  In order to
    completely clean up on interpreter deletion, it is necessary to deallocate this
    storage, even for a static library.
    
    This new implementation also relies on a change made to
    tclBasic.c/DeleteInterpProc:  When associated data is deleted, the
    corresponding Tcl_InterpDeleteProc is now called before the data is actually
    deleted instead of after.  This allows the Tcl_InterpDeleteProc to use the
    associated data. See commit [ccfd61a7cf6bce85].
    
  2. login: "pooryorick"
  3. mimetype: "text/x-fossil-wiki"
  4. resolution changed to: "Fixed"