aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2010-06-13 01:13:36 +0000
committerColin Percival <cperciva@FreeBSD.org>2010-06-13 01:13:36 +0000
commitff847ecb82efc5ec38487ab71c5f00f482e00102 (patch)
tree4fc696a236b0b4050f7803130f79d9657bdf0461 /lib/libc/stdlib
parent27d1c65e8e59b03d209d4497b5f0d9a041bca1bc (diff)
downloadsrc-ff847ecb82efc5ec38487ab71c5f00f482e00102.tar.gz
src-ff847ecb82efc5ec38487ab71c5f00f482e00102.zip
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.
Notes
Notes: svn path=/head/; revision=209117
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/atexit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c
index efd12649e009..aba3eddeea77 100644
--- a/lib/libc/stdlib/atexit.c
+++ b/lib/libc/stdlib/atexit.c
@@ -54,6 +54,7 @@ static pthread_mutex_t atexit_mutex = PTHREAD_MUTEX_INITIALIZER;
#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);
}