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

Bug#297985: gnat-gps: starting compilation terminates X session



Hi,

I stumbled across this bug while scrolling through the list
of release-critical bugs... I strace'd the involved processes
and found that the X server is behaving fine (the bug on
xserver-xfree86 should be closed). I would have attached the
full gnat-gps strace, but 113K is a bit too large, I think -
and it's easily reproducible (drop me a line if you need
exactly _my_ output).

- Upon the request to begin compilation, gnat-gps claims a legacy
legacy PTY (it should really use the new mechanism and open /dev/ptmx
instead) and forks off...

stat64("/dev/ptypf", {st_mode=S_IFCHR|0666, st_rdev=makedev(2, 15), ...}) = 0
open("/dev/ptypf", O_RDWR|O_NONBLOCK)   = 5
access("/dev/ttypf", R_OK|W_OK)         = 0
fcntl64(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl64(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
stat64("/bin/gnatmake", 0xbfffc62c)     = -1 ENOENT (No such file or directory)
stat64("/usr/bin/gnatmake", {st_mode=S_IFREG|0755, st_size=1067896, ...}) = 0
clone(Process 2797 attached
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb72b0928) = 2797

... and the subprocess opens the slave device and connects its
main fds to it.

[pid  2797] open("/dev/ttypf", O_RDWR)  = 6
  [...]
[pid  2797] close(0)                    = 0
[pid  2797] close(1)                    = 0
[pid  2797] close(2)                    = 0
[pid  2797] dup2(6, 0)                  = 0
[pid  2797] dup2(6, 1)                  = 1
[pid  2797] dup2(6, 2)                  = 2
[pid  2797] close(6)                    = 0
[pid  2797] close(6)                    = -1 EBADF (Bad file descriptor)
[pid  2797] close(6)                    = -1 EBADF (Bad file descriptor)
[pid  2797] setpgid(2797, 2797)         = -1 EPERM (Operation not permitted)
[pid  2797] ioctl(0, TIOCSPGRP, [2797]) = 0
[pid  2797] execve("/usr/bin/gnatmake", ["/usr/bin/gnatmake", "-P/home/jcn/dev/gnat/tutorial/sd"..., "sdc.ad
b", "-d", "-XBuild=DEBUG"], [/* 41 vars */]) = 0

gnatmake then forks two more subprocesses...

[pid  2798] execve("/usr/bin/gnatgcc", ["/usr/bin/gnatgcc", "-c", "-g", "-o", "/home/jcn/dev/gnat/tutorial/obj/"..., "-gnatwe", "-gnaty", "-gnato", "-g", "-gnatA", "/home/jcn/dev/gnat/tutorial/comm"...], [/* 43 vars */]) = 0
  [...]
[pid  2799] execve("/usr/lib/gcc-lib/i486-linux/2.8.1/gnat1", ["/usr/lib/gcc-lib/i486-linux/2.8."..., "-quiet", "-dumpbase", "sdc.adb", "-g", "-gnatwe", "-gnaty", "-gnato", "-g", "-gnatA", "-gnatO", "/home/jcn/dev/gnat/tutorial/obj/"..., "/home/jcn/dev/gnat/tutorial/comm"..., "-o", "/tmp/cckYpVua.s"], [/* 44 vars */]) = 0

... but eventually they all terminate:

[pid  2799] exit_group(5)               = ?
Process 2798 resumed
Process 2799 detached
[pid  2798] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 5}], 0, NULL) = 2799
[pid  2798] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid  2798] stat64("/tmp/cckYpVua.s", {st_mode=S_IFREG|0644, st_size=340, ...}) = 0
[pid  2798] unlink("/tmp/cckYpVua.s")   = 0
[pid  2798] exit_group(1)               = ?
Process 2797 resumed
Process 2798 detached
[pid  2797] <... waitpid resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0) = 2798
[pid  2797] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid  2797] write(2, "completed 1 out of 1 (100%)...\n", 31) = 31
[pid  2797] write(2, "gnatmake: \"/home/jcn/dev/gnat/tu"..., 73) = 73
[pid  2797] exit_group(4)               = ?
Process 2797 detached
<... poll resumed> [{fd=3, events=POLLIN}], 1, 38) = -1 EINTR (Interrupted system call)
--- SIGCHLD (Child exited) @ 0 (0) ---

gnat-gps, however, doesn't care about SIGCHLD...

select(6, [5], NULL, NULL, {0, 1000})   = 1 (in [5], left {0, 1000})
read(5, "sdc.adb:28:06: (style) bad inden"..., 4096) = 411
  [...]
select(6, [5], NULL, NULL, {0, 1000})   = 1 (in [5], left {0, 1000})
read(5, 0xbfffc3cc, 4096)               = -1 EIO (Input/output error)

... and finally closes the PTY master device. And now look
closer...

close(5)                                = 0
close(5)                                = -1 EBADF (Bad file descriptor)
ioctl(5, TIOCGPGRP, [1])                = -1 EBADF (Bad file descriptor)
kill(-1, SIGINT)                        = 0

Closing it twice isn't problematic, but ioctl()ing on the FD _after_
closing it, and using the return value unchecked as argument for
kill() is, well, suicidal. :-) And in the case of -1 fatal, as
that sends SIGINT to all processes that gnat-gps is capable to
signals to... and that includes either the Xserver itself (if you've
started it via startx et.al.) or your favourite window manager / login
terminal / whatever keeps your session running.

I've not looked into the gnat-gps source code until now, but if
you want, I could lend a hand there, too.


Best regards,

Jan

-- 
Jan C. Nordholz
<jckn at gmx dot net>



Reply to: