Package: uim-prime
Version: 1:1.5.7-1
Severity: normal

I tried wrapping prime in a C program to log what's failing, and to kill
the calling process as a workaround for the infinite loop. The
workaround didn't work as my session still hangs when the bug occurs,
but at least I got the messages that prime is emitting in the cases
where it fails. uim-prime sends the "session_start" command, and prime
outputs:

/usr/lib/ruby/1.8/prime/prime-japanese.rb:423:in `delete': No such file or 
directory - /home/jamey/.prime/suikyo.rbo (Errno::ENOENT)
        from /usr/lib/ruby/1.8/prime/prime-japanese.rb:423:in `destroy_cache'
        from /usr/bin/prime.distrib:32:in `initialize'
        from /usr/bin/prime.distrib:178:in `new'
        from /usr/bin/prime.distrib:178

That looks like a bug in prime, which I'll report separately, but the
fact that uim-prime infinite-loops when this occurs is still a bug in
uim-prime.

My test program is attached.

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages uim-prime depends on:
ii  libc6                         2.10.2-6   Embedded GNU C Library: Shared lib
ii  libgcroots0                   0.8.3-8    GC shared library for a Scheme int
ii  libuim6                       1:1.5.7-1  Simple and flexible input method c
ii  prime                         1.0.0.1-2  Japanese PRedictive Input Method E
ii  uim-common                    1:1.5.7-1  Common files for uim
ii  uim-utils                     1:1.5.7-1  Utilities for uim

uim-prime recommends no packages.

uim-prime suggests no packages.

-- no debconf information
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

#define LOGFILE "/tmp/uim-hack.log"
#define REALPROGRAM "/usr/bin/prime.distrib"

static char buf[4096];
static int child_gone;

static void child_exit(int signum)
{
	int status;
	waitpid(-1, &status, WNOHANG);
	child_gone = 1;
}

static __attribute__((noreturn)) void die(const char *msg)
{
	perror(msg);
	kill(getppid(), SIGTERM);
	exit(EXIT_FAILURE);
}

int main(int argc, char *argv[], char *envp[])
{
	if(!freopen(LOGFILE, "a", stderr))
		die("open " LOGFILE);
	fprintf(stderr, "\nstarting " REALPROGRAM "\n");

	const struct sigaction action = {
		.sa_handler = child_exit,
		.sa_flags = SA_NOCLDSTOP,
	};
	sigaction(SIGCHLD, &action, 0);

	int pipefd[2];
	pipe(pipefd);

	switch(fork())
	{
	case -1:
		die("fork");

	case 0:
		dup2(pipefd[0], STDIN_FILENO);
		execve(REALPROGRAM, argv, envp);
		die("exec " REALPROGRAM);
	}

	while(!child_gone)
	{
		int n = read(STDIN_FILENO, buf, sizeof buf);
		if(n < 0 && errno == EINTR)
			continue;
		if(n <= 0)
			die("read from stdin");
		fwrite(buf, n, 1, stderr);
		char *p = buf;
		while(n > 0)
		{
			int done = write(pipefd[1], p, n);
			if(done <= 0)
				die("write to child");
			p += done;
			n -= done;
		}
	}
	fprintf(stderr, "\n" REALPROGRAM " exited\n");
	kill(getppid(), SIGTERM);
	exit(EXIT_SUCCESS);
}

Attachment: signature.asc
Description: Digital signature

Reply via email to