From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1691 invoked by alias); 2 Sep 2018 11:53:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43364 Received: (qmail 16783 invoked by uid 1010); 2 Sep 2018 11:53:57 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi0-f50.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.218.50):SA:0(-1.9/5.0):. Processed in 1.532882 secs); 02 Sep 2018 11:53:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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=jn565Juw2YXBVVCY7RDni65DYKu+yZehYTXxl0EAID4=; b=p44bVY+jVSEpLDCTHjbOQpMKJStjgG8+4TwdRq++7qMWJk+52TXKVA3D0iPmU2OSA0 NjvrQ7eTP4fwyvli47iwAtgk82eAO58n2OQfRJMSDpko3QABYoKr1U3JH8NwxA26EcWc TrSG8MYnCIrdGduV+sJOgaeaibC0aCThC8SK2QRoczuwN6YnioWp0eN4LSsSwdkav65l R15HDqBfrlpnLyMkKc8i1QEKDnxQdEOY8LKOUTaPJzcKvyF53jrRLxHiqmPwLMMll3J+ dGh3Gx+P/6i/e4t/iZfqcCjAF6iH/VtzFeHlaceuqcbLHTUTxLNn1BrIuJkUdcwY1k8s 1Ktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=jn565Juw2YXBVVCY7RDni65DYKu+yZehYTXxl0EAID4=; b=ahpNsX50KXh9zKFAdGXmxDe9+n6liUwipuxevGd0wdv3SzYVQ8RVTTPG1hxIfuocCj 3ZTFdvcwiqE7UVNAfIHwWNwChTUHVzQvhPUl/NkG+WqtIkVInPAFxk4h7AYW+v7lLs2s yjPJKRgNAvE2m1hFFEKJTtZ04HRxPK11wIdSinptP3bk+dnTQ55AEav6BM9sT/3z/00d 10bzpVqTvdRamH07PlpQaH0WORopCrXT9kp1xNRc7VvGvNXX6gFKfgBFcd51BnRm09aR MOOnug5ZJi17VhUwgNIw6ZQAD4xVvUQk3jTrxvaV8uoJ9R2T12qcqBPqTQhFHuEvfICa EeJg== X-Gm-Message-State: APzg51CRVvnI37bWtnN6vR+Ir+n2OCQCVsLNNMNCbiXPaU70ePTiscSu YyfU1y5EmzM3oZQdv0yHn2OeIIgjsoNbxyQLJ+nFTQ== X-Google-Smtp-Source: ANB0Vda313QKX1FEb8iOQtrAtt9taLuw10VUsrWwRxUPsDfdiQPdjX3WmvRAD+Qn6P7DO2QNM3CsBqLL+4JfGkKxKb4= X-Received: by 2002:a54:4805:: with SMTP id j5-v6mr16118020oij.210.1535889232786; Sun, 02 Sep 2018 04:53:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Sun, 2 Sep 2018 13:53:40 +0200 Message-ID: Subject: Re: [BUG?] Very strange behavior, execution of a function is interrupted To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Guys to state this more simply but also FUD-like: the little `read -q` brings up front whole Zle-command-line machinery, with sched, zle -F, waiting for inputs (select) on multiple file descriptors, running callbacks. Author of a script that asks y/n with `read -q` would never expect that he will run `sched' by it, embedding foreign scripts in middle of his script. This should have some attention, i.e. should be fixed. On Sat, 1 Sep 2018 at 21:12, Sebastian Gniazdowski wrote: > > 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 > 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 -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org