diff options
| author | Pip Cet | 2021-03-07 21:26:29 +0000 |
|---|---|---|
| committer | Andrea Corallo | 2021-03-09 09:25:27 +0100 |
| commit | 93f92cf1ba37f8b9abaee4b9487705bae464c4e0 (patch) | |
| tree | 5d1c5111b79b5cedeba1d5098e560946986cd9af /src | |
| parent | 15aa239ba058ef02544e5dfaf066bd985d9b2f4f (diff) | |
| download | emacs-93f92cf1ba37f8b9abaee4b9487705bae464c4e0.tar.gz emacs-93f92cf1ba37f8b9abaee4b9487705bae464c4e0.zip | |
Zero stale pointer when unloading comp units (bug#46256)
* src/alloc.c (cleanup_vector): Call unload_comp_unit.
* src/comp.c (unload_comp_unit): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 3 | ||||
| -rw-r--r-- | src/comp.c | 14 | ||||
| -rw-r--r-- | src/comp.h | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c index af083361770..fee8cc08aa4 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3157,8 +3157,7 @@ cleanup_vector (struct Lisp_Vector *vector) | |||
| 3157 | { | 3157 | { |
| 3158 | struct Lisp_Native_Comp_Unit *cu = | 3158 | struct Lisp_Native_Comp_Unit *cu = |
| 3159 | PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); | 3159 | PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); |
| 3160 | eassert (cu->handle); | 3160 | unload_comp_unit (cu); |
| 3161 | dynlib_close (cu->handle); | ||
| 3162 | } | 3161 | } |
| 3163 | else if (NATIVE_COMP_FLAG | 3162 | else if (NATIVE_COMP_FLAG |
| 3164 | && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) | 3163 | && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) |
diff --git a/src/comp.c b/src/comp.c index e6f672de254..e1809785410 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -4949,6 +4949,20 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, | |||
| 4949 | return res; | 4949 | return res; |
| 4950 | } | 4950 | } |
| 4951 | 4951 | ||
| 4952 | void | ||
| 4953 | unload_comp_unit (struct Lisp_Native_Comp_Unit *cu) | ||
| 4954 | { | ||
| 4955 | if (cu->handle == NULL) | ||
| 4956 | return; | ||
| 4957 | |||
| 4958 | Lisp_Object *saved_cu = dynlib_sym (cu->handle, COMP_UNIT_SYM); | ||
| 4959 | Lisp_Object this_cu; | ||
| 4960 | XSETNATIVE_COMP_UNIT (this_cu, cu); | ||
| 4961 | if (EQ (this_cu, *saved_cu)) | ||
| 4962 | *saved_cu = Qnil; | ||
| 4963 | dynlib_close (cu->handle); | ||
| 4964 | } | ||
| 4965 | |||
| 4952 | Lisp_Object | 4966 | Lisp_Object |
| 4953 | native_function_doc (Lisp_Object function) | 4967 | native_function_doc (Lisp_Object function) |
| 4954 | { | 4968 | { |
diff --git a/src/comp.h b/src/comp.h index f7d17f398c7..d01bc17565d 100644 --- a/src/comp.h +++ b/src/comp.h | |||
| @@ -78,6 +78,8 @@ extern void hash_native_abi (void); | |||
| 78 | extern Lisp_Object load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, | 78 | extern Lisp_Object load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, |
| 79 | bool loading_dump, bool late_load); | 79 | bool loading_dump, bool late_load); |
| 80 | 80 | ||
| 81 | extern void unload_comp_unit (struct Lisp_Native_Comp_Unit *); | ||
| 82 | |||
| 81 | extern Lisp_Object native_function_doc (Lisp_Object function); | 83 | extern Lisp_Object native_function_doc (Lisp_Object function); |
| 82 | 84 | ||
| 83 | extern void syms_of_comp (void); | 85 | extern void syms_of_comp (void); |