* [PATCH v2] stdlib: Describe __cxa_finalize usage in function comment
@ 2024-05-31 12:53 Florian Weimer
2024-06-03 13:10 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2024-05-31 12:53 UTC (permalink / raw)
To: libc-alpha
---
v2: Typo fixes from Joe & Jonathan.
stdlib/cxa_finalize.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/stdlib/cxa_finalize.c b/stdlib/cxa_finalize.c
index 258fa56ce5..496141d802 100644
--- a/stdlib/cxa_finalize.c
+++ b/stdlib/cxa_finalize.c
@@ -24,7 +24,22 @@
/* If D is non-NULL, call all functions registered with `__cxa_atexit'
with the same dso handle. Otherwise, if D is NULL, call all of the
- registered handlers. */
+ registered handlers.
+
+ A __cxa_finalize function is declared in the libstdc++ <cxxabi.h>
+ header, and the libstdc++ implementation calls this function. GCC
+ calls the glibc variant directly from its CRT files, from an ELF
+ destructor. this call always passes a non-null D argument. In the
+ current implementation, the GCC-provided __cxa_finalize call is
+ responsible for removing the registered __cxa_atexit (C++)
+ destructors of an object that is undergoing dlclose. Note that
+ this is specific to dlclose. During process termination, glibc
+ invokes the __run_exit_handlers, which calls registered
+ __cxa_atexit (C++) destructors in reverse registration order,
+ across all objects. The subsequent GCC-provided __cxa_finalize
+ calls (which are ordered according to ELF object dependencies, not
+ __cxa_atexit call order, and group destructor calls per object
+ during dlclose) do not result in further destructor invocations. */
void
__cxa_finalize (void *d)
{
base-commit: 46b5e98ef6f1b9f4b53851f152ecb8209064b26c
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] stdlib: Describe __cxa_finalize usage in function comment
2024-05-31 12:53 [PATCH v2] stdlib: Describe __cxa_finalize usage in function comment Florian Weimer
@ 2024-06-03 13:10 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2024-06-03 13:10 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 31/05/24 14:53 +0200, Florian Weimer wrote:
>---
>v2: Typo fixes from Joe & Jonathan.
> stdlib/cxa_finalize.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
+Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
>diff --git a/stdlib/cxa_finalize.c b/stdlib/cxa_finalize.c
>index 258fa56ce5..496141d802 100644
>--- a/stdlib/cxa_finalize.c
>+++ b/stdlib/cxa_finalize.c
>@@ -24,7 +24,22 @@
>
> /* If D is non-NULL, call all functions registered with `__cxa_atexit'
> with the same dso handle. Otherwise, if D is NULL, call all of the
>- registered handlers. */
>+ registered handlers.
>+
>+ A __cxa_finalize function is declared in the libstdc++ <cxxabi.h>
>+ header, and the libstdc++ implementation calls this function. GCC
>+ calls the glibc variant directly from its CRT files, from an ELF
>+ destructor. this call always passes a non-null D argument. In the
>+ current implementation, the GCC-provided __cxa_finalize call is
>+ responsible for removing the registered __cxa_atexit (C++)
>+ destructors of an object that is undergoing dlclose. Note that
>+ this is specific to dlclose. During process termination, glibc
>+ invokes the __run_exit_handlers, which calls registered
>+ __cxa_atexit (C++) destructors in reverse registration order,
>+ across all objects. The subsequent GCC-provided __cxa_finalize
>+ calls (which are ordered according to ELF object dependencies, not
>+ __cxa_atexit call order, and group destructor calls per object
>+ during dlclose) do not result in further destructor invocations. */
> void
> __cxa_finalize (void *d)
> {
>
>base-commit: 46b5e98ef6f1b9f4b53851f152ecb8209064b26c
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-03 13:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-31 12:53 [PATCH v2] stdlib: Describe __cxa_finalize usage in function comment Florian Weimer
2024-06-03 13:10 ` Jonathan Wakely
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).