Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e970d187ff3f90b52e2b967592d3c8005d6006508fe91f672fc5f5d143d6ac91
Ticket: 8cd2fe747463756f4a4a31f726c2c0163ecde2ff
"unload" command Bug (when handling multiple libs)
User & Date: BERC on 2019-11-12 09:57:52
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    In tclLoad.c (i.e. https://core.tcl-lang.org/tcl/artifact/76192e755eed7560) there is a bug which occurs when a library is unloaded.
    In the part "Remove this library from the interpreter's library cache.", the next pointers of the linked list are not properly updated.
    
    
    		ipFirstPtr = Tcl_GetAssocData(target, "tclLoad", NULL);
    		ipPtr = ipFirstPtr;
    		if (ipPtr->pkgPtr == defaultPtr) {
    		    ipFirstPtr = ipFirstPtr->nextPtr;
    		} else {
    		    InterpPackage *ipPrevPtr;
    
    		    for (ipPrevPtr = ipPtr; ipPtr != NULL;
    			    ipPrevPtr = ipPtr, ipPtr = ipPtr->nextPtr) {
    			if (ipPtr->pkgPtr == pkgPtr) {
    			    ipPrevPtr->nextPtr = ipPtr->nextPtr;
    			    break;
    			}
    		    }
    		}
    
    should be
    
    
    		ipFirstPtr = Tcl_GetAssocData(target, "tclLoad", NULL);
    		ipPtr = ipFirstPtr;
    		if (ipPtr->pkgPtr == defaultPtr) {
    		    ipFirstPtr = ipFirstPtr->nextPtr;
    		} else {
    		    InterpPackage *ipPrevPtr;
    
    		    for (ipPrevPtr = ipPtr; ipPtr != NULL;
    			    ipPrevPtr = ipPtr, ipPtr = ipPtr->nextPtr) {
    			if (ipPtr->pkgPtr == defaultPtr) {
    			    ipPrevPtr->nextPtr = ipPtr->nextPtr;
    			    break;
    			}
    		    }
    		}
    
    
    So the check "(ipPtr->pkgPtr == pkgPtr)" should really be "(ipPtr->pkgPtr == defaultPtr)"
    
    With this bug, one can get error messages when first unloading a lib (works properly) and then unloading another one (will return error "has never been loaded in this interpreter" because it cannot be find in the list, because the linked list has been corrupted.
    
  5. foundin changed to: "Tcl 9.0a0 and older"
  6. is_private changed to: "0"
  7. login: "BERC"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "efbd17cefb5d0a14113ad516213d53b903e99650"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "BERC"
  14. subsystem changed to: "38. Init - Library - Autoload"
  15. title changed to: ""unload" command Bug (when handling multiple libs)"
  16. type changed to: "Bug"