This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/9685] New: __have_{sock_cloexec,pipe2} checks not valid with linux headers older than 2.6.27
- From: "vapier at gentoo dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 27 Dec 2008 03:51:51 -0000
- Subject: [Bug libc/9685] New: __have_{sock_cloexec,pipe2} checks not valid with linux headers older than 2.6.27
- Reply-to: sourceware-bugzilla at sourceware dot org
if you build glibc-2.9 against kernel headers older than 2.6.27, then the
resulting libc code can easily break when running on a kernel 2.6.27 or newer.
for example, this simple code will result in popen() failing with ENOSYS:
#include <grp.h>
#include <stdio.h>
main()
{
getgrnam("root");
if (!popen("ls", "r"))
perror("popen()");
}
this is because __have_pipe2 is defined to __have_sock_cloexec in
include/unistd.h. sock_cloexec is tested at runtime using defines that are
completely contained within glibc and so works properly regardless of the
version of kernel headers built against and the kernel version run on. pipe2
however requires __NR_pipe2 to be defined in the kernel headers otherwise glibc
creates an ENOSYS stub for it.
so in the previous example, if we run on linux-2.6.27 or newer, getgrnam()
recurses into socket() with SOCK_CLOEXEC and detects that it works, and so it
sets __have_sock_cloexec to 1. but when we call popen(), it sees that
__have_pipe2 is set to 1 (since it is defined to __have_sock_cloexec), and so
only calls pipe2() (which is an ENOSYS stub) and things fail.
if we give __have_pipe2 dedicated storage, then things work properly --
SOCK_CLOEXEC is detected independent of pipe2().
i wrote a patch here, but i imagine drepper will simply say it's "wrong" and do
whatever else, so no point in writing a ChangeLog/etc...
http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.9/1095_all_glibc-2.9-assume-pipe2.patch?rev=1.1
--
Summary: __have_{sock_cloexec,pipe2} checks not valid with linux
headers older than 2.6.27
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: vapier at gentoo dot org
CC: glibc-bugs at sources dot redhat dot com,toolchain at
gentoo dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=9685
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.