Subject: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373)

From: Pip Cet <[email-masked]>
Date: Fri, 3 Jan 2020 20:49:35 +0000

On Fri, Jan 3, 2020 at 8:13 PM Eli Zaretskii <[email-masked]> wrote:
> > From: Pip Cet <[email-masked]>
> > Date: Fri, 3 Jan 2020 18:53:46 +0000
> > Cc: Philipp Stephani <[email-masked]>, [email-masked], [email-masked]
> >
> > If I'm reading the test correctly, it depends on garbage-collect
> > actually collecting an unreferenced vector; since our GC's
> > conservative, that might not be working for you, if a word that
> > happens to look like a reference to the vector is still on the stack.
> > (Or it might be something else entirely, but I don't think the test as
> > it stands is correct).
>
> You are probably right, because I see the same failure on GNU/Linux,
> in an x86_64 unoptimized build:

I see it too. Fprogn keeps the value of the first sub-form alive while
evaluating the second one.

We can "fix" Fprogn to discard val early in unoptimized builds, and
that might make GC behavior slightly less surprising.

But it won't properly fix this test.
From 2c15533cccbcd1622db73362195e86f9c34531e6 Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Date: Fri, 3 Jan 2020 20:47:50 +0000
Subject: [PATCH] Make (progn (make-huge-vector) (garbage-collect)) behave as
 expected

---
 src/eval.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/eval.c b/src/eval.c
index 66752a397c..eb9018f66a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -457,6 +457,7 @@ DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0,
 
   while (CONSP (body))
     {
+      /* Don't keep VAL alive unnecessarily (bug#30373).  */
       val = Qnil;
       Lisp_Object form = XCAR (body);
       body = XCDR (body);
-- 
2.24.0