diff options
| author | Philipp Stephani | 2020-07-25 23:23:19 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2020-07-25 23:23:19 +0200 |
| commit | 9f01ce6327af886f26399924a9aadf16cdd4fd9f (patch) | |
| tree | a363d2673c61ac60183457965462b05b8b867f4b /src | |
| parent | 6355a3ec62f43c9b99d483982ff851d32dd78891 (diff) | |
| download | emacs-9f01ce6327af886f26399924a9aadf16cdd4fd9f.tar.gz emacs-9f01ce6327af886f26399924a9aadf16cdd4fd9f.zip | |
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.
* test/data/emacs-module/mod-test.c (Fmod_test_globref_invalid_free):
New test module function.
(emacs_module_init): Export it.
* test/src/emacs-module-tests.el
(module--test-assertions--globref-invalid-free): New unit test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs-module.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 02563a4b8b5..e4e7da088d7 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -468,6 +468,14 @@ module_free_global_ref (emacs_env *env, emacs_value global_value) | |||
| 468 | Lisp_Object obj = value_to_lisp (global_value); | 468 | Lisp_Object obj = value_to_lisp (global_value); |
| 469 | ptrdiff_t i = hash_lookup (h, obj, NULL); | 469 | ptrdiff_t i = hash_lookup (h, obj, NULL); |
| 470 | 470 | ||
| 471 | if (module_assertions) | ||
| 472 | { | ||
| 473 | ptrdiff_t n = 0; | ||
| 474 | if (! module_global_reference_p (global_value, &n)) | ||
| 475 | module_abort ("Global value was not found in list of %"pD"d globals", | ||
| 476 | n); | ||
| 477 | } | ||
| 478 | |||
| 471 | if (i >= 0) | 479 | if (i >= 0) |
| 472 | { | 480 | { |
| 473 | Lisp_Object value = HASH_VALUE (h, i); | 481 | Lisp_Object value = HASH_VALUE (h, i); |
| @@ -476,11 +484,6 @@ module_free_global_ref (emacs_env *env, emacs_value global_value) | |||
| 476 | if (--ref->refcount == 0) | 484 | if (--ref->refcount == 0) |
| 477 | hash_remove_from_table (h, obj); | 485 | hash_remove_from_table (h, obj); |
| 478 | } | 486 | } |
| 479 | else if (module_assertions) | ||
| 480 | { | ||
| 481 | module_abort ("Global value was not found in list of %"pD"d globals", | ||
| 482 | h->count); | ||
| 483 | } | ||
| 484 | } | 487 | } |
| 485 | 488 | ||
| 486 | static enum emacs_funcall_exit | 489 | static enum emacs_funcall_exit |