From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Zle goes through select() quickly growin # of times
Date: Sun, 17 Jun 2018 22:25:26 +0200 [thread overview]
Message-ID: <CAKc7PVA2b+yZXJsjHARfLeeXiALnNWeyyGfqUnfUREny65PAiw@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVCUQD-VK_D-xWVU674HzB0LdthfJPvG6JscKCSqJOVgWg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]
The forgotten debug prints patch, attached. First file count.txt is
just a proof that I'm not making this up ;)
On 17 June 2018 at 22:23, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> Hello,
> I'm debugging the reason why Ctrl-C can be ignored. U stumbled upon this:
>
> 1. I open shell, enter "ls ", then press Ctrl-C
> 2. Debug logs from before "< master Zle select()" and after "> master
> Zle select()" occur
> 3. At first Ctrl-C, there are 24 select() recurrent code execution
> paths – the logs around select() are triggered ~24 times.
> 4. At second "ls <Ctrl-C>", there are 96 recurrent code paths.
> 5. At third "ls <Ctrl-C>, there are 197 recurrent code paths.
>
> The logs are:
>
> BASIC < select Before: selret: 0, errflag: 0, retflag: 0, breaks: 0,
> exit_pending: 0
> BASIC > select After: selret: 0, errflag: 0, retflag: 0, breaks: 0,
> exit_pending: 0
>
> two lines, installed before master select() (first line) and after the
> master select (second line).
>
> Could it be that Zsh reacts in this way after occurring Ctrl-C? It's
> somewhat hard to believe. That's why I include also patch with debug
> prints that I've used. Maybe someone will just apply it and do "ls
> <Ctrl-C>".
>
> Also: asciinema recording, showing how the series of logs grow (1 tmux
> screen / page, then 4 tmux screens / pages, then 9 pages to scroll up
> to see the logs beginnings'):
>
> https://asciinema.org/a/hC24KqphbztwQfk5ApZbOYU2y
>
> --
> Best regards,
> Sebastian Gniazdowski
[-- Attachment #2: select_recurrence_debug_prints.diff.txt --]
[-- Type: text/plain, Size: 3156 bytes --]
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index b78c47e..d95eaad 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -343,8 +343,12 @@ static int kungetsz;
void
ungetbyte(int ch)
{
- if (kungetct == kungetsz)
+ if (kungetct == kungetsz) {
+ fprintf( fopen("/tmp/reply", "a"), "== kungetct: %d, kungetsz: %d\n == ... realloc kungetsz*2 :: ", kungetct, kungetsz );
kungetbuf = realloc(kungetbuf, kungetsz *= 2);
+ } else {
+ fprintf( fopen("/tmp/reply", "a"), "== kungetct: %d, kungetsz: %d\n == ... NO realloc:: ", kungetct, kungetsz );
+ }
kungetbuf[kungetct++] = ch;
}
@@ -527,6 +531,7 @@ raw_getbyte(long do_keytmout, char *cptr)
*/
if ((nwatch || tmout.tp != ZTM_NONE)) {
#if defined(HAVE_SELECT) || defined(HAVE_POLL)
+#warning Yes, declaring selret ---------------------
int i, errtry = 0, selret;
# ifdef HAVE_POLL
int nfds;
@@ -581,9 +586,15 @@ raw_getbyte(long do_keytmout, char *cptr)
else
poll_timeout = -1;
+ fprintf( fopen("/tmp/reply", "a"), "BASIC <poll Before[poll]: selret: %d, errflag: %d, retflag: %d, breaks: %d, exit_pending: %d\n",
+ selret, errflag, retflag, breaks, exit_pending );
+
winch_unblock();
selret = poll(fds, errtry ? 1 : nfds, poll_timeout);
winch_block();
+
+ fprintf( fopen("/tmp/reply", "a"), "BASIC >poll After[poll]: selret: %d, errflag: %d, retflag: %d, breaks: %d, exit_pending: %d\n",
+ selret, errflag, retflag, breaks, exit_pending );
# else
int fdmax = SHTTY;
struct timeval *tvptr;
@@ -611,10 +622,16 @@ raw_getbyte(long do_keytmout, char *cptr)
else
tvptr = NULL;
+ fprintf( fopen("/tmp/reply", "a"), "BASIC < select Before: selret: %d, errflag: %d, retflag: %d, breaks: %d, exit_pending: %d\n",
+ selret, errflag, retflag, breaks, exit_pending );
+
winch_unblock();
selret = select(fdmax+1, (SELECT_ARG_2_T) & foofd,
NULL, NULL, tvptr);
winch_block();
+
+ fprintf( fopen("/tmp/reply", "a"), "BASIC > select After: selret: %d, errflag: %d, retflag: %d, breaks: %d, exit_pending: %d\n",
+ selret, errflag, retflag, breaks, exit_pending );
# endif
/*
* Make sure a user interrupt gets passed on straight away.
@@ -864,10 +881,16 @@ getbyte(long do_keytmout, int *timeout)
lastchar_wide_valid = 0;
#endif
- if (kungetct)
+ if (kungetct) {
ret = STOUC(kungetbuf[--kungetct]);
- else {
+ fprintf( fopen("/tmp/reply", "a"), "== DIRECT! kungetct: %d, kungetsz: %d\n == ... continuing:: "
+ "errflag: %d, retflag: %d, breaks: %d, exit_pending: %d\n",
+ kungetct, kungetsz,
+ errflag, retflag, breaks, exit_pending );
+ } else {
for (;;) {
+ fprintf( fopen("/tmp/reply", "a"), "== FOR (;;)! kungetct: %d, kungetsz: %d\n == ... continuing:: \n",
+ kungetct, kungetsz );
int q = queue_signal_level();
dont_queue_signals();
r = raw_getbyte(do_keytmout, &cc);
next prev parent reply other threads:[~2018-06-17 20:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-17 20:23 Sebastian Gniazdowski
2018-06-17 20:25 ` Sebastian Gniazdowski [this message]
2018-06-17 20:39 ` Sebastian Gniazdowski
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=CAKc7PVA2b+yZXJsjHARfLeeXiALnNWeyyGfqUnfUREny65PAiw@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--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).