[Bug 203162] when close(fd) on a fifo fails with EINTR, the file descriptor is not really closed
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Wed Sep 16 22:54:32 UTC 2015
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203162
--- Comment #2 from Victor Stinner <victor.stinner at gmail.com> ---
Created attachment 161127
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=161127&action=edit
Syscalls seen by "truss -f" when the bug occurs
Syscalls seen by "truss -f" when the bug occurs. Attached syscalls.txt is this
command as a file, just if my comment is badly formatted in Bugzilla.
parent = 57517
child = 61173
57517: open("(null)",O_WRONLY,037777777777) ERR#4 'Interrupted system call'
57517: SIGNAL 14 (SIGALRM)
57517:
sigreturn(0x7fffffffe080,0x10006,0x7fffffffe080,0x0,0xffff80000060386e,0x0)
ERR#4 'Interrupted system call'
=> parent is blocked on open(fifo, O_WRONLY) because the child didn't open it
yet, but the open() is interrupted by signals every 10 ms.
61173: nanosleep({0.009149571 }) = 0 (0x0)
61173: SIGNAL 14 (SIGALRM)
61173:
sigreturn(0x7fffffffe040,0x10006,0x7fffffffe040,0x1ff3019bb4b18,0xffffffff8093b550,0xfffff8001fcf9980)
ERR#4 'Interrupted system call'
=> child is sleeping, nanosleep() is interrupted every 10 ms by a signal
57517: open("(null)",O_WRONLY,037777777777) = 0 (0x0)
=> strange, truss says that the parent succeeded first to open a FIFO to
writing, whereas the child didn't open it yet. It looks more like a bug or
race condition in truss. I prefer to think that the parent syscall succeeded
after the open() in the child process.
=> moreover, no, the parent failed to open the FIFO: see below, it still tries
to open it!?
=> And what is this strange file descriptor 0? It is supposed to be already
be used by stdin...
61173: open("fifo_57517_465",O_RDONLY,042716203) = 4 (0x4)
=> child process opened the FIFO for reading, it should unblock open() in
the parent.
61173: close(4) ERR#4 'Interrupted system call'
=> oh oh, closing the FIFO in the child process failed with EINTR...
Bad things happens since this point.
57517: SIGNAL 14 (SIGALRM)
57517:
sigreturn(0x7fffffffe080,0x10006,0x7fffffffe080,0x0,0xffff80000060386e,0x0) = 0
(0x0)
=> open() succeeded or was interrupted by EINTR?
61173: fstat(4,0x7fffffffe660) ERR#9 'Bad file descriptor'
=> fstat() confirms that the FIFO file descriptor is really closed in the
child.
61173: setitimer(0,{0.000000, 0.000000 },0x0) = 0 (0x0)
61173: close(3) = 0 (0x0)
=> fd 3 is only used to workaround truss bugs, it's a copy of the stdout
(fd 1).
61173:
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
= 0 (0x0)
61173: sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0)
61173:
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
= 0 (0x0)
61173: sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0)
61173:
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
= 0 (0x0)
61173: sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0)
61173: process exit, rval = 0
ERR#4 'Interrupted system call'
57517: open("(null)",O_WRONLY,037777777777) ERR#4 'Interrupted system call'
57517: SIGNAL 14 (SIGALRM)
57517:
sigreturn(0x7fffffffe080,0x10006,0x7fffffffe080,0x0,0xffff80000060386e,0x0)
ERR#4 'Interrupted system call'
=> open() still fails in the parent, whereas the child process succeeded to
open it for reading *and* closed it. The parent open() is supposed to be
unblocked since the child open() succeeded, no?
(... open sequence is repeated forever, it never succeed ...)
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list