Tcl Source Code

View Ticket
Login
Ticket UUID: 218821
Title: Memory leak on thread creation
Type: Bug Created on: 2000-10-26 01:05:59
Submitter: nobody Assigned to: nobody
Subsystem: 49. Threading Severity:
Priority: 2 Last modified: 2000-10-26 08:29:17
Status: Closed Closed by: welch
Resolution: Fixed Closed on: 2000-10-26 01:29:17
Version: obsolete: 8.1
Description:
OriginalBugID: 2254 Bug
Version: 8.1
SubmitDate: '1999-06-21'
LastModified: '1999-07-01'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: foster
OS: Other
Machine: NA
FixedDate: '1999-06-21'
FixedInVersion: 8.2b1
ClosedDate: '2000-10-25'


Name:
Andrej Vckovski

CVS:
tclUnixThrd.c 1.18 98/02/19 14:24:12

ObservedBehavior:
in TclpThreadCreate(), the pthread_attr_t attr structure is not
    destroyed.
    This causes a Memory Leak. However, I am not 100% sure if that's really
    ok, as I
    as a uninitalized memory read on thr_create() after fixing this. But
    according
    to POSIX threads definition an attr structure needs to be destroyed
    after usage.

DesiredBehavior:
no leak

Patch:
*** tclUnixThrd.c       Fri Jun 18 20:48:24 1999
--- tclUnixThrd.c.fixed Fri Jun 18 19:53:42 1999
***************
*** 71,85 ****
      Tcl_ThreadCreateProc proc;                /* Main() function of the thread */
      ClientData clientData;            /* The one argument to Main() */
  {
      pthread_attr_t attr;

      pthread_attr_init(&attr);
      pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
      if (pthread_create((pthread_t *)idPtr, &attr, (void * (*)())proc, (void *)clientData) < 0) {
!       return TCL_ERROR;
      } else {
!       return TCL_OK;
      }
  }

  /*
--- 71,88 ----
      Tcl_ThreadCreateProc proc;                /* Main() function of the thread */
      ClientData clientData;            /* The one argument to Main() */
  {
+     int res;
      pthread_attr_t attr;

      pthread_attr_init(&attr);
      pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
      if (pthread_create((pthread_t *)idPtr, &attr, (void * (*)())proc, (void *)clientData) < 0) {
!       res = TCL_ERROR;
      } else {
!       res = TCL_OK;
      }
+     pthread_attr_destroy(&attr);
+     return res;
  }

  /*

PatchFiles:
tclUnixThrd.c



06/21/1999 11:53 - stanton - Applied patch