This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/12926] New: getaddrinfo()/make_request() may spin forever


http://sourceware.org/bugzilla/show_bug.cgi?id=12926

           Summary: getaddrinfo()/make_request() may spin forever
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: ppluzhnikov@google.com


I am not sure whether this is a kernel bug or a glibc bug.

Even if it is a kernel bug, it might be wise to fix it in glibc, since
buggy kernels are observed "in the wild".

Over last two weeks, we observed several Java programs that have a thread
spinning here:

#0  0xf7717430 in __kernel_vsyscall ()
#1  0xf757e448 in recvmsg () at ../sysdeps/unix/sysv/linux/i386/socket.S:97
#2  0xf76797a6 in make_request (fd=1590, pid=<value optimized out>,
seen_ipv4=0x7dceea7b, seen_ipv6=0x7dceea7a, in6ai=0x7dceea70,
in6ailen=0x7dceea6c) at ../sysdeps/unix/sysv/linux/check_pf.c:123
#3  0xf7679bd4 in __check_pf (seen_ipv4=0x7dceea7b, seen_ipv6=0x7dceea7a,
in6ai=0x7dceea70, in6ailen=0x7dceea6c) at
../sysdeps/unix/sysv/linux/check_pf.c:275
#4  0xf761ff4c in getaddrinfo (name=0x988f330 "<a-valid-host-name>",
service=0x0, hints=0x7dceeaf8, pai=0x7dceeb18) at
../sysdeps/posix/getaddrinfo.c:2109
...

strace shows un-ending stream of recvmsg() calls, which all return 0.

Looking in check_pf.c, it seems clear that if recvmsg() keeps returning 0,
then the for() loop on line 131 (current git source) will not execute,
and the do-while loop on line 113 will spin forever.

We do not know what conditions provoke the kernel (2.6.34-smp and 2.6.26-smp
have been observed) to return zero here, and the problem is not repeatable
on the same machine.


The following patch will make make_request() fail under these conditions.
Not sure whether that's the right thing to do.

diff --git a/sysdeps/unix/sysv/linux/check_pf.c
b/sysdeps/unix/sysv/linux/check_pf.c
index c053adc..47cf034 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -121,7 +121,7 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool
*seen_ipv6,
        };

       ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
-      if (read_len < 0)
+      if (read_len <= 0)
        goto out_fail;

       if (msg.msg_flags & MSG_TRUNC)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]