[Bug 260938] script(1) hangs when child doesn't read input fast enough

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 04 Jan 2022 20:25:14 UTC

            Bug ID: 260938
           Summary: script(1) hangs when child doesn't read input fast
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: nabijaczleweli@nabijaczleweli.xyz

Created attachment 230710
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=230710&action=edit
Above core dump, zstd compressed

If there's enough input and the child doesn't read it in fast enough, script(1)
deadlocks on stdin to the child against the child writing to its stdout.

This is a regression from 4.4BSD-Lite, brought on by replacing the 2-process
model (i.e.
  leader:       stdin -> master pty
    child:      master pty -> stdout/fscript
      subchild: the command
) with a single process and select(2); writes to the master pty don't seem to
shard, and block forever; the child cannot continue because it's blocked on
writing its own data.

This is the same bug as in util-linux's implementation (though that uses
poll(2)), so please see this Debian bug for more words on the topic:

Attaching core I got after ^\ing and trace from 
  ktrace script /dev/null sh -c 'for i in $(seq 10); do echo $i; done; read -r
a; echo a=$a' < lc
wherein lc is
  b64encode /lib/libc.so.7 /lib/libc.so.7  > lc
uname -a says "FreeBSD build 13.0-RELEASE-p4 FreeBSD 13.0-RELEASE-p4 #0: Tue
Aug 24 07:33:27 UTC 2021    

You are receiving this mail because:
You are the assignee for the bug.