From owner-freebsd-bugs@freebsd.org Wed Sep 16 22:54:32 2015 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 636029CD7C4 for ; Wed, 16 Sep 2015 22:54:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E990192D for ; Wed, 16 Sep 2015 22:54:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id t8GMsWtK099658 for ; Wed, 16 Sep 2015 22:54:32 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 203162] when close(fd) on a fifo fails with EINTR, the file descriptor is not really closed Date: Wed, 16 Sep 2015 22:54:32 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 10.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: victor.stinner@gmail.com X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 22:54:32 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203162 --- Comment #2 from Victor Stinner --- 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.