public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes
@ 2024-01-15 15:19 Florian Weimer
  2024-01-15 18:58 ` DJ Delorie
  2024-01-16 11:44 ` Szabolcs Nagy
  0 siblings, 2 replies; 4+ messages in thread
From: Florian Weimer @ 2024-01-15 15:19 UTC (permalink / raw)
  To: libc-alpha; +Cc: Szabolcs Nagy

The increased malloc subsystem usage is a side effect of
commit d2123d68275acc0f061e73d5f86ca504e0d5a344 ("elf: Fix slow tls
access after dlopen [BZ #19924]").

---
 NEWS               | 5 +++++
 manual/memory.texi | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/NEWS b/NEWS
index 1da3a6e6ee..a87271e573 100644
--- a/NEWS
+++ b/NEWS
@@ -80,6 +80,11 @@ Deprecated and removed features, and other changes affecting compatibility:
   of GNU libc are advised to check whether their build processes can be
   simplified.
 
+* The dynamic linker calls the malloc and free functions in more cases
+  if a shared object with dynamic TLS is loaded and unloaded.  This can
+  result in an infinite recursion if a malloc replacement libraries or
+  its dependencies uses dynamic TLS instead of initial-exec TLS.
+
 * The ia64*-*-linux-gnu configurations are no longer supported.
 
 Changes to build and runtime requirements:
diff --git a/manual/memory.texi b/manual/memory.texi
index 258fdbd3a0..4193b45e98 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1815,6 +1815,14 @@ using shared object dependencies or @code{LD_PRELOAD}.  For static
 linking, the @code{malloc} replacement library must be linked in before
 linking against @code{libc.a} (explicitly or implicitly).
 
+Care must be taken not to use functionality from @theglibc{} that uses
+@code{malloc} internal.  For example, the @code{fopen}, @code{opendir},
+@code{dlopen}, and @code{pthread_setspecific} functions currently use
+the @code{malloc} subsystem internally.  If the replacement
+@code{malloc} or its dependencies use thread-local storage (TLS), it
+must use the initial-exec TLS model, and not one of the dynamic TLS
+variants.
+
 @strong{Note:} Failure to provide a complete set of replacement
 functions (that is, all the functions used by the application,
 @theglibc{}, and other linked-in libraries) can lead to static linking


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

* Re: [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes
  2024-01-15 15:19 [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes Florian Weimer
@ 2024-01-15 18:58 ` DJ Delorie
  2024-01-15 19:20   ` Florian Weimer
  2024-01-16 11:44 ` Szabolcs Nagy
  1 sibling, 1 reply; 4+ messages in thread
From: DJ Delorie @ 2024-01-15 18:58 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

Florian Weimer <fweimer@redhat.com> writes:
> +@code{malloc} internal.  For example, the @code{fopen}, @code{opendir},

s/internal/internally/


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

* Re: [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes
  2024-01-15 18:58 ` DJ Delorie
@ 2024-01-15 19:20   ` Florian Weimer
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2024-01-15 19:20 UTC (permalink / raw)
  To: DJ Delorie; +Cc: libc-alpha

* DJ Delorie:

> Florian Weimer <fweimer@redhat.com> writes:
>> +@code{malloc} internal.  For example, the @code{fopen}, @code{opendir},
>
> s/internal/internally/

Thanks, sent a v2.

Florian


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

* Re: [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes
  2024-01-15 15:19 [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes Florian Weimer
  2024-01-15 18:58 ` DJ Delorie
@ 2024-01-16 11:44 ` Szabolcs Nagy
  1 sibling, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2024-01-16 11:44 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

The 01/15/2024 16:19, Florian Weimer wrote:
> The increased malloc subsystem usage is a side effect of
> commit d2123d68275acc0f061e73d5f86ca504e0d5a344 ("elf: Fix slow tls
> access after dlopen [BZ #19924]").

thanks.
looks good with some comments

> 
> ---
>  NEWS               | 5 +++++
>  manual/memory.texi | 8 ++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/NEWS b/NEWS
> index 1da3a6e6ee..a87271e573 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -80,6 +80,11 @@ Deprecated and removed features, and other changes affecting compatibility:
>    of GNU libc are advised to check whether their build processes can be
>    simplified.
>  
> +* The dynamic linker calls the malloc and free functions in more cases

i would expand this to ".. calls the malloc and free functions in more
cases during tls access if .." (not very important but makes it clearer
what's going on)

> +  if a shared object with dynamic TLS is loaded and unloaded.  This can
> +  result in an infinite recursion if a malloc replacement libraries or

singular 'library'

> +  its dependencies uses dynamic TLS instead of initial-exec TLS.
> +
>  * The ia64*-*-linux-gnu configurations are no longer supported.
>  
>  Changes to build and runtime requirements:
> diff --git a/manual/memory.texi b/manual/memory.texi
> index 258fdbd3a0..4193b45e98 100644
> --- a/manual/memory.texi
> +++ b/manual/memory.texi
> @@ -1815,6 +1815,14 @@ using shared object dependencies or @code{LD_PRELOAD}.  For static
>  linking, the @code{malloc} replacement library must be linked in before
>  linking against @code{libc.a} (explicitly or implicitly).
>  
> +Care must be taken not to use functionality from @theglibc{} that uses
> +@code{malloc} internal.  For example, the @code{fopen}, @code{opendir},

internally

> +@code{dlopen}, and @code{pthread_setspecific} functions currently use
> +the @code{malloc} subsystem internally.  If the replacement
> +@code{malloc} or its dependencies use thread-local storage (TLS), it
> +must use the initial-exec TLS model, and not one of the dynamic TLS
> +variants.

OK.

> +
>  @strong{Note:} Failure to provide a complete set of replacement
>  functions (that is, all the functions used by the application,
>  @theglibc{}, and other linked-in libraries) can lead to static linking
> 

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

end of thread, other threads:[~2024-01-16 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15 15:19 [PATCH] manual, NEWS: Document malloc side effect of dynamic TLS changes Florian Weimer
2024-01-15 18:58 ` DJ Delorie
2024-01-15 19:20   ` Florian Weimer
2024-01-16 11:44 ` Szabolcs Nagy

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).