From: Florian Weimer <fweimer@redhat.com>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2] elf: Support recursive use of dynamic TLS in interposed malloc
Date: Mon, 01 Jul 2024 17:41:15 +0200 [thread overview]
Message-ID: <87h6d9f7c4.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <ZoLGnjYYoD34NDKu@arm.com> (Szabolcs Nagy's message of "Mon, 1 Jul 2024 16:09:18 +0100")
* Szabolcs Nagy:
>> +static int
>> +do_test (void)
>> +{
>> + /* 16 is large enough to exercise the DTV resizing case. */
>> + void *handles[16];
>> +
>> + for (unsigned int i = 0; i < array_length (handles); ++i)
>> + {
>> + /* Re-use the TLS slot for module 0. */
>> + if (i > 0)
>> + xdlclose (handles[0]);
>> +
>> + char soname[30];
>> + snprintf (soname, sizeof (soname), "tst-recursive-tlsmod%u.so", i);
>> + handles[i] = xdlopen (soname, RTLD_NOW);
>> +
>> + if (i > 0)
>> + handles[0] = xdlopen ("tst-recursive-tlsmod0.so", RTLD_NOW);
>> + }
>
> if this loop accessed the tls in *tlsmod0.so then
> the access would do malloc and the dtv update after
> dlclose would have to free.
>
> i think the current code only tests the realloc in
> _dl_resize_dtv during dtv update so if the initial
> dtv size is increased then the test becomes ineffective
> (it may pass without the patch).
>
> i'd add that access to cover more malloc/free cases, e.g.
>
> if (i > 0)
> {
> handles[0] = xdlopen ("tst-recursive-tlsmod0.so", RTLD_NOW);
> int (*f) (void) = xdlsym (handles[0], "get_threadvar_0");
> f (); /* TLS access may allocate. */
> }
Right, just the f () call expression triggers a fair number of extra
malloc subsystem calls. Will send a v3.
Thanks,
Florian
prev parent reply other threads:[~2024-07-01 15:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 7:52 Florian Weimer
2024-07-01 12:32 ` Florian Weimer
2024-07-01 15:09 ` Szabolcs Nagy
2024-07-01 15:41 ` Florian Weimer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6d9f7c4.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=szabolcs.nagy@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).