[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-27 d767418 3/3: Backport: Make checking for liveness of global val
From: |
Philipp Stephani |
Subject: |
emacs-27 d767418 3/3: Backport: Make checking for liveness of global values more precise. |
Date: |
Fri, 31 Jul 2020 12:20:43 -0400 (EDT) |
branch: emacs-27
commit d767418b76818e4e83bf19cc08307c1329144c13
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>
Backport: Make checking for liveness of global values more precise.
We can't just use a hash lookup because a global and a local reference
might refer to the same Lisp object.
* src/emacs-module.c (module_free_global_ref): More precise check for
global liveness.
(cherry picked from commit 9f01ce6327af886f26399924a9aadf16cdd4fd9f)
---
src/emacs-module.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 099a6a3..a90a976 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -448,6 +448,14 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
Lisp_Object obj = value_to_lisp (ref);
ptrdiff_t i = hash_lookup (h, obj, NULL);
+ if (module_assertions)
+ {
+ ptrdiff_t n = 0;
+ if (! module_global_reference_p (ref, &n))
+ module_abort ("Global value was not found in list of %"pD"d globals",
+ n);
+ }
+
if (i >= 0)
{
Lisp_Object value = HASH_VALUE (h, i);
@@ -456,11 +464,6 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
if (--ref->refcount == 0)
hash_remove_from_table (h, obj);
}
- else if (module_assertions)
- {
- module_abort ("Global value was not found in list of %"pD"d globals",
- h->count);
- }
}
static enum emacs_funcall_exit