]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Destroy the default thread attribute as part of freeres
authorFlorian Weimer <fweimer@redhat.com>
Tue, 19 May 2020 09:03:11 +0000 (11:03 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 2 Jun 2020 08:32:47 +0000 (10:32 +0200)
This avoids a spurious memory leak report by valgrind.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
nptl/nptlfreeres.c
nptl/pthreadP.h
nptl/pthread_setattr_default_np.c

index dda11e5922574ae363d70fbfbf3cebffb325d19b..07aa34adfa659039b99725cbe9a9a04daff77749 100644 (file)
@@ -25,6 +25,7 @@
 void
 __libpthread_freeres (void)
 {
+  call_function_static_weak (__default_pthread_attr_freeres);
   call_function_static_weak (__nptl_stacks_freeres);
   call_function_static_weak (__shm_directory_freeres);
   call_function_static_weak (__nptl_unwind_freeres);
index acc8e88e4a21876f304811492e5dcf26ee44dcec..ed30b7292382b79581135da831fd50ba15c9bd68 100644 (file)
@@ -201,6 +201,8 @@ enum
 /* Default pthread attributes.  */
 extern union pthread_attr_transparent __default_pthread_attr attribute_hidden;
 extern int __default_pthread_attr_lock attribute_hidden;
+/* Called from __libpthread_freeres to deallocate the default attribute.  */
+extern void __default_pthread_attr_freeres (void) attribute_hidden;
 
 /* Size and alignment of static TLS block.  */
 extern size_t __static_tls_size attribute_hidden;
index c4cfb4e8efaf222a4fc0ef6b21065b69958dd4b5..7a1c644334ea05c7774d7afdc77d2ec26454cffd 100644 (file)
@@ -81,3 +81,13 @@ pthread_setattr_default_np (const pthread_attr_t *in)
   lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE);
   return ret;
 }
+
+/* This is placed in the same file as pthread_setattr_default_np
+   because only this function can trigger allocation of attribute
+   data.  This way, the function is automatically defined for all the
+   cases when it is needed in static builds.  */
+void
+__default_pthread_attr_freeres (void)
+{
+  __pthread_attr_destroy (&__default_pthread_attr.external);
+}