This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/3544] New: getgroups() makes a useless system call
- From: "bruno at clisp dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 20 Nov 2006 16:45:00 -0000
- Subject: [Bug libc/3544] New: getgroups() makes a useless system call
- Reply-to: sourceware-bugzilla at sourceware dot org
glibc-2.3.6 on Linux-2.4.x/i386 makes a useless system call when the
getgroups() function is called.
Test program:
===================================================================
#include <sys/types.h>
#include <unistd.h>
int main ()
{
gid_t buf[10];
getgroups (10, buf);
return 0;
}
===================================================================
strace shows:
open("/proc/sys/kernel/ngroups_max", O_RDONLY) = -1 ENOENT (No such file or
directory)
getgroups32(0xa, 0xbfffe4c0) = 3
This open() call, coming from a __sysconf() call, is useless, because the
getgroups32 system call exists; there is no need to allocate a kernel_groups[]
array since there is no translation to do.
Proposed fix (untested):
2006-11-18 Bruno Haible <bruno@clisp.org>
* sysdeps/unix/sysv/linux/i386/getgroups.c (__getgroups): Invoke
__sysconf only after having tried to call getgroups32.
--- sysdeps/unix/sysv/linux/i386/getgroups.c.bak 2003-09-03
05:21:27.000000000 +0200
+++ sysdeps/unix/sysv/linux/i386/getgroups.c 2006-11-18 15:35:59.000000000
+0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000, 2001, 2003, 2006 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,8 +52,6 @@
}
else
{
- int i, ngids;
- __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))];
# ifdef __NR_getgroups32
if (__libc_missing_32bit_uids <= 0)
{
@@ -69,6 +67,9 @@
}
# endif /* __NR_getgroups32 */
+ int i, ngids;
+ __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))];
+
ngids = INLINE_SYSCALL (getgroups, 2, n, CHECK_N (kernel_groups, n));
if (n != 0 && ngids > 0)
for (i = 0; i < ngids; i++)
--
Summary: getgroups() makes a useless system call
Product: glibc
Version: 2.3.6
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: bruno at clisp dot org
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=3544
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.