Date: Wed, 25 Nov 2015 17:34:27 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 204812] pty read blocks after select, if ^S is written in between Message-ID: <bug-204812-8@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204812 Bug ID: 204812 Summary: pty read blocks after select, if ^S is written in between Product: Base System Version: 10.2-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: cgull@glup.org The pts driver has an issue with breaking the promise made by select() that a read will not block, if there is a write of ^S to the pty between the select() and the read(). The reproduction for this is very simple: script /dev/null yes Type ^S. Type ^Q. Nothing happens, because script is hung on a blocking read. The read will never complete, because script is hung and your ^Q will never be delivered. I originally discovered this while working on mosh (net/mosh), but script blocks in the same way. The sequence of events that causes this: * The pty slave has software flow control enabled. * select() returns read status for the pty master fd. * Something write()s ^S to the pty master. * A read() is started on the pty master, with the expectation that it will not block. But it does block, and since the tty is stopped, it will never unblock without outside intervention. I hesitate to call this a bug, because the state of the pty *is* changed by that write, and the fix for this issue is not clear. But it violates POLA, other kernels (Linux, OpenBSD) do not behave this way, and the consequences are serious. I see this issue on FreeBSD 10.2, 9.1, and 7.2. An old 4.10 box doesn't have this issue. I originally discovered this bug while working on Mosh. It's not a new bug there. I've now implemented pty packet mode, and the problem exists there too, even though packet mode should always be able to avoid breaking this promise. See https://github.com/mobile-shell/mosh/issues/692 https://github.com/cgull/mosh/tree/pty-packet I don't understand why nobody has run into this issue before though, either on the FreeBSD or on the Mosh side. (Mosh has this problem on FreeBSD and OS X.) -- You are receiving this mail because: You are the assignee for the bug.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-204812-8>