Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jun 2010 01:13:36 +0000 (UTC)
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r209117 - head/lib/libc/stdlib
Message-ID:  <201006130113.o5D1Da1b067449@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cperciva
Date: Sun Jun 13 01:13:36 2010
New Revision: 209117
URL: http://svn.freebsd.org/changeset/base/209117

Log:
  In threaded processes, destroy the mutex atexit_mutex when we've
  finished using it.  This allows the mutex's allocated memory to be
  freed.
  
  This is one sense a rather silly change, since at this point we're
  less than a microsecond away from calling _exit; but fixing this
  memory leak is likely to make life easier for anyone trying to
  track down other memory leaks.

Modified:
  head/lib/libc/stdlib/atexit.c

Modified: head/lib/libc/stdlib/atexit.c
==============================================================================
--- head/lib/libc/stdlib/atexit.c	Sat Jun 12 22:33:04 2010	(r209116)
+++ head/lib/libc/stdlib/atexit.c	Sun Jun 13 01:13:36 2010	(r209117)
@@ -54,6 +54,7 @@ static pthread_mutex_t atexit_mutex = PT
 
 #define _MUTEX_LOCK(x)		if (__isthreaded) _pthread_mutex_lock(x)
 #define _MUTEX_UNLOCK(x)	if (__isthreaded) _pthread_mutex_unlock(x)
+#define _MUTEX_DESTROY(x)	if (__isthreaded) _pthread_mutex_destroy(x)
 
 struct atexit {
 	struct atexit *next;			/* next in list */
@@ -182,4 +183,6 @@ __cxa_finalize(void *dso)
 		}
 	}
 	_MUTEX_UNLOCK(&atexit_mutex);
+	if (dso == NULL)
+		_MUTEX_DESTROY(&atexit_mutex);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006130113.o5D1Da1b067449>