GNU bug report logs - #49078
dejagnu-1.6.3 test failure

Previous Next

Package: dejagnu;

Reported by: Xi Ruoyao <xry111 <at> mengyan1223.wang>

Date: Thu, 17 Jun 2021 19:44:02 UTC

Owned by: jcb62281 <at> gmail.com

Severity: normal

Full log


Message #28 received at 49078 <at> debbugs.gnu.org (full text, mbox):

From: Adam Sampson <ats <at> offog.org>
To: 49078 <at> debbugs.gnu.org
Subject: Re: dejagnu-1.6.3 test failure
Date: Sat, 23 Oct 2021 01:10:46 +0100
(I've just sent this to the mailing list, but so it's in the bug report
as well...)

Jacob Bachmeyer <jcb62281 <at> gmail.com> writes:

> Expect is incorrectly treating a line exactly 64 bytes long as EOF.

I've just run into this as well when packaging 1.6.3 -- for me, it
happens on Linux 5.10 but not on Linux 4.19, where expect's read(0, buf,
4096) call reads 65 bytes including the newline. So I guess it's become
visible as a result of some change in Linux tty behaviour...

After a bit of debugging, the cause seems to be that expect uses
Tcl_GetsObj to read from stdin, and treats a -1 return value as an
error. However, Tcl_GetsObj can also return -1 to indicate that input
was blocked, i.e. it didn't manage to read a complete line -- expect
didn't handle this case.

This patch seems to fix the problem:

--- expect5.45.4/exp_main_sub.c	2018-02-04 10:43:58.000000000 +0000
+++ expect5.45.4/exp_main_sub.c	2021-10-23 00:39:09.375404444 +0100
@@ -326,7 +326,9 @@
 
 	if (code != EXP_EOF) {
 	    inChannel = expStdinoutGet()->channel;
-	    code = Tcl_GetsObj(inChannel, commandPtr);
+	    do {
+		code = Tcl_GetsObj(inChannel, commandPtr);
+	    } while (code < 0 && Tcl_InputBlocked(inChannel));
 #ifdef SIMPLE_EVENT
 	    if (code == -1 && errno == EINTR) {
 		if (Tcl_AsyncReady()) {

(expect experts may have a better solution, of course!)

Thanks,

-- 
Adam Sampson <ats <at> offog.org>                         <http://offog.org/>




This bug report was last modified 3 years and 238 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.