Package: uim-el Version: 1:1.5.7-2 Severity: normal When I update or remove an emacs-related package (mainly emacs itself, but I think I've seen it reproduce with some other package which I don't recall) on a system where uim-el is installed, the processes uim-el-agent and uim-el-helper-agent use up the CPU, with a total utilization of 100%. Two copies of each program is run.
Steps to reproduce: * Install uim-el and emacs23. The problem might already reproduce here although I haven't tried. * In aptitude, re-install emacs23 with the `L' key. Note: I've tried doing dpkg -ri /var/cache/apt/archives/emacs23_23.1+1-5_amd64.deb but for some reason the problem doesn't reproduce reliably. If I do a reinstall from aptitude, the reproducibility has been 100% so far. The cause appears to be that during either remove or install, emacs closes the stdin of uim-el-agent and uim-el-helper-agent without sending a QUIT command. These programs don't check for EOF, so they go into a tight loop that tries to read more input, which immediately fails, then retries the read right away. The attached patch will make these programs exit when EOF or I/O error is detected. -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.30-2-amd64 (SMP w/2 CPU cores) Locale: LANG=ja_JP.EUC-JP, LC_CTYPE=ja_JP.EUC-JP (charmap=EUC-JP) (ignored: LC_ALL set to ja_JP.eucJP) Shell: /bin/sh linked to /bin/bash Versions of packages uim-el depends on: ii emacs [emacsen] 23.1+1-5 The GNU Emacs editor (metapackage) ii emacs23 [emacsen] 23.1+1-5 The GNU Emacs editor (with GTK+ us ii libc6 2.10.1-5 GNU C Library: Shared libraries ii libgcroots0 0.8.3-4 GC shared library for a Scheme int ii libuim6 1:1.5.7-2 Simple and flexible input method c ii uim-common 1:1.5.7-2 Common files for uim ii uim-utils 1:1.5.7-2 Utilities for uim uim-el recommends no packages. uim-el suggests no packages. -- no debconf information ===File /dvl/debian/uim-el/uim-1.5.7/debian/patches/13_eof_spin.dpatch=== #! /bin/sh /usr/share/dpatch/dpatch-run ## 13_eof_spin.dpatch by <j...@debian.localdomain.org> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: No description. @DPATCH@ diff -urNad uim-1.5.7~/emacs/uim-el-agent.c uim-1.5.7/emacs/uim-el-agent.c --- uim-1.5.7~/emacs/uim-el-agent.c 2009-01-20 20:16:35.000000000 -0600 +++ uim-1.5.7/emacs/uim-el-agent.c 2010-01-24 21:21:47.000000000 -0600 @@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - +#include <errno.h> #include <stdio.h> #include <string.h> #include <stdarg.h> @@ -631,6 +631,7 @@ main(int argc, char *argv[]) { int opt; + char buf[1024]; while ((opt = getopt(argc, argv, "d")) != -1) { switch (opt) { @@ -660,7 +661,14 @@ fflush(stdout); - fgets(buf, sizeof(buf), stdin); + if (fgets (buf, sizeof (buf), stdin) == NULL) { + if (feof (stdin)) + debug_printf (DEBUG_NOTE, "unexpected EOF\n"); + else + debug_printf (DEBUG_ERROR, "failed to read command: %s\n", + strerror (errno)); + goto QUIT; + } p1 = buf; serial = -1; diff -urNad uim-1.5.7~/emacs/uim-el-helper-agent.c uim-1.5.7/emacs/uim-el-helper-agent.c --- uim-1.5.7~/emacs/uim-el-helper-agent.c 2009-01-20 20:16:35.000000000 -0600 +++ uim-1.5.7/emacs/uim-el-helper-agent.c 2010-01-24 21:21:34.000000000 -0600 @@ -35,6 +35,7 @@ */ +#include <errno.h> #include <stdio.h> #include <string.h> #include <stdarg.h> @@ -197,7 +198,10 @@ } -static void +/** + * @return 1 if success, 0 if error. + */ +static int read_command() { ssize_t len; @@ -206,8 +210,15 @@ debug_printf(DEBUG_NOTE, "read command\n"); do { - if ((len = read(STDIN_FILENO, rbuf, sizeof(rbuf) - 1)) == -1) - debug_printf(DEBUG_NOTE, "stdin has corrupted\n"); + len = read(STDIN_FILENO, rbuf, sizeof(rbuf) - 1); + if (len == -1) { + debug_printf(DEBUG_NOTE, "stdin is corrupt: %s\n", strerror (errno)); + return 0; + } + if (len == 0) { + debug_printf(DEBUG_NOTE, "unexpected EOF\n"); + return 0; + } rbuf[len] = '\0'; @@ -221,6 +232,7 @@ } while (!command_exists_in_cmdbuf()); + return 1; } @@ -290,7 +302,8 @@ debug_printf(DEBUG_NOTE, "data arrive\n"); if (FD_ISSET(STDIN_FILENO, &rfds)) { - read_command(); + if (! read_command()) + goto QUIT; } if (FD_ISSET(helper_fd, &rfds)) { @@ -307,6 +320,7 @@ fflush(NULL); } + QUIT: uim_quit(); return 0; } diff -urNad uim-1.5.7~/emacs/uim-el-helper-agent.h uim-1.5.7/emacs/uim-el-helper-agent.h --- uim-1.5.7~/emacs/uim-el-helper-agent.h 2009-01-20 20:16:35.000000000 -0600 +++ uim-1.5.7/emacs/uim-el-helper-agent.h 2010-01-24 21:21:34.000000000 -0600 @@ -47,7 +47,6 @@ static int command_exists_in_cmdbuf(); static int process_command(); static void process_message(char *msg); -static void read_command(); static void wait_data_arrival(fd_set *rfds); void cleanup(void); ============================================================ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org