From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: `message' not outputting the newline "atomically" Date: Wed, 26 Jun 2019 11:15:54 +0200 Message-ID: References: <07619925-e367-fb88-2dd8-27addb2e9052@grinta.net> <68b398b1-3790-b32f-535d-6ea2518f79b8@cs.ucla.edu> <83r27hlkix.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="140672"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: eggert@cs.ucla.edu, daniele@grinta.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 26 11:16:20 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 1hg42O-000aLr-0s for ged-emacs-devel@m.gmane.org; Wed, 26 Jun 2019 11:16:20 +0200 Original-Received: from localhost ([::1]:37992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg42M-0005uq-Vp for ged-emacs-devel@m.gmane.org; Wed, 26 Jun 2019 05:16:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59632) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg42G-0005uG-Kk for emacs-devel@gnu.org; Wed, 26 Jun 2019 05:16:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hg42F-00009O-8s for emacs-devel@gnu.org; Wed, 26 Jun 2019 05:16:12 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:45954) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hg42E-0008SS-Uh; Wed, 26 Jun 2019 05:16:11 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hg41y-0002zY-6t; Wed, 26 Jun 2019 11:15:56 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUTEBzm5eGyqq7+//r+ /vCKf4j///7+/vnz8vH+/fX+//jZ1Nf////FwMZHQlD8+/RKKZsyAAABOUlEQVQ4jWPYnHYGExzL yWUQwyIOBAdxSWQyyOCSwKHjJG6Jbbgk9mCXOE49iWPoEsdyIPRh3Dpw+JzGEmdv5Jw5UYZF4qjC nWN637BIHFJglWNowyaxP44hAqsdG9+9e41N4rQeUxFWo85elTnTilXHVe0cBawSl/SiFdKw6ugI eIBVYnePHAM2iYO7e0OxG7VbVkYBW1idvSt2phWbxOmrgScCajAk0qfkqjIE8GHYcazSJVdN7p3O GQwdU1zWgnT8YehBkzBx8VV4eyKgB0PiiMtE1Zozp7FJLMsB2YUhcdLF7QxWieMuntgljk0BSaRh SgDdCyS2CjN8Q5coc8k5c/CqFlAixwxFAuSmpk1dDH+ABqJrOlOkeJjhzzEMYSCQOYanAEhLywGa ezjNOC0nrR4smAYESwCPNkT1uKsLyAAAAABJRU5ErkJggg== In-Reply-To: <83r27hlkix.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 25 Jun 2019 19:03:34 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.91.231.51 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:238152 Archived-At: Eli Zaretskii writes: > There was no reason to rush this to the repository. Paul raises valid > concerns, some of which I had as well. Also, the commit message > describes something that is very different from the code that was > actually pushed. The commit message talked about interleaved outputs, which is exactly what the patch tries to fix, so I'm not quite sure what you mean here... > I think a version with a fixed-size automatic buffer and a loop using > it to write the message in chunks, would be a much cleaner solution > than allocating the buffer off the heap. Unless I misunderstood something fundamental here (which is very possible), this is the function that's run when Emacs is in --batch mode and some code says `(message ...)'. I tried to trace the callers to see that this was the case. I may not have found them all (users are message3_nolog and message_with_string), but that does seem to be the use case. So this is not an error reporting function, but a bit inside `message', and I don't think anything that calls `message' could reasonably expect it to not allocate memory. > There's also a possibility to use the null byte that we > always/normally have in strings after the last byte. 'fwrite' doesn't > need it, so we could replace it with a newline, write the message, > then replace the newline back with the null byte. This is somewhat > hacky, but it eliminates the need for a buffer and a loop. That's an intriguing idea. But is there a possibility that the fwrite would fail in such a way that we'd not get back control in such a way that we could guarantee that we could replace the newline with a null byte again? Especially in a multi-threaded Emacs... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no