Debian Bug report logs - #578271
expect: [kFreeBSD] spawn/wait waits forever if command has any output

version graph

Package: expect; Maintainer for expect is Sergei Golovan <sgolovan@debian.org>; Source for expect is src:expect (PTS, buildd, popcon).

Reported by: Andreas Metzler <ametzler@downhill.at.eu.org>

Date: Sun, 18 Apr 2010 13:21:08 UTC

Severity: grave

Tags: upstream

Found in version expect/5.44.1.15-1

Done: Sergei Golovan <sgolovan@gmail.com>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Sun, 18 Apr 2010 13:21:11 GMT) (full text, mbox, link).


Acknowledgement sent to Andreas Metzler <ametzler@downhill.at.eu.org>:
New Bug report received and forwarded. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Sun, 18 Apr 2010 13:21:11 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Andreas Metzler <ametzler@downhill.at.eu.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Sun, 18 Apr 2010 15:19:48 +0200
Package: expect
Version: 5.44.1.15-1
Severity: important

On kfreebsd-* spawn/wait does not work as expected:
----------------
ametzler@asdfasdf:$ cat /tmp/FIND/expect.bug
#!/usr/bin/expect -f

eval echo blubb
wait
ametzler@asdfasdf:$ /tmp/FIND/expect.bug
----------------
and the process just hangs and only reacts to kill -9. I have found
this when investigating why sv-bug-24169.exp in findutils testsuite
does not work on kfreebsd-*.

I suspect this should be an rc bug, please raise the severity if you agree.

http://git.savannah.gnu.org/cgit/findutils.git/tree/find/testsuite/find.gnu/sv-bug-24169.exp

cu andreas

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

Kernel: kFreeBSD 8.0-1-amd64
Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages expect depends on:
ii  libc0.1                       2.10.2-6   Embedded GNU C Library: Shared lib
ii  tcl8.5                        8.5.8-2    Tcl (the Tool Command Language) v8

expect recommends no packages.

Versions of packages expect suggests:
ii  expectk                      5.44.1.15-1 A program that can automate intera





Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Sun, 18 Apr 2010 15:48:08 GMT) (full text, mbox, link).


Acknowledgement sent to Sergei Golovan <sgolovan@gmail.com>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Sun, 18 Apr 2010 15:48:08 GMT) (full text, mbox, link).


Message #10 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@gmail.com>
To: Andreas Metzler <ametzler@downhill.at.eu.org>, 578271@bugs.debian.org
Cc: control@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Sun, 18 Apr 2010 19:45:29 +0400
tags 578271 + kfreebsd upstream
severity 578271 grave
thanks

On Sun, Apr 18, 2010 at 5:19 PM, Andreas Metzler
<ametzler@downhill.at.eu.org> wrote:
>
> On kfreebsd-* spawn/wait does not work as expected:

You're right, the bug is reproducible not only on Debian kFreeBSD
but also on a plain FreeBSD.

> ----------------
> ametzler@asdfasdf:$ cat /tmp/FIND/expect.bug
> #!/usr/bin/expect -f
>
> eval echo blubb

Though I'd replace eval by spawn.

> wait
>
> I suspect this should be an rc bug, please raise the severity if you agree.

I agree, it's an RC bug for kfreebsd.

Cheers!
-- 
Sergei Golovan




Added tag(s) upstream. Request was from Sergei Golovan <sgolovan@gmail.com> to control@bugs.debian.org. (Sun, 18 Apr 2010 15:48:14 GMT) (full text, mbox, link).


Severity set to 'grave' from 'important' Request was from Sergei Golovan <sgolovan@gmail.com> to control@bugs.debian.org. (Sun, 18 Apr 2010 15:48:15 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Sun, 18 Apr 2010 17:27:09 GMT) (full text, mbox, link).


Acknowledgement sent to Sergei Golovan <sgolovan@gmail.com>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Sun, 18 Apr 2010 17:27:09 GMT) (full text, mbox, link).


Message #19 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@gmail.com>
To: Andreas Metzler <ametzler@downhill.at.eu.org>, 578271@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Sun, 18 Apr 2010 21:25:12 +0400
On Sun, Apr 18, 2010 at 5:19 PM, Andreas Metzler
<ametzler@downhill.at.eu.org> wrote:
> and the process just hangs and only reacts to kill -9. I have found
> this when investigating why sv-bug-24169.exp in findutils testsuite
> does not work on kfreebsd-*.

