From unknown Fri Jun 20 07:12:05 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#30373 <30373@debbugs.gnu.org> To: bug#30373 <30373@debbugs.gnu.org> Subject: Status: Support finalizers for functions created in dynamic modules Reply-To: bug#30373 <30373@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:12:05 +0000 retitle 30373 Support finalizers for functions created in dynamic modules reassign 30373 emacs submitter 30373 Samir Jindel severity 30373 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 06 16:25:31 2018 Received: (at submit) by debbugs.gnu.org; 6 Feb 2018 21:25:31 +0000 Received: from localhost ([127.0.0.1]:60609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejAk7-0004eb-Di for submit@debbugs.gnu.org; Tue, 06 Feb 2018 16:25:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejAcZ-0004SI-6l for submit@debbugs.gnu.org; Tue, 06 Feb 2018 16:17:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejAcT-0000PE-1L for submit@debbugs.gnu.org; Tue, 06 Feb 2018 16:17:37 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,HTML_MESSAGE, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejAcS-0000P4-TR for submit@debbugs.gnu.org; Tue, 06 Feb 2018 16:17:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejAcR-00055f-Jt for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:17:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejAcQ-0000M6-6V for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:17:35 -0500 Received: from mail-ua0-x229.google.com ([2607:f8b0:400c:c08::229]:42969) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejAcP-0000L5-VE for bug-gnu-emacs@gnu.org; Tue, 06 Feb 2018 16:17:34 -0500 Received: by mail-ua0-x229.google.com with SMTP id 47so2142095uau.9 for ; Tue, 06 Feb 2018 13:17:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=AJMwOAM0/he8vrSzorPSBbQNJT776snTcdi+V8bgdsI=; b=iSfyZGpvYBahrjQmQdJeEuVSxH2Vv3zsJpqw5DHerYgPrxWhgTRCRTBehNHtAfJ80i K6PtMe3wIdHL8GqrhgfyG0HbiGEMbiYBZMiQ6FR4IebJs8/0be9LszGI9bT5Tryxxd3S VwPQnBicmPMqKhrWQhdH2jlKf0AexLrQVAMLq9M3NXEITTilAQ3JuQYyU9wjQQUUtc4w AhFzguGfeXAoDXHCfXFq/xplbM8sLL1gArX9ueTbMnoR9iCJ0kYlNKFFriPY2Bb1i0tk p+BjjweCkYtb+neryt1TvNWNkss9DK0u7kjjul9OREiIyeckxqL8IR8hL1vZ7zo/gKz/ kAfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=AJMwOAM0/he8vrSzorPSBbQNJT776snTcdi+V8bgdsI=; b=RxN5zokNVlp/didJqxchkNDJDHnAjBVKFwKvlPXFoFPms4KEUb9lmg70O6yE6qzYhm Iu0LKzCvjaW4m6dJcoxJWV3v92FgL1m+7DHmLz6jojzWGB3Vr5rFlO33L7hP2cmbPNJF QShc2e+9X/4ghXkk7TH4CeQMUFt8SDA+ciFvScPVmz0u4ojDFzL/AtUAYoHKVwoxv3RB 5h2+wBycnn/HlClx+fCb/bguig3WmOsTMnejXqHxF73tkzq4MPS8sYbcHrvaUu1IXV6x irQqbkMJ7BcVrGTed3TKyMjs8KLtb+Kb/LhJu5dBzWc0C0lYg84OKoVtOaD8A+NUZz4D g5TQ== X-Gm-Message-State: APf1xPDHdTm5JSzg97UNUf24ZPoOQhG55U6Qs+LIOZihOztKPGIfLZHv HiheEKownj5JFEeDBaQDIPf4sOsFPK8yEhRZnQI1wRCQDQw= X-Google-Smtp-Source: AH8x225tPvzXECJpMueGtOfNEcsHEFqR+E/bBoEqhuiSGNGi4bvlGaHcA8fIqA9vLdnCu7YN09JeGEv9z1doBr1+ffg= X-Received: by 10.176.83.203 with SMTP id l11mr3694993uaa.167.1517951852053; Tue, 06 Feb 2018 13:17:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.195.17 with HTTP; Tue, 6 Feb 2018 13:17:11 -0800 (PST) From: Samir Jindel Date: Tue, 6 Feb 2018 22:17:11 +0100 Message-ID: Subject: Support finalizers for functions created in dynamic modules To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="f403045e36c8ee3200056491b4ee" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 06 Feb 2018 16:25:30 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --f403045e36c8ee3200056491b4ee Content-Type: text/plain; charset="UTF-8" Hi, I'm very excited by the possibilities opened through the new dynamic module interface, "emacs-module.h". However, I have a concern about the API for creating Lisp functions bound to native functions: ```c emacs_value (*make_function) (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, emacs_value (*function) (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *) EMACS_NOEXCEPT, const char *documentation, void *data); ``` I presume the "data" pointer here is provided to enable native functions to work like closures, carrying additional, possibly dynamically allocated data. However, this functionality is limited by the absence of a finalization function pointer, like the "user_ptr" values have: ```c emacs_value (*make_user_ptr) (emacs_env *env, void (*fin) (void *) EMACS_NOEXCEPT, void *ptr); ``` Without the ability to provide a finalizer, a module can only safely make the "data" pointer to "make_function" point to static memory. Thanks, Samir Jindel --f403045e36c8ee3200056491b4ee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I'm very excited by the possibi= lities opened through the new dynamic module interface, "emacs-module.= h".

However, I have a concern about the API f= or creating Lisp functions bound to native functions:

<= div>```c
  emacs_value (*make_function) (emacs=
_env *env,                                                                 =
                                                                =20
        ptrdiff_t min_arity,                                               =
                                                                           =
                          =20
        ptrdiff_t max_arity,                                               =
                                                                           =
                          =20
        emacs_value (*function) (emacs_env *env,                           =
                                                                           =
                          =20
               ptrdiff_t nargs,                                            =
                                                                           =
                          =20
               emacs_value args[],                                         =
                                                                           =
                          =20
               void *)                                                     =
                                                                           =
                          =20
          EMACS_NOEXCEPT,                                                  =
                                                                           =
                          =20
        const char *documentation,                                         =
                                                                           =
                          =20
        void *data); 
```=C2=A0

I presume the= "data" pointer here is provided to enable native functions to wo= rk like closures,
carrying additional, possibly dynamically alloc= ated data. However, this functionality is limited by=C2=A0
the ab= sence of a finalization function pointer, like the "user_ptr" val= ues have:

```c
  emacs_=
value (*make_user_ptr) (emacs_env *env,                                    =
                                                                           =
                  =20
        void (*fin) (void *) EMACS_NOEXCEPT,                               =
                                                                           =
                          =20
        void *ptr);                                                        =
                                                                           =
                           
```

Without t= he ability to provide a finalizer, a module can only safely make the "= data" pointer to
"make_function" point to static m= emory.

