diff options
| author | Philipp Stephani | 2017-07-04 22:50:46 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-07-08 15:25:01 +0200 |
| commit | b7dab24b7953f7a31b806f83e15043c94aaa7745 (patch) | |
| tree | fc31284ef0fac82accddc573069652b1c8adccf0 /src | |
| parent | a87d767c7acc43b3679d87d2d225b1edeb69326c (diff) | |
| download | emacs-b7dab24b7953f7a31b806f83e15043c94aaa7745.tar.gz emacs-b7dab24b7953f7a31b806f83e15043c94aaa7745.zip | |
Module assertions: check for garbage collections
It's technically possible to write a user pointer finalizer that calls
into Emacs module functions. This would be disastrous because it
would allow arbitrary Lisp code to run during garbage collection.
Therefore extend the module assertions to check for this case.
* src/emacs-module.c (module_assert_thread): Also check whether a
garbage collection is in progress.
* test/data/emacs-module/mod-test.c (invalid_finalizer)
(Fmod_test_invalid_finalizer): New test module functions.
(emacs_module_init): Register new test function.
* test/src/emacs-module-tests.el (module--test-assertion)
(module--with-temp-directory): New helper macros.
(module--test-assertions--load-non-live-object): Rename existing
unit test, use helper macros.
(module--test-assertions--call-emacs-from-gc): New unit test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs-module.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 7b1a402eeff..b80aa23abce 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -817,9 +817,11 @@ in_current_thread (void) | |||
| 817 | static void | 817 | static void |
| 818 | module_assert_thread (void) | 818 | module_assert_thread (void) |
| 819 | { | 819 | { |
| 820 | if (! module_assertions || in_current_thread ()) | 820 | if (! module_assertions || (in_current_thread () && ! gc_in_progress)) |
| 821 | return; | 821 | return; |
| 822 | module_abort ("Module function called from outside the current Lisp thread"); | 822 | module_abort (gc_in_progress ? |
| 823 | "Module function called during garbage collection" : | ||
| 824 | "Module function called from outside the current Lisp thread"); | ||
| 823 | } | 825 | } |
| 824 | 826 | ||
| 825 | static void | 827 | static void |