zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: Confirming X02zlevi test failures
Date: Sun, 23 Nov 2014 10:00:45 +0100	[thread overview]
Message-ID: <13277.1416733245@thecus.kiddle.eu> (raw)
In-Reply-To: <2D312191-3B6F-49BE-9289-95DDA6DAC1F4@kba.biglobe.ne.jp>

"Jun T." wrote:
> If I commented out 'zpty_flush After zletest', then 2/1000 failed.
> Then I changed 'read -t 0.011' to 'read -t 0.02' and got 1000/1000 success.

One thing to be wary of when using the vi test is that there is no
counter test in there: we don't have a test of username completion on
\e~ with a suitable lack of delay between the two keystrokes.

If we can make it work, we should probably have two earlier tests
explicitly testing KEYTIMEOUT.

Bart wrote:
> I begin to suspect that what needs to happen is that zpty needs to be a
> lot more aggressive internally about consuming (and buffering up) the
> slave output as fast as it appears

I decided to see if I could reproduce the problem using expect. The
results somewhat convince me that tweaking zpty isn't going to help.
With expect it is easier to adjust the delays and parameters. But the
results aren't always making much sense, either on Linux or BSD. On
Linux, switching between precisely 1000 and 999 micro seconds was making
a difference. I've attached the expect script. The second parameter to
send_slow and -s option to send control the delays but other, seemingly
innocuous, changes can also make a difference.

> The second thing I found is that, possibly for the same reason, the
> delayzetterm flag is (inconsistently in terms of zletest input, but
> consistently for this particular test) getting set, which causes
> KEYTIMEOUT to be ignored.  The comment for delayzetterm says:

I've been looking at this too. I noticed instances where the
FIONREAD in getbyte() was returning 0, it then called zsetterm again
which does another FIONREAD ioctl but received a value of 5. There's an
unavoidable race condition if we can't stop more characters coming in
between the FIONREAD and the settyinfo. Even so, it seems a bit
pointless to do the ioctl twice. I've attached a patch to make getbyte
just call zsetterm again and rely on it trying the ioctl again. Not that
this helps us much.

Are you just using strategically placed dputs for instrumentation? I
seem to get nothing from them after the terminal has been configured.
truss/ltrace are not much use. dtrace is just hanging for me but I've
never tried it on BSD before. I'll try gdb with a command file. I've
just realised on reading the e-mail before sending that the dtrace
problem is because the prompt is # for root instead of the % that expect
is expecting. I couldn't find a way to enable it for a normal user on
BSD.

Oliver

diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index d157e36..a38f55b 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -238,9 +238,9 @@ zsetterm(void)
 	 * we can't set up the terminal for zle *at all* until
 	 * we are sure there is no more typeahead to come.  So
 	 * if there is typeahead, we set the flag delayzsetterm.
-	 * Then getbyte() performs another FIONREAD call; if that is
-	 * 0, we have finally used up all the typeahead, and it is
-	 * safe to alter the terminal, which we do at that point.
+	 * Then getbyte() calls here to performs another FIONREAD call;
+	 * if that is 0, we have finally used up all the typeahead, and
+	 * it is safe to alter the terminal, which we do at that point.
 	 */
 	delayzsetterm = 1;
 	return;
@@ -884,12 +884,8 @@ getbyte(long do_keytmout, int *timeout)
 	ret = STOUC(kungetbuf[--kungetct]);
     else {
 #ifdef FIONREAD
-	if (delayzsetterm) {
-	    int val;
-	    ioctl(SHTTY, FIONREAD, (char *)&val);
-	    if (!val)
-		zsetterm();
-	}
+	if (delayzsetterm)
+	    zsetterm();
 #endif
 	for (;;) {
 	    int q = queue_signal_level();

#<text/plain
#!/usr/local/bin/expect -f
set timeout -1
set send_slow { 1 .05 }
spawn -noecho -nottyinit -nottycopy inst/bin/zsh -f
expect %
send "bindkey -s '\\e~' user\r"
expect %
#send "KEYTIMEOUT=40\r"
#expect %
send -s ": o\033~\r"
expect {
    O { puts "\nswap case" }
    user { puts "\nusername completion" }
}
send "exit\r"


  parent reply	other threads:[~2014-11-23  9:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 16:50 Bart Schaefer
2014-11-19 17:25 ` Ray Andrews
2014-11-19 23:05 ` Oliver Kiddle
2014-11-20  6:20   ` Bart Schaefer
2014-11-20 15:42     ` Jun T.
2014-11-20 17:18       ` Bart Schaefer
2014-11-21 14:37         ` Oliver Kiddle
2014-11-21 18:18         ` Jun T.
2014-11-21 18:56           ` Bart Schaefer
2014-11-23  1:37             ` Jun T.
2014-11-23  3:32               ` Bart Schaefer
2014-11-23  7:44                 ` Jun T.
2014-11-24  0:11                   ` Bart Schaefer
2014-11-23  9:00               ` Oliver Kiddle [this message]
2014-11-23 18:37                 ` Bart Schaefer
2014-11-25 17:13         ` Jun T.
2014-11-25 17:32           ` Jun T.
2014-11-25 19:01             ` Bart Schaefer
2014-11-26  2:31               ` Jun T.
2014-11-26 14:51                 ` Oliver Kiddle
2014-11-26 15:45                   ` Peter Stephenson
2014-11-26 16:37                     ` Bart Schaefer
2014-11-27 14:11                       ` Oliver Kiddle
2014-12-01 10:58                         ` Jun T.
2014-12-05 14:36                           ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13277.1416733245@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).