unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / code / Atom feed
* [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure
@ 2021-07-28  6:25 Siddhesh Poyarekar via Libc-alpha
  2021-07-28  7:14 ` Florian Weimer via Libc-alpha
  2021-07-28  7:59 ` Andreas Schwab
  0 siblings, 2 replies; 4+ messages in thread
From: Siddhesh Poyarekar via Libc-alpha @ 2021-07-28  6:25 UTC (permalink / raw)
  To: libc-alpha

Return -1 in the unlikely event that allocation fails when trying to
register a TLS destructor.
---
 stdlib/cxa_thread_atexit_impl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/stdlib/cxa_thread_atexit_impl.c b/stdlib/cxa_thread_atexit_impl.c
index 577ed30931..e956f4d804 100644
--- a/stdlib/cxa_thread_atexit_impl.c
+++ b/stdlib/cxa_thread_atexit_impl.c
@@ -72,6 +72,7 @@
    is not very different from a case where __call_tls_dtors is called after
    _dl_close_worker on the DSO and hence is an accepted execution.  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <ldsodefs.h>
 
@@ -104,6 +105,8 @@ __cxa_thread_atexit_impl (dtor_func func, void *obj, void *dso_symbol)
 
   /* Prepend.  */
   struct dtor_list *new = calloc (1, sizeof (struct dtor_list));
+  if (__glibc_unlikely (new == NULL))
+    return -1;
   new->func = func;
   new->obj = obj;
   new->next = tls_dtor_list;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure
  2021-07-28  6:25 [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure Siddhesh Poyarekar via Libc-alpha
@ 2021-07-28  7:14 ` Florian Weimer via Libc-alpha
  2021-07-28  7:26   ` Siddhesh Poyarekar via Libc-alpha
  2021-07-28  7:59 ` Andreas Schwab
  1 sibling, 1 reply; 4+ messages in thread
From: Florian Weimer via Libc-alpha @ 2021-07-28  7:14 UTC (permalink / raw)
  To: Siddhesh Poyarekar via Libc-alpha; +Cc: Siddhesh Poyarekar

* Siddhesh Poyarekar via Libc-alpha:

> Return -1 in the unlikely event that allocation fails when trying to
> register a TLS destructor.

This is bug 18524.  As said on the bug, the interface is broken.  We
really need to rework C++ global destructor support so that these
dynamic memory allocations become unnecessary.

The GCC-generated caller code does not check the return value (and could
do anything with it anyway).  You probable need to add __libc_fatal.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure
  2021-07-28  7:14 ` Florian Weimer via Libc-alpha
@ 2021-07-28  7:26   ` Siddhesh Poyarekar via Libc-alpha
  0 siblings, 0 replies; 4+ messages in thread
From: Siddhesh Poyarekar via Libc-alpha @ 2021-07-28  7:26 UTC (permalink / raw)
  To: Florian Weimer, Siddhesh Poyarekar via Libc-alpha

On 7/28/21 12:44 PM, Florian Weimer wrote:
> * Siddhesh Poyarekar via Libc-alpha:
> 
>> Return -1 in the unlikely event that allocation fails when trying to
>> register a TLS destructor.
> 
> This is bug 18524.  As said on the bug, the interface is broken.  We
> really need to rework C++ global destructor support so that these
> dynamic memory allocations become unnecessary.
> 
> The GCC-generated caller code does not check the return value (and could
> do anything with it anyway).  You probable need to add __libc_fatal.

Hmm, so I started with __libc_fatal and changed it to return -1 when I 
saw that the libstdc++ compat implementation did the same.  Now I see 
that there's no check for return value from the call.  I'll update the 
patch with __libc_fatal and resend.

Thanks,
Siddhesh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure
  2021-07-28  6:25 [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure Siddhesh Poyarekar via Libc-alpha
  2021-07-28  7:14 ` Florian Weimer via Libc-alpha
@ 2021-07-28  7:59 ` Andreas Schwab
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2021-07-28  7:59 UTC (permalink / raw)
  To: Siddhesh Poyarekar via Libc-alpha; +Cc: Siddhesh Poyarekar

On Jul 28 2021, Siddhesh Poyarekar via Libc-alpha wrote:

> Return -1 in the unlikely event that allocation fails when trying to
> register a TLS destructor.

Ok.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-28  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28  6:25 [PATCH] __cxa_thread_atexit_impl: Return -1 on allocation failure Siddhesh Poyarekar via Libc-alpha
2021-07-28  7:14 ` Florian Weimer via Libc-alpha
2021-07-28  7:26   ` Siddhesh Poyarekar via Libc-alpha
2021-07-28  7:59 ` Andreas Schwab

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/glibc.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).