Package: libgdbm3 Version: 1.8.3-3 Severity: important An application can enter on an infinite loop when reading data. This occour at random times.
I already traced the error and find that the problem is with the patch 05_handle-short-read.dpatch introduced at bug #274417. This patch makes it possible that libgdbm3 keep trying to read the file even if the EOF is returned. ** From the patch: **************************** @@ -111,7 +112,12 @@ if (file_pos != bucket_adr) _gdbm_fatal (dbf, "lseek error"); - num_bytes = read (dbf->desc, dbf->bucket, dbf->header->bucket_size); + do + { + bytes_read = read (dbf->desc, dbf->bucket+num_bytes, dbf->header->bucket_size-num_bytes); + num_bytes += bytes_read; + } + while ((bytes_read > 0 || errno == EINTR) && num_bytes < dbf->header->bucket_size); if (num_bytes != dbf->header->bucket_size) _gdbm_fatal (dbf, "read error"); } **************************** As could be seen the "while ((bytes_read > 0 || errno == EINTR) && num_bytes < dbf->header->bucket_size);" if the read return EINTR then bytes_read will be 0 and if num_byes still less then bucket_size the application will be locked on the loop. I have strace some process during the lock. It took me more then a year to find that. My application stop on several different severs at random times. Some times once a week, but it happens to be more then once a day too. After I removed this patch and rebuild libgdgm3 I had never had a hang again. It has about 1 month I did that. 1) strace during normal operation (file descriptor 4 is a gdbm file) ------------------------------------------------ 17:46:05.482106 rt_sigaction(SIGCHLD, {SIG_DFL}, {0x404ae0, [CHLD], SA_RESTORER|SA_RESTART, 0x7f4144f8af60}, 8) = 0 17:46:05.482278 rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0 17:46:05.482683 brk(0x2503000) = 0x2503000 17:46:05.482974 brk(0x2524000) = 0x2524000 17:46:05.483454 brk(0x2545000) = 0x2545000 17:46:05.483729 lseek(4, 8192, SEEK_SET) = 8192 17:46:05.484210 read(4, "\0\0\0\0\r\0\0\0\31\0\0\0\271\3627 216.\2474\0\0\0\0\0\0\16\0\0\0\31"..., 4096) = 4096 17:46:05.484686 getsockname(5, {sa_family=AF_INET6, sin6_port=htons(25), inet_pton(AF_INET6, "::ffff:74.86.76.42", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0 17:46:05.485206 open("/etc/resolv.conf", O_RDONLY) = 6 . . . normal process end.. --------------------------------------------- 2) strace when the application starts degradating performance ---------------------------------------------- 17:46:43.742191 rt_sigaction(SIGCHLD, {SIG_DFL}, {0x404ae0, [CHLD], SA_RESTORER|SA_RESTART, 0x7f4144f8af60}, 8) = 0 17:46:43.743147 rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0 17:46:43.748307 brk(0x2503000) = 0x2503000 17:46:43.753416 brk(0x2524000) = 0x2524000 17:46:43.753745 brk(0x2545000) = 0x2545000 17:46:43.754507 lseek(4, 8192, SEEK_SET) = 8192 17:46:43.754836 read(4, "201.17.129.83allow,SIZELIMIT=5242"..., 4096) = 1650 17:46:43.755069 read(4, ""..., 2446) = 0 17:46:43.756458 read(4, ""..., 2446) = 0 17:46:43.756556 read(4, ""..., 2446) = 0 17:46:43.756994 read(4, ""..., 2446) = 0 17:46:43.757080 read(4, ""..., 2446) = 0 17:46:43.757188 read(4, ""..., 2446) = 0 17:46:43.757276 read(4, ""..., 2446) = 0 17:46:43.757367 read(4, ""..., 2446) = 0 17:46:43.757452 read(4, ""..., 2446) = 0 17:46:43.757534 read(4, ""..., 2446) = 0 17:46:43.757617 read(4, ""..., 2446) = 0 17:46:43.757703 read(4, ""..., 2446) = 0 17:46:43.757794 read(4, ""..., 2446) = 0 17:46:43.757877 read(4, ""..., 2446) = 0 17:46:43.757960 read(4, ""..., 2446) = 0 17:46:43.758047 read(4, ""..., 2446) = 0 17:46:43.758155 read(4, ""..., 2446) = 0 17:46:43.758260 read(4, ""..., 2446) = 0 17:46:43.758570 read(4, ""..., 2446) = 0 17:46:43.758654 read(4, ""..., 2446) = 0 17:46:43.758762 read(4, "\1\0\0\0\0\0\0\0\216\t\0\0\0\0\0\0r6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2446) = 2446 17:46:43.759082 getsockname(5, {sa_family=AF_INET6, sin6_port=htons(25), inet_pton(AF_INET6, "::ffff:74.86.76.42", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0 17:46:43.759258 open("/etc/resolv.conf", O_RDONLY) = 6 . . . . normal process end.. ---------------------------------------------- 3) strace during a complete hang --------------------------------------------- 17:46:49.944384 rt_sigaction(SIGCHLD, {SIG_DFL}, {0x404ae0, [CHLD], SA_RESTORER|SA_RESTART, 0x7f4144f8af60}, 8) = 0 17:46:49.950918 rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0 17:46:49.951420 brk(0x2503000) = 0x2503000 17:48:05.794865 brk(0x2524000) = 0x2524000 17:48:05.795256 brk(0x2545000) = 0x2545000 17:48:45.322594 lseek(4, 8192, SEEK_SET) = 8192 17:48:45.322770 read(4, "201.17.129.83allow,SIZELIMIT=5242"..., 4096) = 1650 17:48:45.322967 read(4, ""..., 2446) = 0 17:48:45.323220 read(4, ""..., 2446) = 0 17:48:45.323390 read(4, ""..., 2446) = 0 17:48:45.323529 read(4, ""..., 2446) = 0 17:48:45.323675 read(4, ""..., 2446) = 0 17:48:45.323812 read(4, ""..., 2446) = 0 17:48:45.323937 read(4, ""..., 2446) = 0 17:48:45.324074 read(4, ""..., 2446) = 0 17:48:45.324215 read(4, ""..., 2446) = 0 17:48:45.324377 read(4, ""..., 2446) = 0 . . . until I kill the proccess --------------------------------------------- I dont know why the read seems to be starting on the middle of the file, not on the start. May be its related to the short read bug. My file is located on a local ext3 hard disk. Anyway libgdbm cant go on a infinite loop like that. Marcus Pereira -- System Information: Debian Release: lenny/sid APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.18-6-686 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages libgdbm3 depends on: ii libc6 2.7-13 GNU C Library: Shared libraries libgdbm3 recommends no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org