A quick look reveals that expect hangs on waitpid() call in
Exp_WaitObjCmd() function defined in exp_commands.c

(A few lines from exp_commands.c):
----------------------------------------------------------------------
		while (1) {
		    if (Tcl_AsyncReady()) {
			int rc = Tcl_AsyncInvoke(interp,TCL_OK);
			if (rc != TCL_OK) return(rc);
		    }

		    result = waitpid(esPtr->pid,(int *)&esPtr->wait,0);
		    if (result == esPtr->pid) break;
		    if (result == -1) {
			if (errno == EINTR) continue;
			else break;
		    }
		}
----------------------------------------------------------------------

It seems like FreeBSD kernel doesn't terminate the spawned child if it
did print something to stdout and nobody has read the printed chars.

Though I'm not sure if this behavior is wrong. It's just different.
So, may be the correct way is to fix expect script? The following
script works fine on Linux and FreeBSD:

spawn echo blubb
expect {
eof {puts [wait]}
}

BTW, I've reported this bug upstream. See
https://sourceforge.net/tracker/?func=detail&aid=2989008&group_id=13179&atid=113179

Cheers!
-- 
Sergei Golovan




Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Mon, 19 Apr 2010 14:24:07 GMT) (full text, mbox, link).


Acknowledgement sent to Sergei Golovan <sgolovan@gmail.com>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Mon, 19 Apr 2010 14:24:07 GMT) (full text, mbox, link).


Message #24 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@gmail.com>
To: Andreas Metzler <ametzler@downhill.at.eu.org>, 578271@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Mon, 19 Apr 2010 18:22:20 +0400
On Sun, Apr 18, 2010 at 9:25 PM, Sergei Golovan <sgolovan@gmail.com> wrote:
>
> Though I'm not sure if this behavior is wrong. It's just different.
> So, may be the correct way is to fix expect script? The following
> script works fine on Linux and FreeBSD:
>
> spawn echo blubb
> expect {
> eof {puts [wait]}
> }

And the following script hangs both on Linux and FreeBSD kernels:

spawn echo [string repeat a 10000]
puts [wait]

Cheers!
-- 
Sergei Golovan




Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Sat, 01 May 2010 10:09:06 GMT) (full text, mbox, link).


Acknowledgement sent to Andreas Metzler <ametzler@downhill.at.eu.org>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Sat, 01 May 2010 10:09:06 GMT) (full text, mbox, link).


Message #29 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Andreas Metzler <ametzler@downhill.at.eu.org>
To: 578271@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Sat, 1 May 2010 12:07:04 +0200
On 2010-04-18 Sergei Golovan <sgolovan@gmail.com> wrote:
> On Sun, Apr 18, 2010 at 5:19 PM, Andreas Metzler
> <ametzler@downhill.at.eu.org> wrote:
> > and the process just hangs and only reacts to kill -9. I have found
> > this when investigating why sv-bug-24169.exp in findutils testsuite
> > does not work on kfreebsd-*.
[...]
> The following
> script works fine on Linux and FreeBSD:

> spawn echo blubb
> expect {
> eof {puts [wait]}
> }

Hello,

thak you for your help. Due to my (non existing) tcl knowledge I fail
to apply this to my avctual problem in the findutils testsuite
http://git.savannah.gnu.org/cgit/findutils.git/tree/find/testsuite/find.gnu/sv-bug-24169.exp
since I need the exit code.

The aim of this test is to run "find -neweraa" and verify that it
runs and exits cleanly with an error (exit code 1) instead of
segfaulting. (Bug #496853).

cu andreas




Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Sat, 01 May 2010 12:42:03 GMT) (full text, mbox, link).


Acknowledgement sent to Sergei Golovan <sgolovan@gmail.com>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Sat, 01 May 2010 12:42:03 GMT) (full text, mbox, link).


