From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: `message' not outputting the newline "atomically" Date: Sun, 23 Jun 2019 10:32:48 -0700 Organization: UCLA Computer Science Department Message-ID: References: <83y31xr3aa.fsf@gnu.org> <26154872-1a5c-7302-0f32-b16aff8e0ae7@cs.ucla.edu> <83blytq90m.fsf@gnu.org> <95de57fb-ef8c-a65f-d3ca-4a9e7f0f38bc@cs.ucla.edu> <83a7ecquzb.fsf@gnu.org> <83tvckp5ni.fsf@gnu.org> <83r27op1wb.fsf@gnu.org> <60d1b05d-ef4c-252a-0626-8c69c103fdf0@cs.ucla.edu> <83o92rpk1g.fsf@gnu.org> <9d07a8e2-7f9b-bbfa-b73e-0d7aee09b099@cs.ucla.edu> <83zhmankgu.fsf@gnu.org> <31b12a41-18f2-d20c-55dc-28f7adb8606c@cs.ucla.edu> <83y31tm40j.fsf@gnu.org> <6f34c3a3-2f0a-e581-0dfe-4e4619e0b3dc@cs.ucla.edu> <83sgs0mk9d.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------63C5475B4314D261D9BAD7B6" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="85472"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 Cc: schwab@suse.de, larsi@gnus.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 23 19:38:28 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hf6Rg-000M5N-1g for ged-emacs-devel@m.gmane.org; Sun, 23 Jun 2019 19:38:28 +0200 Original-Received: from localhost ([::1]:46086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hf6Re-0003tm-Ez for ged-emacs-devel@m.gmane.org; Sun, 23 Jun 2019 13:38:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40860) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hf6MP-00012D-3H for emacs-devel@gnu.org; Sun, 23 Jun 2019 13:33:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hf6MO-0002zx-1q for emacs-devel@gnu.org; Sun, 23 Jun 2019 13:33:01 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hf6MJ-0002mJ-5v; Sun, 23 Jun 2019 13:32:55 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 23227161C02; Sun, 23 Jun 2019 10:32:50 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id BTtnrk2MHYOw; Sun, 23 Jun 2019 10:32:49 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0B35B161C3E; Sun, 23 Jun 2019 10:32:49 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CuIfgLW24Pbd; Sun, 23 Jun 2019 10:32:48 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CB21C160964; Sun, 23 Jun 2019 10:32:48 -0700 (PDT) In-Reply-To: <83sgs0mk9d.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238068 Archived-At: This is a multi-part message in MIME format. --------------63C5475B4314D261D9BAD7B6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > Bugs aren't hypotheses, they actually happen. I've looked carefully for any of the bugs hypothesized so far, and haven't found any. That's not to say they don't exist, but these mythical creatures are so rare that in practice it's fair to assert that they are less important than the practical bugs that this patch fixed. If we could use hypothetical bugs as part of the argument, I could easily hypothesize bugs where unbuffered stderr produces less-useful output than line-buffered stderr does. But that would be going down a rabbit hole. We should focus on bugs that actually occur rather than implausible bugs hypothesized for the sake of argument. > the primary purpose of stderr is to produce diagnostic > error messages And if these diagnostics are confusing or unintelligible, as with unbuffered stderr, this purpose is not being fulfilled. > That use case could have a more specialized solution Sure: we could take every bit of Emacs code that produces piecemeal stderr output, and rewrite it to generate the output into a temporary memory buffer and then output that buffer manually. For example, we could install something like the attached patch to address the dump_fingerprint issue. But this sort of change would be counterproductive: it would complicate the code and it would not make diagnostic output any more reliable (on the contrary - just look at all those tricky buffer-size calculations). In contrast, using _IOLBF is a one-line fix that fixes the problem without introducing all this complexity and unreliability. --------------63C5475B4314D261D9BAD7B6 Content-Type: text/x-patch; name="handbuffer.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="handbuffer.diff" diff --git a/src/pdumper.c b/src/pdumper.c index c00f8a0af5..c4d48cc575 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -326,10 +326,16 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset) static void dump_fingerprint (const char *label, unsigned char const *xfingerprint) { - fprintf (stderr, "%s: ", label); + /* The maximum length of LABEL. If you change code that calls this + function you may need to change this value. */ + enum { max_label_length = sizeof "desired fingerprint" - 1 }; + + char buf[max_label_length + sizeof ": \n" + 2 * 32]; + int buflen = sprintf (buf, "%s: ", label); for (int i = 0; i < 32; ++i) - fprintf (stderr, "%02x", (unsigned) xfingerprint[i]); - fprintf (stderr, "\n"); + buflen += sprintf (buf + buflen, "%02x", (unsigned) xfingerprint[i]); + buf[buflen++] = '\n'; + fwrite (buf, 1, buflen, stderr); } /* Format of an Emacs portable dump file. All offsets are relative to --------------63C5475B4314D261D9BAD7B6--