From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#6149: bug#24531: process-send-string seems to truncate lines over 4096 characters Date: Thu, 27 Jul 2023 07:51:31 -0700 Organization: UCLA Computer Science Department Message-ID: References: <87aas81jgh.fsf@jidanni.org> <83sf9h257b.fsf@gnu.org> <19e73ab0-19b5-d7f4-8912-20c9e822e3fb@gutov.dev> <83r0otnc67.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32132"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 6149@debbugs.gnu.org, Dmitry Gutov , monnier@iro.umontreal.ca, jidanni@jidanni.org To: Spencer Baugh , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 27 17:32:04 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qP2yC-00089g-0O for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Jul 2023 17:32:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP2LW-0000sq-Ib; Thu, 27 Jul 2023 10:52:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP2LT-0000oa-4G for bug-gnu-emacs@gnu.org; Thu, 27 Jul 2023 10:52:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qP2LS-0005MI-QR for bug-gnu-emacs@gnu.org; Thu, 27 Jul 2023 10:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qP2LS-0006f8-MA for bug-gnu-emacs@gnu.org; Thu, 27 Jul 2023 10:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Jul 2023 14:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6149 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 6149-submit@debbugs.gnu.org id=B6149.169046950625562 (code B ref 6149); Thu, 27 Jul 2023 14:52:02 +0000 Original-Received: (at 6149) by debbugs.gnu.org; 27 Jul 2023 14:51:46 +0000 Original-Received: from localhost ([127.0.0.1]:42851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qP2L8-0006eA-OQ for submit@debbugs.gnu.org; Thu, 27 Jul 2023 10:51:45 -0400 Original-Received: from mail.cs.ucla.edu ([131.179.128.66]:47242) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qP2L3-0006du-H6 for 6149@debbugs.gnu.org; Thu, 27 Jul 2023 10:51:41 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id F23483C011BD9; Thu, 27 Jul 2023 07:51:31 -0700 (PDT) Original-Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 0yw-nbW4GA9T; Thu, 27 Jul 2023 07:51:31 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id A73C63C011BDA; Thu, 27 Jul 2023 07:51:31 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu A73C63C011BDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1690469491; bh=POTI/VGioPjY2O/ksnzrG2VhCjLxobvZdmrkrrLZ3GY=; h=Message-ID:Date:MIME-Version:To:From; b=BzAbibrf300Qe5Fk0GSXlS4Cvm6Wkf7z3G78ORPIgzX4SWw9ZxMIlXReIEGpTlbJ5 6vzkC9u8YTdeMSDxLZ5ESh8+gxD4M9PUYijWvlrSpjx/hzN3G/Xhi1HkJGsAHP/5dq TZuKTFx6sXt/RJjI8FFuV8RvcSb8Xw89f8wpa/xQ9ssHsXuC1l3XE7mefFGHkilIic tCbzCUO58Bm4awssS9uzieRFvV9Z1CsP6jCV1blk3bdNta+g5oEVlDPSm/3SKte+0Q ZGVkU2Us0Yxo8+5TTqAQsPfZvhc9zyr4mlWbng5N8ksLcMnMTP14pn+oKsurje8NpC 42QG5LikF1/LQ== X-Virus-Scanned: amavisd-new at mail.cs.ucla.edu Original-Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hTym5FBOdbxg; Thu, 27 Jul 2023 07:51:31 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 751FB3C011BD9; Thu, 27 Jul 2023 07:51:31 -0700 (PDT) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266199 Archived-At: On 2023-07-27 06:59, Spencer Baugh wrote: >> AFAIU, that is based on the errno value returned by a 'write' call >> which attempts to write too many bytes (see the would_block function). >> I guess writes to PTYs don't do that? > Writes to PTYs do tell us when the data has been truncated. Unfortunately not. Data bytes are silently truncated, at least on Ubuntu 23.04. If I fire up Emacs and type: M-x shell RET cat >out RET C-u 4096 x RET C-d the last RET causes Emacs to write 4097 bytes (4096 'x's followed by a newline) to the pty. This 'write' system call succeeds and returns 4097. However, the two 'read' calls that 'cat' executes see only 4095 'x's followed by '\n' ('read' returns 4096) followed by EOF ('read' returns 0). An 'x' was lost, and Emacs has no way to see this directly. This comes from the canonical mode of Linux's terminal driver, which silently discards non-newline bytes after the 4095th byte of an input line. See: https://github.com/torvalds/linux/blob/v6.4/drivers/tty/n_tty.c#L1648 One possibility is that Emacs could monitor writes to a Linux pty, looking for too many non-newline bytes in a row, and warn the user if that number exceeds 4095. That might be the best it can do in this troublesome environment. (The warning would be irrelevant for ttys operating in non-canonical mode, which have a different set of problems.)