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: Sun, 07 Mar 2021 16:04:42 +0200 Message-ID: <83a6rft5z9.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> <838s70wdb5.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15394"; 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 Sun Mar 07 15:06:02 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 1lIu2j-0003t5-T8 for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Mar 2021 15:06:01 +0100 Original-Received: from localhost ([::1]:51692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIu2i-0008Cz-WE for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Mar 2021 09:06:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIu1g-0007mK-Rv for emacs-devel@gnu.org; Sun, 07 Mar 2021 09:04:56 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57622) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIu1g-0006Ek-FK; Sun, 07 Mar 2021 09:04:56 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4391 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lIu1c-00006J-In; Sun, 07 Mar 2021 09:04:53 -0500 In-Reply-To: (message from Pip Cet on Sun, 7 Mar 2021 13:27:01 +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:266126 Archived-At: > From: Pip Cet > Date: Sun, 7 Mar 2021 13:27:01 +0000 > Cc: Stefan Monnier , emacs-devel@gnu.org > > > > 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 > > "Seems". If you have a computer fast enough and enough RAM to actually > compile emacs with -flto -fanalyzer -fdump-analyzer-json. I don't. > > > > 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. > > By tagging it in the source code? How do you know which functions to tag? > > For the same reasons, I don't see how (2) can be done in practice. > > Sorry, I don't understand. We'd have > > void > f (void) > { > DONT_CALL_GC (); > g(); > } > > void > g (void) > { > maybe_gc (); > } > > and that would throw a runtime error because maybe_gc checks the flag > set by DONT_CALL_GC. How do you know in which functions to add DONT_CALL_GC ? Or did you intend to add that to all the functions one by one, then removing them as needed, until you stop getting runtime exceptions?