From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master d582356: * src/fns.c (Frandom): Handle bignum `limit`s Date: Sat, 06 Mar 2021 16:45:50 +0200 Message-ID: <838s70wdb5.fsf@gnu.org> References: <20210305170955.27732.27579@vcs0.savannah.gnu.org> <20210305170957.AF99920E1B@vcs0.savannah.gnu.org> <83sg58wu0v.fsf@gnu.org> <83k0qkwnwt.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23331"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 06 15:46:54 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lIYCj-0005yn-Q2 for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Mar 2021 15:46:53 +0100 Original-Received: from localhost ([::1]:41630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIYCi-0002zD-Od for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Mar 2021 09:46:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIYBv-0002RH-HQ for emacs-devel@gnu.org; Sat, 06 Mar 2021 09:46:05 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:39419) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIYBv-0002eT-8e; Sat, 06 Mar 2021 09:46:03 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1096 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lIYBt-0006uv-RO; Sat, 06 Mar 2021 09:46:03 -0500 In-Reply-To: (message from Pip Cet on Sat, 6 Mar 2021 13:22:10 +0000) 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266075 Archived-At: > From: Pip Cet > Date: Sat, 6 Mar 2021 13:22:10 +0000 > Cc: Stefan Monnier , emacs-devel@gnu.org > > > > So I'm not sure whether code_conversion_save is allowed to call Lisp. > > > I'd rather it didn't, for more than one reason. But we can side-step > > this by making Fgenerate_new_buffer_name use random-fixnum, which is > > still a pure-C implementation. > > Here's a patch which makes it use get_random() directly. Thanks, maybe add a comment explaining the need for the do-while loop in generate-new-buffer-name. > Actually, I think it would be best to have these restrictions > represented in the code. I see two ways of doing that: > > 1. Have FUNCTION_MAY_GC etc. translate into a GCC attribute in debug > builds so we can statically check that a function that says it never > calls GC doesn't call a function that says it may call GC. > 2. Have a statement at the beginning of non-GCing functions which sets > a flag that is then checked by garbage-collecting functions, so that > we may dynamically check this. > > (1) seems easy to implement, but has a high rate of false negatives as > many functions are safe to call from non-GCing functions as long as > the arguments are correct. > (2) is difficult to implement, and would only trigger at runtime. > > So I say we should do (1) in preference to (2), but maybe we should do both. I don't think I understand how will we know which function says it never calls GC. And the FUNCTION_MAY_GC attribute, even if applied to the lowest-level functions that actually call maybe_gc, would be a maintenance headache because we do change this from time to time. So we'd need something that checks the attribute's accuracy at compile time, otherwise the attribute will bitrot. For the same reasons, I don't see how (2) can be done in practice.