This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix posix_spawn getrlimit64 namespace (bug 17991)
- From: Rich Felker <dalias at libc dot org>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 17 Feb 2015 16:46:43 -0500
- Subject: Re: Fix posix_spawn getrlimit64 namespace (bug 17991)
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1502171743370 dot 19294 at digraph dot polyomino dot org dot uk>
On Tue, Feb 17, 2015 at 05:44:55PM +0000, Joseph Myers wrote:
> posix_spawn (a standard POSIX function) brings in a use of getrlimit64
> (not a standard POSIX function). This patch fixes this by using
> __getrlimit64 and making getrlimit64 a weak alias.
>
> This is more complicated than some such changes because of files that
> define getrlimit64 in their own way using symbol versioning after
> including the main sysdeps/unix/sysv/linux/getrlimit64.c with a
> getrlimit macro defined. There are various existing patterns for such
> cases in glibc; the one I've used here is that a getrlimit64 macro
> disables the weak_alias / libc_hidden_weak calls, leaving it to the
> including file to define the getrlimit64 name in whatever way is
> appropriate.
>
> Tested for x86_64 and x86 that installed stripped shared libraries are
> unchanged by this patch.
> [...]
> @@ -40,4 +40,6 @@ getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
>
> return 0;
> }
> -libc_hidden_def (getrlimit64)
> +libc_hidden_def (__getrlimit64)
> +weak_alias (__getrlimit64, getrlimit64)
> +libc_hidden_weak (getrlimit64)
> diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
> index 4a25c89..eee9331 100644
> --- a/sysdeps/posix/spawni.c
> +++ b/sysdeps/posix/spawni.c
> @@ -188,7 +188,7 @@ __spawni (pid_t *pid, const char *file,
> {
> if (! have_fdlimit)
> {
> - getrlimit64 (RLIMIT_NOFILE, &fdlimit);
> + __getrlimit64 (RLIMIT_NOFILE, &fdlimit);
> have_fdlimit = true;
> }
Wouldn't it make more sense to use sysconf() to get the limit?
Rich