This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: glibc 2.19 - asyn-signal safe TLS and ASan.
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: Andrew Hunter <ahh at google dot com>
- Cc: Kostya Serebryany <kcc at google dot com>, "Carlos O'Donell" <carlos at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, Roland McGrath <roland at hack dot frob dot com>, Paul Pluzhnikov <ppluzhnikov at google dot com>, address-sanitizer at googlegroups dot com
- Date: Fri, 24 Jan 2014 11:46:22 +0530
- Subject: Re: glibc 2.19 - asyn-signal safe TLS and ASan.
- Authentication-results: sourceware.org; auth=none
- References: <52D0BCED dot 3000109 at redhat dot com> <52DDBF0E dot 8010501 at redhat dot com> <CAN=P9piS3Xczq2AKrzh4rsK9JxiHtJXawcQs9_+xsYXxrbLQWQ at mail dot gmail dot com> <CADroS=6vODmWCdBsynOf7oM9uVDymwdxrSDFbmD6kT5P9gbBRw at mail dot gmail dot com>
On Thu, Jan 23, 2014 at 01:59:08PM -0800, Andrew Hunter wrote:
> FYI -- you could easily do the same thing with calls to
> signal_safe_memalign from libc as a stopgap. (Well, we'd need to
> export the symbols from libc, like I wanted to in the first place.)
Or we could just add a thread-local flag that malloc looks at and if
set, short-circuits its way to mmap and have signal_safe_malloc use
it:
static __thread bool force_mmap;
void *
signal_safe_malloc (size_t sz)
{
force_mmap = true;
void *ret = malloc (sz);
force_mmap = false;
return ret;
}
void *
sysmalloc (size_t sz)
{
...
if (__glibc_unlikely (force_mmap)
|| ((unsigned long) (nb) >= (unsigned long) (mp_.mmap_threshold)
&& (mp_.n_mmaps < mp_.n_mmaps_max)))
{
...
/* call mmap and just fail if force_mmap is set and mmap fails.
Otherwise fall back to the heap as usual. */
...
}
...
}
Rinse and repeat for realloc, memalign, etc. free would work out of
the box since the chunk_is_mmapped.
Siddhesh