From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: master d582356: * src/fns.c (Frandom): Handle bignum `limit`s Date: Sun, 7 Mar 2021 14:21:51 +0000 Message-ID: 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> <83a6rft5z9.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 07 15:23:35 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 1lIuJj-0002Ir-6O for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Mar 2021 15:23:35 +0100 Original-Received: from localhost ([::1]:60578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIuJi-0004S4-8f for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Mar 2021 09:23:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIuIj-00040d-7r for emacs-devel@gnu.org; Sun, 07 Mar 2021 09:22:33 -0500 Original-Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:38852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIuIf-0002zz-O1; Sun, 07 Mar 2021 09:22:32 -0500 Original-Received: by mail-ot1-x334.google.com with SMTP id a17so6689883oto.5; Sun, 07 Mar 2021 06:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yqjKTTyk1nlEIDCmlB0MU0/2cqbB3SEfS+kZetru614=; b=gv5n7EYICky6gHI77CyKUhAd5D8coJOb1GGrAjJL+bHSnHY7mvzzKyPTBSqOW+sdXl TETNhfdZsq6coAMjCWdT50L3yM0oaxfHNxmyUVR0k/MO4Nz63mLaDIGnQR5+UF7+8ooV 15hi7xq5EJ8Gj6UxTnCaYs+Qxabn/MH8slxbYkM+7QH6vxAnuNQW4UJ07Wodm7BwMAom tvZUXy/iOjsxbUzd0PHlnYhwiILEW1bKpSeTRwt9YpZO+sPW4qIrPOxov22qN9S9SEmg bff6wTpJbvkFlnKxja05Mtte5iMkBpghZid9w/e3IzSx4lwDyEgtYFd6CnNmRDfP5/Bk XesA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yqjKTTyk1nlEIDCmlB0MU0/2cqbB3SEfS+kZetru614=; b=S8w4dKMHolc/T0egR6ehXzSEBhCbTf43i9Oxj12lG8yL15ffUAbsdVKUtgP9N1bpOt iKm5SAe9unkxIBKcfdGm8vIC/U6zT4oztmhXgjlrKfjsG4IENj1lD0n+MbBp0f7L+WBV lp1MNMf39VMEQB1bAGe+XYQnMKJxB+Dm2Ucq80q913ONBEkZvrgD3El0bC6+fbzgjMKB IbqBP+3QB4EfHVJrviRGeynA7fpTQ3XGRo6AGBKtrJACPAnpuIVFRSLoi4hBK/clrvQ6 ysCF3Q/6Hvcf2/FBljxams+R0OFy7DCJ9+N+qNBRJlnkc5ZWZ1hNik7y+RQrcJxXapI0 WTpw== X-Gm-Message-State: AOAM531OynOJglC0ufvwKeiHgfP36TIlM4C4ZRYVAuiw7DzFB4ao+iZH ks4rmjroQdeJsPWUraBQMh5Ec17W0BZBCXdOqNJYmPrIzeU= X-Google-Smtp-Source: ABdhPJx6+bw8Q9G0udyaMpZK2PEo3E2c5cmu0OG7GzouWSSs+HvQSxmep2/Us/SJnnDuMnAvLBP3V8OgqME/RzLqU4k= X-Received: by 2002:a05:6830:1e51:: with SMTP id e17mr15951965otj.292.1615126947507; Sun, 07 Mar 2021 06:22:27 -0800 (PST) In-Reply-To: <83a6rft5z9.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=pipcet@gmail.com; helo=mail-ot1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:266127 Archived-At: On Sun, Mar 7, 2021 at 2:04 PM Eli Zaretskii wrote: > > 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? That's the part I wasn't volunteering for :-) We'd have to do that manually, but we wouldn't have to do it all at once. > > > 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 ? That's not something we can decide automatically, is it? But usually there will already be a comment in those functions explaining that they must not call GC, right? I think a runtime check is better than a comment, and either is much better than not documenting the assumption at all. > 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? No. That sounds painful. Pip