Skip to content
Tcl Source Code History Of Ticket 218972
Login

History Of Ticket 218972

Artifacts Associated With Ticket 218972

  1. Ticket change [73e201497f] (rid 105110) by nobody on 2000-10-26 01:08:49:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 3373 Bug
      Version: 8.2.1
      SubmitDate: '1999-11-05'
      LastModified: '1999-11-30'
      Severity: MED
      Status: Released
      Submitter: techsupp
      ChangedBy: hobbs
      RelatedBugIDs: 2560
      OS: Other
      OSVersion: Dynix/Ptx-4.0
      FixedDate: '1999-11-30'
      FixedInVersion: 8.2.3
      ClosedDate: '2000-10-25'
      
      
      Name:
      
      Jackson McCann
      
      
      Comments:
      
      The patch supplied cures the problem under dynix/ptx but is probably a
      
          bit heavy handed.  A better approach might be to allow a package to mark
      
          itself as unloadable? Or to take advantage of the fact that atexit
      
          functions are called in the reverse of the order they are registered in.
      
          Moving the package unload to its own atexit function which is registered
      
          as part of the interpreters startup?
      
      
      ReproducibleScript:
      
      /*
      
          ** The following tcl extension demostrates the problem.  Compile it as
      
          a
      
          ** loadable shared library. It registers an atexit function but because
      
          ** tcl now unloads the shared library as part of its exit processing
      
          the
      
          ** atexit function causes the memory violation.
      
          */
      
      
          #include <tcl.h>
      
      
          static void my_exit(void)
      
          {
      
              printf("Goodbye\n") ;
      
          }
      
      
          static int _wrap_Times_Two(ClientData clientData,
      
                                          Tcl_Interp *interp,
      
                                          int objc,
      
                                          Tcl_Obj *CONST objv[]) {
      
      
              int  _result;
      
              unsigned long  _arg0;
      
              long  _arg1 = 0;
      
              Tcl_Obj * tcl_result;
      
              int tempint;
      
      
              clientData = clientData; objv = objv;
      
              tcl_result = Tcl_GetObjResult(interp);
      
              if ((objc < 2) || (objc > 3))
      
              {
      
                  Tcl_SetStringObj(tcl_result,
      
                                   "Wrong # args. Tuxedo::Tpbegin timeout ?flags?
      
          ",
      
                                   -1);
      
                  return TCL_ERROR;
      
              }
      
      
              if (Tcl_GetIntFromObj(interp,objv[1],&tempint) == TCL_ERROR)
      
                  return TCL_ERROR;
      
      
              _arg0 = (unsigned long ) tempint;
      
      
              if (objc >2)
      
              { 
      
                  if (Tcl_GetIntFromObj(interp,objv[2],&tempint) == TCL_ERROR)
      
                      return TCL_ERROR;
      
                  _arg1 = (long ) tempint;
      
              }
      
      
              _result = _arg0 * 2 ;
      
      
              tcl_result = Tcl_GetObjResult(interp);
      
              Tcl_SetIntObj(tcl_result,(long) _result);
      
              return TCL_OK;
      
          }
      
      
          int Times_two_Init (Tcl_Interp *interp) {
      
      
              if (interp == 0) 
      
                  return TCL_ERROR;
      
      
              Tcl_Eval(interp,"namespace eval Tuxedo { }");
      
      
              if (Tcl_InitStubs(interp, "8.0", 0) == NULL) {
      
                  return TCL_ERROR ;
      
              }
      
      
              Tcl_CreateObjCommand(interp,
      
                                   "Times_Two",
      
                                   _wrap_Times_Two,
      
                                   (ClientData) NULL,
      
                                   (Tcl_CmdDeleteProc *) NULL);
      
      
              if (atexit(my_exit) != 0 )
      
              {
      
                  printf("No atexit\n") ;
      
                  return TCL_ERROR ;
      
              }
      
      
              return TCL_OK;
      
          }
      
      
      ObservedBehavior:
      
      Core dump on exit if a shared library that registers an atexit function
      
          is loaded.
      
      
      DesiredBehavior:
      
      No core dump
      
      
      Patch:
      
      *** ../generic/tclLoad.c Mon Oct 11 12:05:43 1999
      
      --- ../generic/tclLoad.c.orig Mon Oct 11 12:05:39 1999
      
      ***************
      
      *** 645,663 ****
      
            while (firstPackagePtr != NULL) {
      
        pkgPtr = firstPackagePtr;
      
        firstPackagePtr = pkgPtr->nextPtr;
      
      ! 
      
      !         /*
      
      !         ** Don't automatically remove shared libraries from memory at shutdown.
      
      !         ** There may be a reference to code in the shared libary in an atexit()
      
      !         ** exit handler
      
      !         */
      
      ! 
      
      !         /*
      
      !           if (pkgPtr->fileName[0] != '\0') {
      
      !               TclpUnloadFile(pkgPtr->clientData);
      
        }
      
      -         */
      
      -         
      
        ckfree(pkgPtr->fileName);
      
        ckfree(pkgPtr->packageName);
      
        ckfree((char *) pkgPtr);
      
      --- 645,653 ----
      
            while (firstPackagePtr != NULL) {
      
        pkgPtr = firstPackagePtr;
      
        firstPackagePtr = pkgPtr->nextPtr;
      
      ! if (pkgPtr->fileName[0] != '\0') {
      
      !     TclpUnloadFile(pkgPtr->clientData);
      
        }
      
        ckfree(pkgPtr->fileName);
      
        ckfree(pkgPtr->packageName);
      
        ckfree((char *) pkgPtr);
      
      
      PatchFiles:
      
      generic/tclLoad.c
      
      
      
      
      8.2.3 was changed to not unload any DLLs when finalizing,
      allowing for code like the (bad) use of atexit above to function
      without a core.  8.3 should be improved to allow the user to
      specify whether the dll should be unloaded or not.  Users should
      use Tcl_CreateExitHandler from Tcl instead of atexit. 
      -- 11/30/1999 hobbs
      
    4. foundin initialized to: "obsolete: 8.2.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to:
      tcl core dumps (sigsegv) on exit under unix (sequent dynix/p
      
    11. type initialized to: "Bug"
  2. Ticket change [bcf8d402a4] (rid 101833) by welch on 2000-10-26 08:32:16:

    1. closedate changed to: "2000-10-26T01:32:16"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [8fdf7b787b] (rid 120347) by dgp on 2001-04-19 04:18:22:

    1. closedate changed to: "2001-04-18T21:18:22"
    2. closer changed to: "dgp"
    3. subsystem changed to: "02. Event Loops"