Message #34 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@gmail.com>
To: Andreas Metzler <ametzler@downhill.at.eu.org>, 578271@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Sat, 1 May 2010 16:38:58 +0400
[Message part 1 (text/plain, inline)]
On Sat, May 1, 2010 at 2:07 PM, Andreas Metzler
<ametzler@downhill.at.eu.org> wrote:
>
> The aim of this test is to run "find -neweraa" and verify that it
> runs and exits cleanly with an error (exit code 1) instead of
> segfaulting. (Bug #496853).

The attached patch to sv-bug-24169.exp should make test working on
kfreebsd also.

BTW, now I'm not sure which behavior is correct - FreeBSD which
doesn't kill a child process before the parent reads it's output, or
Linux which kills the child if it's output is sufficiently short.

Cheers!
-- 
Sergei Golovan
[sv-bug-24169.exp.diff (application/octet-stream, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Thu, 29 Jul 2010 03:57:06 GMT) (full text, mbox, link).


Acknowledgement sent to Ben Hutchings <ben@decadent.org.uk>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Thu, 29 Jul 2010 03:57:06 GMT) (full text, mbox, link).


Message #39 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Ben Hutchings <ben@decadent.org.uk>
To: Sergei Golovan <sgolovan@gmail.com>
Cc: Andreas Metzler <ametzler@downhill.at.eu.org>, 578271@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Thu, 29 Jul 2010 04:52:20 +0100
[Message part 1 (text/plain, inline)]
On Sat, 2010-05-01 at 16:38 +0400, Sergei Golovan wrote:
> On Sat, May 1, 2010 at 2:07 PM, Andreas Metzler
> <ametzler@downhill.at.eu.org> wrote:
> >
> > The aim of this test is to run "find -neweraa" and verify that it
> > runs and exits cleanly with an error (exit code 1) instead of
> > segfaulting. (Bug #496853).
> 
> The attached patch to sv-bug-24169.exp should make test working on
> kfreebsd also.
> 
> BTW, now I'm not sure which behavior is correct - FreeBSD which
> doesn't kill a child process before the parent reads it's output, or
> Linux which kills the child if it's output is sufficiently short.

A pipe normally has a buffer of size 1 page, so a process that writes up
to 4K to a pipe will not block while writing, but a process that writes
more than 4K will block if nothing reads from the other end of the pipe.

Neither kernel kills the child process, but Linux allows it to exit
immediately whereas FreeBSD appears to make it block on exit if it has
output buffered in a pipe.  This behaviour is useful because it
guarantees that the parent will receive the child's output and its exit
code in the 'right' order.  However, I think that either behaviour is
acceptable.

Ben.

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, Sergei Golovan <sgolovan@debian.org>:
Bug#578271; Package expect. (Thu, 29 Jul 2010 04:39:08 GMT) (full text, mbox, link).


Acknowledgement sent to Sergei Golovan <sgolovan@gmail.com>:
Extra info received and forwarded to list. Copy sent to Sergei Golovan <sgolovan@debian.org>. (Thu, 29 Jul 2010 04:39:08 GMT) (full text, mbox, link).


Message #44 received at 578271@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@gmail.com>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Andreas Metzler <ametzler@downhill.at.eu.org>, 578271@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Thu, 29 Jul 2010 08:37:19 +0400
On Thu, Jul 29, 2010 at 7:52 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
>
> Neither kernel kills the child process, but Linux allows it to exit
> immediately whereas FreeBSD appears to make it block on exit if it has
> output buffered in a pipe.  This behaviour is useful because it
> guarantees that the parent will receive the child's output and its exit
> code in the 'right' order.  However, I think that either behaviour is
> acceptable.

So, it isn't a bug (and certainly not a bug in Expect which just get what kernel
send to it)? Then I'll close the bugreport and will send your explanation to
the upstream. Thanks for clarification!

Cheers!
-- 
Sergei Golovan




Reply sent to Sergei Golovan <sgolovan@gmail.com>:
You have taken responsibility. (Thu, 29 Jul 2010 09:51:04 GMT) (full text, mbox, link).


Notification sent to Andreas Metzler <ametzler@downhill.at.eu.org>:
Bug acknowledged by developer. (Thu, 29 Jul 2010 09:51:04 GMT) (full text, mbox, link).


Message #49 received at 578271-close@bugs.debian.org (full text, mbox, reply):

From: Sergei Golovan <sgolovan@gmail.com>
To: 578271-close@bugs.debian.org
Subject: Re: Bug#578271: expect: [kFreeBSD] spawn/wait waits forever if command has any output
Date: Thu, 29 Jul 2010 13:47:04 +0400
Hi!

I'm closing this bugreport as invalid. [wait] behavior in Expect
reflects the underlying Linux or FreeBSD kernel differences.

Cheers!
-- 
Sergei Golovan




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Fri, 27 Aug 2010 07:36:42 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sat Dec 23 16:35:14 2023; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.