[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#130798: dpkg: dselect loops getting EOF on stdin



tags 130798 + patch
thanks

Followup-For: Bug #130798
Package: dpkg
Version: 1.9.19

> Background: calling "dselect update" from cron. Probably happens when
> apt-get upgrade invoked by dselect fails to get one or more files.

Hi,

I can confirm this behaviour:
goodvibes:~# strace -p $(pidof dselect)
read(0, "", 4096)                       = 0
read(0, "", 4096)                       = 0
read(0, "", 4096)                       = 0
read(0, "", 4096)                       = 0
[...]

gdb output (I stretched the loop at lines 200-202, to show what's
happening, it's unmodified otherwise):

#9  0x0804f280 in falliblesubprocess (
    exepath=0x8077688 "/usr/lib/dpkg/methods/apt/update", 
    name=0x8064128 "update available list script", args=0xbffffd64)
    at /opt/src/build/debug/dpkg/dpkg-1.9.19/dselect/method.cc:201
201          c= fgetc(stdin); 
(gdb) list
196       }
197       fprintf(stderr,_("Press <enter> to continue.\n"));
198       if (ferror(stderr))
199         ohshite(_("write error on standard error"));
200       do {
201          c= fgetc(stdin); 
202       } while ((c == ERR && errno==EINTR) || (c != '\n'));
203       if (c == ERR)
204         ohshite(_("error reading acknowledgement of program
failure message"));
205       return urqr_fail;
(gdb) disp c
1: c = -1
(gdb) disp errno
2: {<data variable, no debug info>} 1075743968 = 2

c is EOF and errno is ENOENT, and this won't change.  As consequence,
the loop cannot be left.  The loop condition is erm... quite wrong.

Furthermore, the usage of ERR here is completely wrong, ERR is from
ncurses and it's pure coincidence that ERR == EOF.

A patch fixing both issues is attached.


Cheers,
Michael

[not Cc:ed to submitter since I doubt it will reach the person
(judging from the email address).]

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux stargate 2.4.18 #1 SMP Sun Mar 17 23:04:54 CET 2002 i686
Locale: LANG=POSIX, LC_CTYPE=de_DE@euro

Versions of packages dpkg depends on:
ii  libc6                    2.2.5-3         GNU C Library: Shared libraries an
ii  libncurses5              5.2.20020112a-3 Shared libraries for terminal hand
ii  libstdc++2.10-glibc2.2   1:2.95.4-1      The GNU stdc++ library
--- dselect/method.cc.mwe	Tue Apr 23 23:43:47 2002
+++ dselect/method.cc	Sat Apr 27 01:23:08 2002
@@ -197,8 +197,10 @@
   fprintf(stderr,_("Press <enter> to continue.\n"));
   if (ferror(stderr))
     ohshite(_("write error on standard error"));
-  do { c= fgetc(stdin); } while ((c == ERR && errno==EINTR) || (c != '\n'));
-  if (c == ERR)
+  do {
+     c= fgetc(stdin); 
+  } while ((c != EOF || errno==EINTR) && (c != '\n'));
+  if (c == EOF)
     ohshite(_("error reading acknowledgement of program failure message"));
   return urqr_fail;
 }

Reply to: