From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.bugs Subject: bug#39610: R6RS `flush-output-port` not playing along with `transcoded-port` Date: Sun, 22 Mar 2020 23:50:47 +0100 Message-ID: <87r1xkj96g.fsf@r0tty.org> References: <87d0agu2yd.fsf@londo.h.r0tty.org> <87wo8orvr9.fsf@londo.h.r0tty.org> <874kuhzj6l.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="107818"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.3.6; emacs 27.0.50 Cc: 39610@debbugs.gnu.org To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sun Mar 22 23:51:13 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jG9R3-000Rtr-LL for guile-bugs@m.gmane-mx.org; Sun, 22 Mar 2020 23:51:13 +0100 Original-Received: from localhost ([::1]:54680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jG9R2-0008Ji-Ae for guile-bugs@m.gmane-mx.org; Sun, 22 Mar 2020 18:51:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57452) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jG9Qt-0008Em-OW for bug-guile@gnu.org; Sun, 22 Mar 2020 18:51:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jG9Qs-00021e-MB for bug-guile@gnu.org; Sun, 22 Mar 2020 18:51:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45157) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jG9Qs-00021a-CM for bug-guile@gnu.org; Sun, 22 Mar 2020 18:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jG9Qs-0000q2-9e for bug-guile@gnu.org; Sun, 22 Mar 2020 18:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Rottmann Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 22 Mar 2020 22:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39610 X-GNU-PR-Package: guile Original-Received: via spool by 39610-submit@debbugs.gnu.org id=B39610.15849174613215 (code B ref 39610); Sun, 22 Mar 2020 22:51:02 +0000 Original-Received: (at 39610) by debbugs.gnu.org; 22 Mar 2020 22:51:01 +0000 Original-Received: from localhost ([127.0.0.1]:51130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jG9Qr-0000pn-Bt for submit@debbugs.gnu.org; Sun, 22 Mar 2020 18:51:01 -0400 Original-Received: from ghost.xx.vu ([185.33.11.101]:47895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jG9Qp-0000pe-Aj for 39610@debbugs.gnu.org; Sun, 22 Mar 2020 18:51:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=r0tty.org; s=20200309; t=1584917449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1tFiajl+UxYm5ZrgI+r6FkpnOQ8Klp2Z6noaQqyJx8s=; b=tlltqwMoVUFv5GXlHHmtzX8x5yusbro0LYKvLmm06DIhI1azn0iCjCzasvn9g/wBkTr4+L yOLGPeO7hYZ/v+HR8vw6XJO1KDbz9duRtk/taWmo9wVwUDRJpMimLw4bQRs9gJ6ExcS8L7 +aoyx3gd75/IwYFggvwA3jNF3pYdE4w= Original-Received: from mail0.xx.vu (localhost [::1]) by ghost.xx.vu (OpenSMTPD) with ESMTP id 162a9ab4; Sun, 22 Mar 2020 22:50:49 +0000 (UTC) Original-Received: from londo ([46.125.250.111]) by mail0.xx.vu with ESMTPSA id yiBsFsnrd15lUQEAg/rtjg (envelope-from ); Sun, 22 Mar 2020 22:50:49 +0000 In-reply-to: <874kuhzj6l.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9684 Archived-At: Ludovic Court=C3=A8s writes: > Hi Andreas, > > And welcome back! :-) > Thanks -- and thanks in return for looking into this! > Andreas Rottmann skribis: > >> Andreas Rottmann writes: >> >>> [...] I isolated the cause; the following snippet hangs on Guile 2.2 >>> and 3.0, while it worked as expected on 2.0: >>> >>> ;; ------------------ >>> (import (rnrs)) >>> >>> (let* ((p (pipe)) >>> (in (car p)) >>> (out (transcoded-port (cdr p) (make-transcoder (utf-8-codec))))) >>> (put-datum out "foo") >>> (flush-output-port out) >>> (display "Should have written to pipe by now, attempting reading a by= te\n") >>> (display "Got") >>> (display (get-u8 in)) >>> (newline)) >>> ;; ------------------- >>> >>> It seems the underlying port is no longer flushed to the OS, so the >>> `get-u8` now hangs waiting for input, starting with Guile 2.2. >>> >> I'd like to add that this is indeed not passing data to the OS, as >> verified by strace. Also, I have now figured out the commit introducing >> the regression, namely 8399e7af5 ("Generic port facility provides >> buffering uniformly"); the commit before (e8eeeeb1d) still runs the >> above code to completion. > > Actually I think the code above behaves as expected. =E2=80=98pipe=E2=80= =99 returns > buffered ports by default. When flushing the transcoded port, > =E2=80=98transcoded_port_write=E2=80=99 is called, but then bytes written= to the pipe > are buffered. > > The fix is to add: > > (setvbuf (cdr p) 'none) > > Does that make sense? > It makes sense, and I can confirm that it makes the boiled-down example I posted work. However, I'm not sure it is the expected behavior. Regardless of buffering modes used, I would expect a `flush-output-port` in a "port stack" (as produced by `transcoded-output-port`) to propagate all the way to the OS. It seems that was the case in Guile 2.0, as I'm pretty sure I observed the "breaking" behavior change with 8399e7af5 applied, and not with the commit preceding it. If the current behavior is indeed the intended one, we should make sure the docs somehow reflect this caveat, as I imagine it may surprise future Guile users which happen to use its R6RS support and pipes in combination. Regards, Rotty