Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG?] Very strange behavior, execution of a function is interrupted
- X-seq: zsh-workers 43361
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [BUG?] Very strange behavior, execution of a function is interrupted
- Date: Sat, 1 Sep 2018 21:12:26 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=0749i+u8nElgrcpGAKrm7JkW8hhsUYpph3tugMBcY4I=; b=Y2XvfdU5FOD2RQwDs6Zsz87a8DOSE9011bhwXhcChxsn+lgq7KBsg8tctmxUt7R5Sl yxV2KjSDCpSkJeQbPS8ZQTYrg45mwuVGVcC6HVkxK4iUcvt+WihODG89a9dyZSQV7zIt p5chbaZXS5Ypq6KR2wXQQtNQZgO9NVqwsLGGhA+3GttijTVGVFFUe3ZBQL3Zz9kYm6qb ++0uiehnkHXQTlFf3RkGSgLeUy11fn6SEbyRF1d19Yg4zBYe2iHvVIHGE8LV8++9y/S5 XKJhmd7c2UBZsaq8f3NAX6Ly/C+2/pTe0UFpnBwTAjuAqfRA1dDHeADb2fJ5YkHEJlEH 2sjw==
- In-reply-to: <CAKc7PVCfFXZuEVd510JJLKQ6g0kDC7KRDBmR+=36CcOUceDquQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCfFXZuEVd510JJLKQ6g0kDC7KRDBmR+=36CcOUceDquQ@mail.gmail.com>
I've found the cause. `compinit' does `read -q' when occurring
insecure directories. If this happens from `sched' with possibly Zle
being active, then following call inside bin_read() uses Zle's
raw_getbyte() to read a character:
zleentry(ZLE_CMD_GET_KEY, izle_timeout, NULL, &val);
This means that `read' can make all the rich side-effects of the regular
command-line to activate. I think this has significant importance, is
severe. I wouldn't expect the `read' builtin to bring up whole `zle -F'
handling, waiting for inputs, invoking callbacks.
Below test code confirms the above thesis. Its execution is recorded
here: https://asciinema.org/a/199265 Basically, my problem is that
Zplugin's scheduler gets invoked in nested manner because of
compinit's `read -q' (I was doing stress tests with compaudit
activating) and data structures go to improper state.
FD=1337; setup() {
exec {FD}< <( sleep 1; echo run )
zle -F $FD -my-scheduler
echo "Sched call reporting being called"
read -q "?[y/n]?"
echo "Sched call reporting exiting"
}
-my-scheduler() {
local THEFD="$1"; zle -F "$THEFD"; exec {THEFD}<&- # remove zle -F handler
echo "Zle -F handler reporting being called"
}
sched +1 setup
On Sat, 1 Sep 2018 at 00:01, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> Hello,
> it's quite a lost game to explain this, but I'll try:
>
> - there is a scheduler called from sched +1 and once from zle -F
> - it detects timed-out tasks, moves them to ZPLG_RUN, then executes
> them reading them from this array
>
> Problem: sometimes execution never reaches this line and beyond:
> https://github.com/zdharma/zplugin/blob/7a24478e5862a1359b6cfb2887a792213be07e3a/zplugin.zsh#L1485
>
> Some cycles of the preceding loop are then also skipped.
>
> I feel very helpless in explaining this, maybe there's standard
> questions sheet for situation where bug in exec.c is suspected?
>
> I know `break 2' inside a function will break out of loop that
> contains the function call. But I don't know what could exit a
> function. I have debug prints and observe this clearly. At the
> mentioned line, no execution occurs, ZPLG_RUN isn't cleared, I get to
> run some tasks twice.
>
> Twice when I checked, it was happening when zle -F was called so near
> next second, that timeout'd tasks detection included two time slots:
> "0" (0 seconds after first precmd, handled by zle -F) and "1" (1
> second after first precmd, handled by sched +1).
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author