Thanks,
Samir Jindel
--f403045e36c8ee3200056491b4ee-- From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 23 15:41:35 2019 Received: (at 30373) by debbugs.gnu.org; 23 Dec 2019 20:41:35 +0000 Received: from localhost ([127.0.0.1]:51718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ijUWE-0001Rp-Vi for submit@debbugs.gnu.org; Mon, 23 Dec 2019 15:41:35 -0500 Received: from mail-ot1-f41.google.com ([209.85.210.41]:36697) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ijUWD-0001Rd-Hs for 30373@debbugs.gnu.org; Mon, 23 Dec 2019 15:41:34 -0500 Received: by mail-ot1-f41.google.com with SMTP id 19so11065473otz.3 for <30373@debbugs.gnu.org>; Mon, 23 Dec 2019 12:41:33 -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=nywWsBE52hEXtyOM6YctpShhOR208OjtyPzdUcrIlLE=; b=Ob2iykpC6A9poMyJpJUHAwySpSEFrImKFPM6cqIojcoe/UzoZ2axhX3Q4hV5F2bX3g LpmWnfTrgrL9+eDhGQTARQzdF47HeYTebJezO2a/cZA/+o8J7bVjSxd8Jw5EjOK/Bq4I CXju1JlqUJtVeKIXIQkvOFGI3/KAD7Qlhthh1JzT1A0t+Rs//N0yflXLHPTkk2TPyiAJ cqumtrPS9tK6//tD1Y67tzl5rTM/xQ5bKZAbalkze/dMUlioNR2lmCC5Q6v2hX1Zw0ig 8bdAwLWtl5izO6L2AyqxxjZyF2A0ke3PM366n7Yi2ubki7zwlB23kJ9Lji2+MtJaOjrL VEdg== 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=nywWsBE52hEXtyOM6YctpShhOR208OjtyPzdUcrIlLE=; b=Y5jx9BajRXMVfQ/+BqG+UqOEsSFbiJP1ZVtnod0fmrzlzE07FSAeGcUc2tklpV8x3L 79FlaXT8kmE6r1t3sY97MvO40wKOE/fQGO7jxMrcyyDTlDjYZPMKX/puZ2WSGs3YI+2h 0EfB8Nophr4TRJ2nTwCx1ZqfOSnOCYZXxI/k9XwbYgXRkzENcF6ukgecv20nZeMCikAW uyctOD5XPSWWN80bcuL9i41BerYhPP2RUfvRcZXC5uMVtB07jol1JGcPkyN9JBqvVhxh tTgeuvkxe7qmC48SRFzKAWmiEuspvbrOGq6/E7c9OPDBzjYTTLP+D8cL9wUHiqVG3kzT AUSw== X-Gm-Message-State: APjAAAULledyceBN9Sc1FJSeeYTthfVYJPAEg1sHM7YjYWKexFptGTSx 3X7DLttMGznhzu0zZFTuYsXB7BRHoRaP1eEBojE= X-Google-Smtp-Source: APXvYqy9adkQCL8PN/2AegX2Yzg3mmocp9lYkJjfqfMq1spKBPDeusq6Cc/1A7FA/pHFwvEG+/Xzp/DBL84eoFQ+tCM= X-Received: by 2002:a9d:4b05:: with SMTP id q5mr22081046otf.174.1577133687651; Mon, 23 Dec 2019 12:41:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Philipp Stephani Date: Mon, 23 Dec 2019 21:41:16 +0100 Message-ID: Subject: Re: bug#30373: Support finalizers for functions created in dynamic modules To: Samir Jindel Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 30373 Cc: 30373@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Am Di., 6. Feb. 2018 um 22:43 Uhr schrieb Samir Jindel : > > Hi, > > I'm very excited by the possibilities opened through the new dynamic module interface, "emacs-module.h". > > However, I have a concern about the API for creating Lisp functions bound to native functions: > > ```c > > emacs_value (*make_function) (emacs_env *env, > ptrdiff_t min_arity, > ptrdiff_t max_arity, > emacs_value (*function) (emacs_env *env, > ptrdiff_t nargs, > emacs_value args[], > void *) > EMACS_NOEXCEPT, > const char *documentation, > void *data); > > ``` > > I presume the "data" pointer here is provided to enable native functions to work like closures, > carrying additional, possibly dynamically allocated data. However, this functionality is limited by > the absence of a finalization function pointer, like the "user_ptr" values have: > > ```c > > emacs_value (*make_user_ptr) (emacs_env *env, > void (*fin) (void *) EMACS_NOEXCEPT, > void *ptr); > > ``` > > Without the ability to provide a finalizer, a module can only safely make the "data" pointer to > "make_function" point to static memory. > Sorry for not responding for so long. I think this makes a lot of sense, and we should definitely introduce function finalizers. I can think of three possible interface choices for this: 1. Add a make_finalizable_function environment function that is like make_function but accepts a finalizer. 2. Add a set_function_finalizer(env, emacs_value, void(*)(void)) environment function. 3. Allow set_user_finalizer to also set function finalizers. I'd lean away from (1) since it makes an already complex interface even more complex. (2) seems cleanest, but requires adding a new environment function. (3) would require the least amount of changes, but it would also be slightly less clean than (2), and would break backwards compatibility in a subtle way (users relying on set_user_finalizer raising an error if a non-user-pointer object is passed would break). Overall, I'd slightly lean towards (2). Other opinions? From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 25 19:04:43 2019 Received: (at 30373) by debbugs.gnu.org; 26 Dec 2019 00:04:43 +0000 Received: from localhost ([127.0.0.1]:54779 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ikGdv-0000Zn-8V for submit@debbugs.gnu.org; Wed, 25 Dec 2019 19:04:43 -0500 Received: from mail-wr1-f47.google.com ([209.85.221.47]:40642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ikGdt-0000ZO-4O for 30373@debbugs.gnu.org; Wed, 25 Dec 2019 19:04:42 -0500 Received: by mail-wr1-f47.google.com with SMTP id c14so22491905wrn.7 for <30373@debbugs.gnu.org>; Wed, 25 Dec 2019 16:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BLxZKhsEkK3AP1HvwW++QwGBmn69KVoVYNqMFfWrphk=; b=jIgqjisYWKBKpnZGYlpblZTbClNuyYG6AziPjLQySmTMhcTOW3w11KgEncRn0goLge /8BtuX6a67XHTlYytUERd8SH2ck6axlyKr5ggo32+NFvIbR8hpymcqT3skpPlI2UQi0f ECBvxkIUkSBR0xoVUglvH4SXmRUHvnTLrj/O3RNIXkW+KvIlCmwsQikqvLzprxLMGlPR +zz6Q7qD91ytuvlpxju6Qxlgij7x6g0FlEoaUSlu2qI6gTeUzSgzFoA4hejnvzru83/a dQRF3zBxKGCWJXmWe9P0K0aq1oM++QTfniekS0EePWv4QtqEo4MkD+gL9DnsbVO5Tv+I HCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BLxZKhsEkK3AP1HvwW++QwGBmn69KVoVYNqMFfWrphk=; b=JesyfLHW/ofHLRsVcljHNcHR9bdGXlnJRB3wgc//Xb19PLHgu0nHYnWgdhgr73RAjg MVT0Z0xxwYt9A9rHQvhfgj0WR5vLjRNbHwFijLyxraiFe3V1rngx1WFsYALVm9xw+IJK 6OfhjGw9Nryg5lLAmPPkPliAxy6W9ckYygadBV6aeDVQoe+lbGYPEXRhAgTrIHqOrzpx 9aIC0sflPWN4QM8hdb8KQiPY6V1+9xU2Qv0X+8EZzIrUrPvNEZaVkEwXFxrUX53bmDZi Rv0wK5a7qAMd9mG/VfOR7a+UpnW+Xz1GDd9y0qggYqvFnXgVyf3xMvbAbh4Z6PU03H80 y1Dg== X-Gm-Message-State: APjAAAWU7sqzGdNh0hUugaPIQujyhg/XiL7zgia97cqhXM2dQU29o5Kb 3ife6G0OY/RkFM9Ip0mrnVzVos7dHa4= X-Google-Smtp-Source: APXvYqxpgYRwYvG+tRp3wxHZQzDs6ewzBbk03qOGhE64na6LFLnVYvzD+WUzCOspfXJpgFOazpfTJg== X-Received: by 2002:a5d:5452:: with SMTP id w18mr28694010wrv.333.1577318674535; Wed, 25 Dec 2019 16:04:34 -0800 (PST) Received: from p.fritz.box (p57AAFE71.dip0.t-ipconnect.de. [87.170.254.113]) by smtp.gmail.com with ESMTPSA id p15sm6848696wma.40.2019.12.25.16.04.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Dec 2019 16:04:33 -0800 (PST) From: Philipp Stephani X-Google-Original-From: Philipp Stephani To: 30373@debbugs.gnu.org, sjindel@google.com Subject: [PATCH] Implement finalizers for module functions (Bug#30373) Date: Thu, 26 Dec 2019 01:04:17 +0100 Message-Id: <20191226000417.69183-1-phst@google.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 30373 Cc: Philipp Stephani X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) * src/module-env-28.h: Add new module environment functions to module environment for Emacs 28. * src/emacs-module.c (CHECK_MODULE_FUNCTION): New function. (struct Lisp_Module_Function): Add finalizer data member. (module_make_function): Initialize finalizer. (module_get_function_finalizer) (module_set_function_finalizer): New module environment functions. (module_finalize_function): New function. (initialize_environment): Initialize new environment functions. * src/alloc.c (cleanup_vector): Call potential module function finalizer during garbage collection. * test/data/emacs-module/mod-test.c (signal_error): New helper function. (memory_full): Use it. (finalizer): New example function finalizer. (Fmod_test_make_function_with_finalizer) (Fmod_test_function_finalizer_calls): New test module functions. (emacs_module_init): Define them. * test/src/emacs-module-tests.el (module/function-finalizer): New unit test. --- src/alloc.c | 6 ++++ src/emacs-module.c | 45 +++++++++++++++++++++++++--- src/lisp.h | 1 + src/module-env-28.h | 8 +++++ test/data/emacs-module/mod-test.c | 49 +++++++++++++++++++++++++++++-- test/src/emacs-module-tests.el | 8 +++++ 6 files changed, 111 insertions(+), 6 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 6a17bedc75..94c1433124 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3023,6 +3023,12 @@ cleanup_vector (struct Lisp_Vector *vector) if (uptr->finalizer) uptr->finalizer (uptr->p); } + else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_MODULE_FUNCTION)) + { + ATTRIBUTE_MAY_ALIAS struct Lisp_Module_Function *function + = (struct Lisp_Module_Function *) vector; + module_finalize_function (function); + } } /* Reclaim space used by unmarked vectors. */ diff --git a/src/emacs-module.c b/src/emacs-module.c index ff1a05450c..9ec25d57af 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -122,10 +122,11 @@ Copyright (C) 2015-2019 Free Software Foundation, Inc. /* Function prototype for the module init function. */ typedef int (*emacs_init_function) (struct emacs_runtime *); -/* Function prototype for module user-pointer finalizers. These - should not throw C++ exceptions, so emacs-module.h declares the - corresponding interfaces with EMACS_NOEXCEPT. There is only C code - in this module, though, so this constraint is not enforced here. */ +/* Function prototype for module user-pointer and function finalizers. + These should not throw C++ exceptions, so emacs-module.h declares + the corresponding interfaces with EMACS_NOEXCEPT. There is only C + code in this module, though, so this constraint is not enforced + here. */ typedef void (*emacs_finalizer) (void *); @@ -332,6 +333,12 @@ #define MODULE_FUNCTION_BEGIN(error_retval) \ MODULE_FUNCTION_BEGIN_NO_CATCH (error_retval); \ MODULE_HANDLE_NONLOCAL_EXIT (error_retval) +static void +CHECK_MODULE_FUNCTION (Lisp_Object obj) +{ + CHECK_TYPE (MODULE_FUNCTIONP (obj), Qmodule_function_p, obj); +} + static void CHECK_USER_PTR (Lisp_Object obj) { @@ -488,6 +495,7 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value) ptrdiff_t min_arity, max_arity; emacs_subr subr; void *data; + emacs_finalizer finalizer; } GCALIGNED_STRUCT; static struct Lisp_Module_Function * @@ -521,6 +529,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, function->max_arity = max_arity; function->subr = func; function->data = data; + function->finalizer = NULL; if (docstring) function->documentation = build_string_from_utf8 (docstring); @@ -532,6 +541,32 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, return lisp_to_value (env, result); } +static emacs_finalizer +module_get_function_finalizer (emacs_env *env, emacs_value arg) +{ + MODULE_FUNCTION_BEGIN (NULL); + Lisp_Object lisp = value_to_lisp (arg); + CHECK_MODULE_FUNCTION (lisp); + return XMODULE_FUNCTION (lisp)->finalizer; +} + +static void +module_set_function_finalizer (emacs_env *env, emacs_value arg, + emacs_finalizer fin) +{ + MODULE_FUNCTION_BEGIN (); + Lisp_Object lisp = value_to_lisp (arg); + CHECK_MODULE_FUNCTION (lisp); + XMODULE_FUNCTION (lisp)->finalizer = fin; +} + +void +module_finalize_function (const struct Lisp_Module_Function *func) +{ + if (func->finalizer != NULL) + func->finalizer (func->data); +} + static emacs_value module_funcall (emacs_env *env, emacs_value func, ptrdiff_t nargs, emacs_value *args) @@ -1339,6 +1374,8 @@ initialize_environment (emacs_env *env, struct emacs_env_private *priv) env->make_time = module_make_time; env->extract_big_integer = module_extract_big_integer; env->make_big_integer = module_make_big_integer; + env->get_function_finalizer = module_get_function_finalizer; + env->set_function_finalizer = module_set_function_finalizer; Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments); return env; } diff --git a/src/lisp.h b/src/lisp.h index e0ae2c4262..1bd78284d7 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4245,6 +4245,7 @@ XMODULE_FUNCTION (Lisp_Object o) (struct Lisp_Module_Function const *); extern module_funcptr module_function_address (struct Lisp_Module_Function const *); +extern void module_finalize_function (const struct Lisp_Module_Function *); extern void mark_modules (void); extern void init_module_assertions (bool); extern void syms_of_module (void); diff --git a/src/module-env-28.h b/src/module-env-28.h index dec8704edd..a2479a8f74 100644 --- a/src/module-env-28.h +++ b/src/module-env-28.h @@ -1,3 +1,11 @@ /* Add module environment functions newly added in Emacs 28 here. Before Emacs 28 is released, remove this comment and start module-env-29.h on the master branch. */ + + void (*(*EMACS_ATTRIBUTE_NONNULL (1) + get_function_finalizer) (emacs_env *env, + emacs_value arg)) (void *) EMACS_NOEXCEPT; + + void (*set_function_finalizer) (emacs_env *env, emacs_value arg, + void (*fin) (void *) EMACS_NOEXCEPT) + EMACS_ATTRIBUTE_NONNULL (1); diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c index 5addf61147..6a70a7ab57 100644 --- a/test/data/emacs-module/mod-test.c +++ b/test/data/emacs-module/mod-test.c @@ -373,15 +373,20 @@ Fmod_test_add_nanosecond (emacs_env *env, ptrdiff_t nargs, emacs_value *args, } static void -memory_full (emacs_env *env) +signal_error (emacs_env *env, const char *message) { - const char *message = "Memory exhausted"; emacs_value data = env->make_string (env, message, strlen (message)); env->non_local_exit_signal (env, env->intern (env, "error"), env->funcall (env, env->intern (env, "list"), 1, &data)); } +static void +memory_full (emacs_env *env) +{ + signal_error (env, "Memory exhausted"); +} + enum { max_count = ((SIZE_MAX < PTRDIFF_MAX ? SIZE_MAX : PTRDIFF_MAX) @@ -490,6 +495,42 @@ Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args, return result; } +static int function_data; +static int finalizer_calls_with_correct_data; +static int finalizer_calls_with_incorrect_data; + +static void +finalizer (void *data) +{ + if (data == &function_data) + ++finalizer_calls_with_correct_data; + else + ++finalizer_calls_with_incorrect_data; +} + +static emacs_value +Fmod_test_make_function_with_finalizer (emacs_env *env, ptrdiff_t nargs, + emacs_value *args, void *data) +{ + emacs_value fun + = env->make_function (env, 2, 2, Fmod_test_sum, NULL, &function_data); + env->set_function_finalizer (env, fun, finalizer); + if (env->get_function_finalizer (env, fun) != finalizer) + signal_error (env, "Invalid finalizer"); + return fun; +} + +static emacs_value +Fmod_test_function_finalizer_calls (emacs_env *env, ptrdiff_t nargs, + emacs_value *args, void *data) +{ + emacs_value Flist = env->intern (env, "list"); + emacs_value list_args[] + = {env->make_integer (env, finalizer_calls_with_correct_data), + env->make_integer (env, finalizer_calls_with_incorrect_data)}; + return env->funcall (env, Flist, 2, list_args); +} + /* Lisp utilities for easier readability (simple wrappers). */ /* Provide FEATURE to Emacs. */ @@ -566,6 +607,10 @@ #define DEFUN(lsym, csym, amin, amax, doc, data) \ DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, NULL); DEFUN ("mod-test-nanoseconds", Fmod_test_nanoseconds, 1, 1, NULL, NULL); DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL); + DEFUN ("mod-test-make-function-with-finalizer", + Fmod_test_make_function_with_finalizer, 0, 0, NULL, NULL); + DEFUN ("mod-test-function-finalizer-calls", + Fmod_test_function_finalizer_calls, 0, 0, NULL, NULL); #undef DEFUN diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el index 322500ff60..d9a57aecf6 100644 --- a/test/src/emacs-module-tests.el +++ b/test/src/emacs-module-tests.el @@ -402,4 +402,12 @@ module-darwin-secondary-suffix (load so nil nil :nosuffix :must-suffix) (delete-file so)))) +(ert-deftest module/function-finalizer () + (mod-test-make-function-with-finalizer) + (let* ((previous-calls (mod-test-function-finalizer-calls)) + (expected-calls (copy-sequence previous-calls))) + (cl-incf (car expected-calls)) + (garbage-collect) + (should (equal (mod-test-function-finalizer-calls) expected-calls)))) + ;;; emacs-module-tests.el ends here -- 2.21.0 (Apple Git-122.2) From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 03 13:35:11 2020 Received: (at 30373-done) by debbugs.gnu.org; 3 Jan 2020 18:35:11 +0000 Received: from localhost ([127.0.0.1]:41435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inRmw-0003B7-KR for submit@debbugs.gnu.org; Fri, 03 Jan 2020 13:35:11 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:34646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inRmu-0003Ar-Px for 30373-done@debbugs.gnu.org; Fri, 03 Jan 2020 13:35:09 -0500 Received: by mail-ot1-f67.google.com with SMTP id a15so62185423otf.1 for <30373-done@debbugs.gnu.org>; Fri, 03 Jan 2020 10:35:08 -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=WmB4kXUoO7ArDez8W9BaonsXuq07+HZImKw6kHlddDY=; b=kTMvr2F/Q08ASz2gEbTlskJxpeNW45Opgpf/WdMFyEtjeY4OkX/4aC9cK2UTGC5aWw k87d7oxA5zM0ILdsuYrpLFmUITeXY7ir/Us0cKRgPlBd5pKio4Ozyrq/77XQg264ztEm pAHnvza5f1PuVl3UPCfxROA7RLJmxq51iSfXVGhXYk/nG3FBDJoIJzPa6LiqluyPe1k6 B4bYwEgQHQz4SqtDPfGk7mscDBPzheMeeikp8zcPbjmMRjvfpO79OuqKXvD0q5HHJmw1 pX941UUrnjJBilQyysUvoyI/CwugfumBmyFhHu8cgj4YIXJajzLzy+arspd+/5kmuI8Y JOXQ== 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=WmB4kXUoO7ArDez8W9BaonsXuq07+HZImKw6kHlddDY=; b=nGr9nz5OFqPVhs/Es/FbVnsB6TsgDAFEF/2h0Cfu1jipdBZnH/Kk8smowM7+T6t0vZ PxxL5qRL4tqCCWvqPcGjMm5PNma64c0sh42MWDre/ZHozvVXatakM5clOWnQMbJ1y208 jw2Y9htQpNOezGhEfWwnWfYpFBLxJ+Z0U/2m0ipgZJ7i9VGfnfSvB8AtBmbLRbZyHiPL eYuABbMXqqyIofyOzu62CXVRODtm7YVB4r87e6xHWPBTQxiS4aO0Trd1wPsCCtx8SUTa Yccn6MyJI/55QLQXgbADHxChrGlVnOg1uyDKPS6QMX8Nx+L6C92f2uPfll7e7Y4KifVV biGA== X-Gm-Message-State: APjAAAU3tg9/L3vWnxyegD4TEN0WoHkuQ3UxGzW8Y0IfZQKQcFt57nmn 3A+LgL8kmm1tBWMbP5VWhJTNg3aThfvqdJIP+eWNOpNY9xM= X-Google-Smtp-Source: APXvYqzamxRTmNflJLNfrOHr+LSUEXFweIimelm2GMCIZfMdErl2LbLRpjLStgRf8S/xJ0fitk3yN4y8h4kik0cL0q4= X-Received: by 2002:a9d:4b05:: with SMTP id q5mr84103223otf.174.1578076502831; Fri, 03 Jan 2020 10:35:02 -0800 (PST) MIME-Version: 1.0 References: <20191226000417.69183-1-phst@google.com> In-Reply-To: <20191226000417.69183-1-phst@google.com> From: Philipp Stephani Date: Fri, 3 Jan 2020 19:34:51 +0100 Message-ID: Subject: Re: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373) To: 30373-done@debbugs.gnu.org, Samir Jindel Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 30373-done Cc: Philipp Stephani X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Since there were no objections, I've installed this patch (plus some documentation) as commit 48ffef5ef4 into master. Am Do., 26. Dez. 2019 um 01:05 Uhr schrieb Philipp Stephani : > > * src/module-env-28.h: Add new module environment functions to > module environment for Emacs 28. > > * src/emacs-module.c (CHECK_MODULE_FUNCTION): New function. > (struct Lisp_Module_Function): Add finalizer data member. > (module_make_function): Initialize finalizer. > (module_get_function_finalizer) > (module_set_function_finalizer): New module environment functions. > (module_finalize_function): New function. > (initialize_environment): Initialize new environment functions. > > * src/alloc.c (cleanup_vector): Call potential module function > finalizer during garbage collection. > > * test/data/emacs-module/mod-test.c (signal_error): New helper > function. > (memory_full): Use it. > (finalizer): New example function finalizer. > (Fmod_test_make_function_with_finalizer) > (Fmod_test_function_finalizer_calls): New test module functions. > (emacs_module_init): Define them. > > * test/src/emacs-module-tests.el (module/function-finalizer): New unit > test. > --- > src/alloc.c | 6 ++++ > src/emacs-module.c | 45 +++++++++++++++++++++++++--- > src/lisp.h | 1 + > src/module-env-28.h | 8 +++++ > test/data/emacs-module/mod-test.c | 49 +++++++++++++++++++++++++++++-- > test/src/emacs-module-tests.el | 8 +++++ > 6 files changed, 111 insertions(+), 6 deletions(-) > > diff --git a/src/alloc.c b/src/alloc.c > index 6a17bedc75..94c1433124 100644 > --- a/src/alloc.c > +++ b/src/alloc.c > @@ -3023,6 +3023,12 @@ cleanup_vector (struct Lisp_Vector *vector) > if (uptr->finalizer) > uptr->finalizer (uptr->p); > } > + else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_MODULE_FUNCTION)) > + { > + ATTRIBUTE_MAY_ALIAS struct Lisp_Module_Function *function > + = (struct Lisp_Module_Function *) vector; > + module_finalize_function (function); > + } > } > > /* Reclaim space used by unmarked vectors. */ > diff --git a/src/emacs-module.c b/src/emacs-module.c > index ff1a05450c..9ec25d57af 100644 > --- a/src/emacs-module.c > +++ b/src/emacs-module.c > @@ -122,10 +122,11 @@ Copyright (C) 2015-2019 Free Software Foundation, Inc. > /* Function prototype for the module init function. */ > typedef int (*emacs_init_function) (struct emacs_runtime *); > > -/* Function prototype for module user-pointer finalizers. These > - should not throw C++ exceptions, so emacs-module.h declares the > - corresponding interfaces with EMACS_NOEXCEPT. There is only C code > - in this module, though, so this constraint is not enforced here. */ > +/* Function prototype for module user-pointer and function finalizers. > + These should not throw C++ exceptions, so emacs-module.h declares > + the corresponding interfaces with EMACS_NOEXCEPT. There is only C > + code in this module, though, so this constraint is not enforced > + here. */ > typedef void (*emacs_finalizer) (void *); > > > @@ -332,6 +333,12 @@ #define MODULE_FUNCTION_BEGIN(error_retval) \ > MODULE_FUNCTION_BEGIN_NO_CATCH (error_retval); \ > MODULE_HANDLE_NONLOCAL_EXIT (error_retval) > > +static void > +CHECK_MODULE_FUNCTION (Lisp_Object obj) > +{ > + CHECK_TYPE (MODULE_FUNCTIONP (obj), Qmodule_function_p, obj); > +} > + > static void > CHECK_USER_PTR (Lisp_Object obj) > { > @@ -488,6 +495,7 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value) > ptrdiff_t min_arity, max_arity; > emacs_subr subr; > void *data; > + emacs_finalizer finalizer; > } GCALIGNED_STRUCT; > > static struct Lisp_Module_Function * > @@ -521,6 +529,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, > function->max_arity = max_arity; > function->subr = func; > function->data = data; > + function->finalizer = NULL; > > if (docstring) > function->documentation = build_string_from_utf8 (docstring); > @@ -532,6 +541,32 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, > return lisp_to_value (env, result); > } > > +static emacs_finalizer > +module_get_function_finalizer (emacs_env *env, emacs_value arg) > +{ > + MODULE_FUNCTION_BEGIN (NULL); > + Lisp_Object lisp = value_to_lisp (arg); > + CHECK_MODULE_FUNCTION (lisp); > + return XMODULE_FUNCTION (lisp)->finalizer; > +} > + > +static void > +module_set_function_finalizer (emacs_env *env, emacs_value arg, > + emacs_finalizer fin) > +{ > + MODULE_FUNCTION_BEGIN (); > + Lisp_Object lisp = value_to_lisp (arg); > + CHECK_MODULE_FUNCTION (lisp); > + XMODULE_FUNCTION (lisp)->finalizer = fin; > +} > + > +void > +module_finalize_function (const struct Lisp_Module_Function *func) > +{ > + if (func->finalizer != NULL) > + func->finalizer (func->data); > +} > + > static emacs_value > module_funcall (emacs_env *env, emacs_value func, ptrdiff_t nargs, > emacs_value *args) > @@ -1339,6 +1374,8 @@ initialize_environment (emacs_env *env, struct emacs_env_private *priv) > env->make_time = module_make_time; > env->extract_big_integer = module_extract_big_integer; > env->make_big_integer = module_make_big_integer; > + env->get_function_finalizer = module_get_function_finalizer; > + env->set_function_finalizer = module_set_function_finalizer; > Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments); > return env; > } > diff --git a/src/lisp.h b/src/lisp.h > index e0ae2c4262..1bd78284d7 100644 > --- a/src/lisp.h > +++ b/src/lisp.h > @@ -4245,6 +4245,7 @@ XMODULE_FUNCTION (Lisp_Object o) > (struct Lisp_Module_Function const *); > extern module_funcptr module_function_address > (struct Lisp_Module_Function const *); > +extern void module_finalize_function (const struct Lisp_Module_Function *); > extern void mark_modules (void); > extern void init_module_assertions (bool); > extern void syms_of_module (void); > diff --git a/src/module-env-28.h b/src/module-env-28.h > index dec8704edd..a2479a8f74 100644 > --- a/src/module-env-28.h > +++ b/src/module-env-28.h > @@ -1,3 +1,11 @@ > /* Add module environment functions newly added in Emacs 28 here. > Before Emacs 28 is released, remove this comment and start > module-env-29.h on the master branch. */ > + > + void (*(*EMACS_ATTRIBUTE_NONNULL (1) > + get_function_finalizer) (emacs_env *env, > + emacs_value arg)) (void *) EMACS_NOEXCEPT; > + > + void (*set_function_finalizer) (emacs_env *env, emacs_value arg, > + void (*fin) (void *) EMACS_NOEXCEPT) > + EMACS_ATTRIBUTE_NONNULL (1); > diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c > index 5addf61147..6a70a7ab57 100644 > --- a/test/data/emacs-module/mod-test.c > +++ b/test/data/emacs-module/mod-test.c > @@ -373,15 +373,20 @@ Fmod_test_add_nanosecond (emacs_env *env, ptrdiff_t nargs, emacs_value *args, > } > > static void > -memory_full (emacs_env *env) > +signal_error (emacs_env *env, const char *message) > { > - const char *message = "Memory exhausted"; > emacs_value data = env->make_string (env, message, strlen (message)); > env->non_local_exit_signal (env, env->intern (env, "error"), > env->funcall (env, env->intern (env, "list"), 1, > &data)); > } > > +static void > +memory_full (emacs_env *env) > +{ > + signal_error (env, "Memory exhausted"); > +} > + > enum > { > max_count = ((SIZE_MAX < PTRDIFF_MAX ? SIZE_MAX : PTRDIFF_MAX) > @@ -490,6 +495,42 @@ Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args, > return result; > } > > +static int function_data; > +static int finalizer_calls_with_correct_data; > +static int finalizer_calls_with_incorrect_data; > + > +static void > +finalizer (void *data) > +{ > + if (data == &function_data) > + ++finalizer_calls_with_correct_data; > + else > + ++finalizer_calls_with_incorrect_data; > +} > + > +static emacs_value > +Fmod_test_make_function_with_finalizer (emacs_env *env, ptrdiff_t nargs, > + emacs_value *args, void *data) > +{ > + emacs_value fun > + = env->make_function (env, 2, 2, Fmod_test_sum, NULL, &function_data); > + env->set_function_finalizer (env, fun, finalizer); > + if (env->get_function_finalizer (env, fun) != finalizer) > + signal_error (env, "Invalid finalizer"); > + return fun; > +} > + > +static emacs_value > +Fmod_test_function_finalizer_calls (emacs_env *env, ptrdiff_t nargs, > + emacs_value *args, void *data) > +{ > + emacs_value Flist = env->intern (env, "list"); > + emacs_value list_args[] > + = {env->make_integer (env, finalizer_calls_with_correct_data), > + env->make_integer (env, finalizer_calls_with_incorrect_data)}; > + return env->funcall (env, Flist, 2, list_args); > +} > + > /* Lisp utilities for easier readability (simple wrappers). */ > > /* Provide FEATURE to Emacs. */ > @@ -566,6 +607,10 @@ #define DEFUN(lsym, csym, amin, amax, doc, data) \ > DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, NULL); > DEFUN ("mod-test-nanoseconds", Fmod_test_nanoseconds, 1, 1, NULL, NULL); > DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL); > + DEFUN ("mod-test-make-function-with-finalizer", > + Fmod_test_make_function_with_finalizer, 0, 0, NULL, NULL); > + DEFUN ("mod-test-function-finalizer-calls", > + Fmod_test_function_finalizer_calls, 0, 0, NULL, NULL); > > #undef DEFUN > > diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el > index 322500ff60..d9a57aecf6 100644 > --- a/test/src/emacs-module-tests.el > +++ b/test/src/emacs-module-tests.el > @@ -402,4 +402,12 @@ module-darwin-secondary-suffix > (load so nil nil :nosuffix :must-suffix) > (delete-file so)))) > > +(ert-deftest module/function-finalizer () > + (mod-test-make-function-with-finalizer) > + (let* ((previous-calls (mod-test-function-finalizer-calls)) > + (expected-calls (copy-sequence previous-calls))) > + (cl-incf (car expected-calls)) > + (garbage-collect) > + (should (equal (mod-test-function-finalizer-calls) expected-calls)))) > + > ;;; emacs-module-tests.el ends here > -- > 2.21.0 (Apple Git-122.2) > > > > From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 03 13:44:34 2020 Received: (at 30373) by debbugs.gnu.org; 3 Jan 2020 18:44:34 +0000 Received: from localhost ([127.0.0.1]:41442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inRw1-0003Nl-Vk for submit@debbugs.gnu.org; Fri, 03 Jan 2020 13:44:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inRw0-0003NZ-Rg for 30373@debbugs.gnu.org; Fri, 03 Jan 2020 13:44:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1inRvv-0005EC-JO; Fri, 03 Jan 2020 13:44:27 -0500 Received: from [176.228.60.248] (port=2402 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1inRvu-0008CB-SX; Fri, 03 Jan 2020 13:44:27 -0500 Date: Fri, 03 Jan 2020 20:44:26 +0200 Message-Id: <83v9psgz1x.fsf@gnu.org> From: Eli Zaretskii To: Philipp Stephani In-reply-to: (message from Philipp Stephani on Fri, 3 Jan 2020 19:34:51 +0100) Subject: Re: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373) References: <20191226000417.69183-1-phst@google.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: 30373 Cc: 30373@debbugs.gnu.org, sjindel@google.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) > From: Philipp Stephani > Date: Fri, 3 Jan 2020 19:34:51 +0100 > Cc: Philipp Stephani > > Since there were no objections, I've installed this patch (plus some > documentation) as commit 48ffef5ef4 into master. Thanks. The new test fails for me on MS-Windows: Test module/function-finalizer backtrace: signal(ert-test-failed (((should (equal (mod-test-function-finalizer ert-fail(((should (equal (mod-test-function-finalizer-calls) expecte (if (unwind-protect (setq value-370 (apply fn-368 args-369)) (setq f (let (form-description-372) (if (unwind-protect (setq value-370 (app (let ((value-370 'ert-form-evaluation-aborted-371)) (let (form-descr (let* ((fn-368 #'equal) (args-369 (condition-case err (let ((signal- (let* ((previous-calls (mod-test-function-finalizer-calls)) (expecte (closure (t) nil (mod-test-make-function-with-finalizer) (let* ((pre ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name module/function-finalizer :documentat ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type ert-run-tests-batch((not (tag :unstable))) ert-run-tests-batch-and-exit((not (tag :unstable))) eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t) command-line-1((#("-L" 0 2 (charset cp862)) #(";." 0 2 (charset cp86 command-line() normal-top-level() Test module/function-finalizer condition: (ert-test-failed ((should (equal (mod-test-function-finalizer-calls) expected-calls)) :form (equal (0 0) (1 0)) :value nil :explanation (list-elt 0 (different-atoms (0 "#x0" "?") (1 "#x1" "?"))))) FAILED 26/27 module/function-finalizer (0.109375 sec) From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 03 13:54:32 2020 Received: (at 30373) by debbugs.gnu.org; 3 Jan 2020 18:54:32 +0000 Received: from localhost ([127.0.0.1]:41446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inS5f-0003bV-TU for submit@debbugs.gnu.org; Fri, 03 Jan 2020 13:54:32 -0500 Received: from mail-ot1-f51.google.com ([209.85.210.51]:38894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inS5d-0003bI-V1 for 30373@debbugs.gnu.org; Fri, 03 Jan 2020 13:54:30 -0500 Received: by mail-ot1-f51.google.com with SMTP id d7so57825487otf.5 for <30373@debbugs.gnu.org>; Fri, 03 Jan 2020 10:54:29 -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=yzpNMlr06XxHf6jJjFPNP3pG8pj9pp/dvHOGS88XDPo=; b=A0HPBPutzgOfkUNZPVREgPa0GoCEmWzI1QZQ5ZXl9HY7GdtPLlmBO4hFoACUcXg34b BqH7jLnr61nPMjyYsX03oQxBHmTI6Hyc8lE+iTxA0jiK9I6EdWZL2z2/Ng9xRGHhmTSl zvInvsvHlPlM5aSlek40Y4Efk9Tbcwv+I9saasPtYcjvP662BuRwupUH1ZKyhR0mkVXN R+0i9kLymqnHwlsrHD0fI+zxBHyyK9pMT97+kPfxkEgYC9KoEUgH/4PTX3Wuy5TwiRes PLUBUeYNidiok4mtHT6rEXSZEjwB4xtcVGt8TROneW7PznUjnh+C79JxNt4IXdb7k+4s KbTg== 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=yzpNMlr06XxHf6jJjFPNP3pG8pj9pp/dvHOGS88XDPo=; b=qsd11kKx09YY/Z5mMgPfKsb4CvRy4GfzVPJruOol0OGXh3UdhRerGvt0zjMUNBG6BN grBLMMUxC5TKPQwse4+oonPpaQEcjDU7VZa6DbNEftn3E3r0uTTpMDvjQo/pG7W+8pyS heEdHRGYSKY7jt+yGWNIyckMjlWTdWlwZiWtSJ2HMt1AmsrwwexEPJuqO/PVNPBNb3gk OKA5+74m0wxJg6MckoyPTz/hA9Twf+anRsREjIqzaE0IIayOQTUX+AwnT1RSPE8lurmn z2kEYS4N8g6N9Z5rEa58YCcUwQmPn7IlRBP/tYXD5LUs4Ukj5jTzdcQiJ2sxbaJ5/D9c P1tQ== X-Gm-Message-State: APjAAAXpp2lahPDqbB9tS/RXBsHL3mJqIAu9XLZu5R6bmtvX2g1q6iyq NdqQNU5XgTRHBqxjgP+q+aZmq/tX/RUsgO9Vmmg= X-Google-Smtp-Source: APXvYqx+SSTcq88Iy19rI+MMKQCZckNc2I2hUVu4Pkt9W8gSnMGbWbz/aM+UD3Xkjh/hUXOdR1z2LcsZ42AoHFBqn+Y= X-Received: by 2002:a05:6830:1bd5:: with SMTP id v21mr105942026ota.154.1578077662897; Fri, 03 Jan 2020 10:54:22 -0800 (PST) MIME-Version: 1.0 References: <20191226000417.69183-1-phst@google.com> <83v9psgz1x.fsf@gnu.org> In-Reply-To: <83v9psgz1x.fsf@gnu.org> From: Pip Cet Date: Fri, 3 Jan 2020 18:53:46 +0000 Message-ID: Subject: Re: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373) To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 30373 Cc: 30373@debbugs.gnu.org, Philipp Stephani , sjindel@google.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Fri, Jan 3, 2020 at 6:45 PM Eli Zaretskii wrote: > The new test fails for me on MS-Windows: > > Test module/function-finalizer backtrace: > signal(ert-test-failed (((should (equal (mod-test-function-finalizer > ert-fail(((should (equal (mod-test-function-finalizer-calls) expecte > (if (unwind-protect (setq value-370 (apply fn-368 args-369)) (setq f > (let (form-description-372) (if (unwind-protect (setq value-370 (app > (let ((value-370 'ert-form-evaluation-aborted-371)) (let (form-descr > (let* ((fn-368 #'equal) (args-369 (condition-case err (let ((signal- > (let* ((previous-calls (mod-test-function-finalizer-calls)) (expecte > (closure (t) nil (mod-test-make-function-with-finalizer) (let* ((pre > ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test > ert-run-test(#s(ert-test :name module/function-finalizer :documentat > ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m > ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type > ert-run-tests-batch((not (tag :unstable))) > ert-run-tests-batch-and-exit((not (tag :unstable))) > eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t) > command-line-1((#("-L" 0 2 (charset cp862)) #(";." 0 2 (charset cp86 > command-line() > normal-top-level() > Test module/function-finalizer condition: > (ert-test-failed > ((should > (equal > (mod-test-function-finalizer-calls) > expected-calls)) > :form > (equal > (0 0) > (1 0)) > :value nil :explanation > (list-elt 0 > (different-atoms > (0 "#x0" "? ") > (1 "#x1" "? "))))) > FAILED 26/27 module/function-finalizer (0.109375 sec) 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). From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 03 15:13:34 2020 Received: (at 30373) by debbugs.gnu.org; 3 Jan 2020 20:13:34 +0000 Received: from localhost ([127.0.0.1]:41490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inTKA-0005Sf-Ge for submit@debbugs.gnu.org; Fri, 03 Jan 2020 15:13:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35437) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inTK8-0005SR-Rn for 30373@debbugs.gnu.org; Fri, 03 Jan 2020 15:13:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1inTK3-0006U9-BV; Fri, 03 Jan 2020 15:13:27 -0500 Received: from [176.228.60.248] (port=3810 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1inTK2-0001wj-F5; Fri, 03 Jan 2020 15:13:27 -0500 Date: Fri, 03 Jan 2020 22:13:25 +0200 Message-Id: <83sgkwguxm.fsf@gnu.org> From: Eli Zaretskii To: Pip Cet In-reply-to: (message from Pip Cet on Fri, 3 Jan 2020 18:53:46 +0000) Subject: Re: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373) References: <20191226000417.69183-1-phst@google.com> <83v9psgz1x.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 30373 Cc: 30373@debbugs.gnu.org, p.stephani2@gmail.com, sjindel@google.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Pip Cet > Date: Fri, 3 Jan 2020 18:53:46 +0000 > Cc: Philipp Stephani , 30373@debbugs.gnu.org, sjindel@google.com > > 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: Test module/function-finalizer condition: (ert-test-failed ((should (equal (mod-test-function-finalizer-calls) expected-calls)) :form (equal (0 0) (1 0)) :value nil :explanation (list-elt 0 (different-atoms (0 "#x0" "?") (1 "#x1" "?"))))) FAILED 26/27 module/function-finalizer (0.247565 sec) From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 03 15:50:20 2020 Received: (at 30373) by debbugs.gnu.org; 3 Jan 2020 20:50:20 +0000 Received: from localhost ([127.0.0.1]:41733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inTtj-0006QY-Qn for submit@debbugs.gnu.org; Fri, 03 Jan 2020 15:50:20 -0500 Received: from mail-ot1-f53.google.com ([209.85.210.53]:40598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inTth-0006QI-DR for 30373@debbugs.gnu.org; Fri, 03 Jan 2020 15:50:17 -0500 Received: by mail-ot1-f53.google.com with SMTP id w21so54868094otj.7 for <30373@debbugs.gnu.org>; Fri, 03 Jan 2020 12:50:17 -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=tU7AimXqGjLqElyss63cLIMl8kA90AVJ7crr/2f5LzQ=; b=G6xhYKFQIIMsR+uuL419ke6q7IwK0l9rvt36CVSVRDcYjOmKAkyQ+tOkIVDwP2jUm6 +v4ZzVhLkB7LiDjw2I7x2V4uVjAWkUrTknXkQbJ+lh5R40tpn3no33qfjQF6RPdkfCE7 AqPnmwfo5/8Zrzsli+RYy3UVjXH+1FL8EPckgPTWbVMwIR71Bm8xuX3yH/EXYmN+MUz9 LfAYMrt6e+8MRvg9xYc8L7jJgxmUf3z7ymlo/wTuwxG8wTWr3JCJVNZTu/mO9B1rWpTO PLOQb7cNWfCRwTceAhtWz+7bzUI22oaYAqHrGia+oipuEoQK111KFHSOwwycYbKNQ0GK D3og== 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=tU7AimXqGjLqElyss63cLIMl8kA90AVJ7crr/2f5LzQ=; b=N7pk13SL2zaWT3k4Fyq70QxcUj/KM81HNuGDII3dY8ZjyyK3XWJKHez1sxfqr0Tpgn Y1jgAAmKjRX3/gOfgvXFYA4xfVNzG5tGaKV08LfUtDGMPxtbKiGgxmaG7XF47ekZ0k64 geRNIKrG9/wt3/5LySBa1a7RjT2gvMge56fC6fac4/oSAw42tPLYppZC1qjxSXxloggW J6+CCe5i1Bugr9gXOSiAwtoRKjUR7tp5hvKrMRD7lq6C8yvTtIGSttZa3PxHWerQd/l3 ZBHs26J8FDK90Bf9g3v1uHidhGYaEFin7Zh9icGiFjCiUSTikx8SFhg1ycTM7arAfxbP ggpA== X-Gm-Message-State: APjAAAUBOEgkDc+g2Ot0Qe3POjQ6gvWjcurs34TOHu6HjFpNPru9Hy1J P1vzkTWQVwg+gP3muJ1LB/SyI8yKV7Yn45icxmI= X-Google-Smtp-Source: APXvYqx85DwWn0oKexW+O0oVodlRPOBTrlZhWAxsda5HtpGgJFKKxLP7unuRGq3sHAoyYRcpkarlrWnxQ+ukTNu9FbA= X-Received: by 2002:a05:6830:1bd5:: with SMTP id v21mr106477326ota.154.1578084611823; Fri, 03 Jan 2020 12:50:11 -0800 (PST) MIME-Version: 1.0 References: <20191226000417.69183-1-phst@google.com> <83v9psgz1x.fsf@gnu.org> <83sgkwguxm.fsf@gnu.org> In-Reply-To: <83sgkwguxm.fsf@gnu.org> From: Pip Cet Date: Fri, 3 Jan 2020 20:49:35 +0000 Message-ID: Subject: Re: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373) To: Eli Zaretskii Content-Type: multipart/mixed; boundary="000000000000b6c087059b427452" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 30373 Cc: 30373@debbugs.gnu.org, p.stephani2@gmail.com, sjindel@google.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000b6c087059b427452 Content-Type: text/plain; charset="UTF-8" On Fri, Jan 3, 2020 at 8:13 PM Eli Zaretskii wrote: > > From: Pip Cet > > Date: Fri, 3 Jan 2020 18:53:46 +0000 > > Cc: Philipp Stephani , 30373@debbugs.gnu.org, sjindel@google.com > > > > 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. --000000000000b6c087059b427452 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Make-progn-make-huge-vector-garbage-collect-behave-a.patch" Content-Disposition: attachment; filename="0001-Make-progn-make-huge-vector-garbage-collect-behave-a.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k4ymt5fv0 RnJvbSAyYzE1NTMzY2NjYmNkMTYyMmRiNzMzNjIxOTVlODZmOWMzNDUzMWU2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQaXAgQ2V0IDxwaXBjZXRAZ21haWwuY29tPgpEYXRlOiBGcmks IDMgSmFuIDIwMjAgMjA6NDc6NTAgKzAwMDAKU3ViamVjdDogW1BBVENIXSBNYWtlIChwcm9nbiAo bWFrZS1odWdlLXZlY3RvcikgKGdhcmJhZ2UtY29sbGVjdCkpIGJlaGF2ZSBhcwogZXhwZWN0ZWQK Ci0tLQogc3JjL2V2YWwuYyB8IDEgKwogMSBmaWxlIGNoYW5nZWQsIDEgaW5zZXJ0aW9uKCspCgpk aWZmIC0tZ2l0IGEvc3JjL2V2YWwuYyBiL3NyYy9ldmFsLmMKaW5kZXggNjY3NTJhMzk3Yy4uZWI5 MDE4ZjY2YSAxMDA2NDQKLS0tIGEvc3JjL2V2YWwuYworKysgYi9zcmMvZXZhbC5jCkBAIC00NTcs NiArNDU3LDcgQEAgREVGVU4gKCJwcm9nbiIsIEZwcm9nbiwgU3Byb2duLCAwLCBVTkVWQUxMRUQs IDAsCiAKICAgd2hpbGUgKENPTlNQIChib2R5KSkKICAgICB7CisgICAgICAvKiBEb24ndCBrZWVw IFZBTCBhbGl2ZSB1bm5lY2Vzc2FyaWx5IChidWcjMzAzNzMpLiAgKi8KICAgICAgIHZhbCA9IFFu aWw7CiAgICAgICBMaXNwX09iamVjdCBmb3JtID0gWENBUiAoYm9keSk7CiAgICAgICBib2R5ID0g WENEUiAoYm9keSk7Ci0tIAoyLjI0LjAKCg== --000000000000b6c087059b427452-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 04 14:56:57 2020 Received: (at 30373) by debbugs.gnu.org; 4 Jan 2020 19:56:57 +0000 Received: from localhost ([127.0.0.1]:43422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inpXc-0003uv-PT for submit@debbugs.gnu.org; Sat, 04 Jan 2020 14:56:56 -0500 Received: from mail-ot1-f51.google.com ([209.85.210.51]:34116) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inpXb-0003uk-Lo for 30373@debbugs.gnu.org; Sat, 04 Jan 2020 14:56:55 -0500 Received: by mail-ot1-f51.google.com with SMTP id a15so65826022otf.1 for <30373@debbugs.gnu.org>; Sat, 04 Jan 2020 11:56:55 -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=9USAdSsavzgs5KLlUCfRbXP94MEtZ7lJwS5pFq/eg6k=; b=fWscZxdJj3gc5/lh9XWTuDCOH7S4UbMl2jw98AzW4RRT0mn3VL85cdb8Lppe1+L4ix 4qdQ1yNJvVKlVRR338T6SqDSxIjJUfio46XXY1izApAeT7zE3EMxQUrUneML2fn84XsI qMAZfEHL6DNF4BdGaxt5k5h9xnvGxI2a9Zu/k7NxirhvfE4T7vc6VpfaV75UxSQBNZzW rc0zvAzAqsej7++lqQd1JYxNmfVVu/LRPk3KEamh8DuthQg6FvRGPrcDRQqyQBe/AGVT ygXPJ8s7kHlgskS6CSRCfkjAoBgfncfVKWqD7Qnn0topAqeNOmQProfZ86d5D/nK3rby 2AVg== 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=9USAdSsavzgs5KLlUCfRbXP94MEtZ7lJwS5pFq/eg6k=; b=A+s5/hY159nIC+BdmTVbT4+PpotANvppAOHiHkXrl3eb0ZrHBwFfE4dacULm9BQxn1 fTdmRLb8LjD+KS4pMmzMWgFhk5cQyrVjP0zxlOFjIcCd1SXG18MPw2MSu5e7uGJ8MECj 0lOEqiLrcuPyYteNaQFL31/ZcTV6/B+i4DfAjawYMltVw8bj94oz9CEtIZ7tAJTD22UQ 0BE+Y7W1jozWnhhzRXKFNy+pAUECGPyQ9HAxFdcejD4Zl6K11QkNye5Gcc5KV8HfX6AP ao2srIfIBJo82YxUNljwghI6m9OwfjCTgmQTNn2aV2H+HNQBIv0eMny71tKv/lJMvuzm FgpA== X-Gm-Message-State: APjAAAUR2/MbPfmAc9o4XDqCmX4lQtrX6jVTkXNe5IunU0doRi5r5Lf3 tqN7DKLw3/R6Tb9z6cBi8Bl/xgQhaAnz7YCVFvo= X-Google-Smtp-Source: APXvYqy7gV1MShYuahahfHv6m52LWsSOgyPYVXtAB26rMb0LCltG1JdIgpZWwpXJ9ey726KT6zS6v7/k+ClsF9ocwtM= X-Received: by 2002:a05:6830:ce:: with SMTP id x14mr93917212oto.105.1578167809866; Sat, 04 Jan 2020 11:56:49 -0800 (PST) MIME-Version: 1.0 References: <20191226000417.69183-1-phst@google.com> <83v9psgz1x.fsf@gnu.org> <83sgkwguxm.fsf@gnu.org> In-Reply-To: From: Philipp Stephani Date: Sat, 4 Jan 2020 20:56:37 +0100 Message-ID: Subject: Re: bug#30373: [PATCH] Implement finalizers for module functions (Bug#30373) To: Pip Cet Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 30373 Cc: 30373@debbugs.gnu.org, Eli Zaretskii , Samir Jindel X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Am Fr., 3. Jan. 2020 um 21:50 Uhr schrieb Pip Cet : > > On Fri, Jan 3, 2020 at 8:13 PM Eli Zaretskii wrote: > > > From: Pip Cet > > > Date: Fri, 3 Jan 2020 18:53:46 +0000 > > > Cc: Philipp Stephani , 30373@debbugs.gnu.org, sjindel@google.com > > > > > > 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. Ah yeah, looks like the test was too brittle. (For some reason, it worked fine on macOS.) I've now installed a patch that creates 100 dangling functions; hopefully that increases the likelihood of at least one getting garbage-collected. From unknown Fri Jun 20 07:12:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 02 Feb 2020 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator