summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-09-18 18:19:49 +0000
committerGreg Clayton <gclayton@apple.com>2012-09-18 18:19:49 +0000
commit813ddfcdd084ad1d979123784ea6ff1b813cf6b6 (patch)
tree593e59a5d1572fa3e685caa6ed96432d31a666e4 /lldb/source/Host
parent63d2a23618759811ab83edfdb492b508ec4072fa (diff)
downloadbcm5719-llvm-813ddfcdd084ad1d979123784ea6ff1b813cf6b6.tar.gz
bcm5719-llvm-813ddfcdd084ad1d979123784ea6ff1b813cf6b6.zip
<rdar://problem/12219840>
Don't leak mach ports when calling "mach_thread_self()". llvm-svn: 164152
Diffstat (limited to 'lldb/source/Host')
-rw-r--r--lldb/source/Host/common/Host.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 4b23ff412ab..400f493d2c3 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -39,6 +39,7 @@
#include <dispatch/dispatch.h>
#include <libproc.h>
#include <mach-o/dyld.h>
+#include <mach/mach_port.h>
#include <sys/sysctl.h>
@@ -430,7 +431,12 @@ lldb::tid_t
Host::GetCurrentThreadID()
{
#if defined (__APPLE__)
- return ::mach_thread_self();
+ // Calling "mach_port_deallocate()" bumps the reference count on the thread
+ // port, so we need to deallocate it. mach_task_self() doesn't bump the ref
+ // count.
+ thread_port_t thread_self = mach_thread_self();
+ mach_port_deallocate(mach_task_self(), thread_self);
+ return thread_self;
#elif defined(__FreeBSD__)
return lldb::tid_t(pthread_getthreadid_np());
#else
OpenPOWER on IntegriCloud