aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2018-01-19 19:35:09 (GMT)
committerCaroline Tice <cmtice@google.com>2018-01-19 20:16:59 (GMT)
commit46936205f991de051a9555a03f856683475a2be5 (patch)
tree43a40ca1a767c43d1e93a9bc3318b65f16357e8c
parentdca601e5d2b032ac5cca1df90ac56077ccf5d665 (diff)
downloadtoolchain_gcc-46936205f991de051a9555a03f856683475a2be5.zip
toolchain_gcc-46936205f991de051a9555a03f856683475a2be5.tar.gz
toolchain_gcc-46936205f991de051a9555a03f856683475a2be5.tar.bz2
[libgcc] Fix emutls.c to not leak pthread keys.
Bug:b/71814577 Test:Built toolchain w/change and successfully tested building both platform and kernel images with new toolchain for marlin (pixel) device. Change-Id: Ia0c6944ce1d78b5bd57d65f705a3f7a59c944202
-rw-r--r--gcc-4.9/libgcc/emutls.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc-4.9/libgcc/emutls.c b/gcc-4.9/libgcc/emutls.c
index fd6d86e..77550e0 100644
--- a/gcc-4.9/libgcc/emutls.c
+++ b/gcc-4.9/libgcc/emutls.c
@@ -60,6 +60,7 @@ static __gthread_mutex_t emutls_mutex = __GTHREAD_MUTEX_INIT;
static __gthread_mutex_t emutls_mutex;
#endif
static __gthread_key_t emutls_key;
+static int emutls_key_created = 0;
static pointer emutls_size;
static void
@@ -86,9 +87,18 @@ emutls_init (void)
#endif
if (__gthread_key_create (&emutls_key, emutls_destroy) != 0)
abort ();
+ emutls_key_created = 1;
}
#endif
+__attribute__((destructor))
+static void
+unregister_emutls_key (void)
+{
+ if (emutls_key_created)
+ __gthread_key_delete (emutls_key);
+}
+
static void *
emutls_alloc (struct __emutls_object *obj)
{