From: Pip Cet <pipcet@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 46256@debbugs.gnu.org, andrewjmoreton@gmail.com,
Andrea Corallo <akrl@sdf.org>
Subject: bug#46256: [feature/native-comp] AOT eln files ignored if run from build tree
Date: Mon, 8 Mar 2021 06:48:40 +0000 [thread overview]
Message-ID: <CAOqdjBeYSLeFCQi3jG33CH297B1a2CRUEYVPG_o3_iF9_JamnQ@mail.gmail.com> (raw)
In-Reply-To: <CAOqdjBe_NJ2vYxd6bsZMJ1th8djqEJKbJuiPW0WVYi0sKWqiug@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
On Mon, Mar 8, 2021 at 5:54 AM Pip Cet <pipcet@gmail.com> wrote:
> Note that this might not always work because of conservative GC.
If it doesn't work, can you simply retry a few times? Eventually there
shouldn't be references to the stale native_comp_unit on the stack.
However, I think I've worked out why dynlib_close doesn't do its job:
Fnative_elisp_load creates a comp unit, but, if the shared library has
already been initialized, it doesn't set that comp unit's comp_unit
variable to point to the new comp unit; instead, it will continue
pointing to the first comp unit which still has it open.
Then, the original comp unit is unloaded but not the new one created
by Fnative_elisp_load. We call dynlib_close() once, but we called it
twice before, leaving the shared library open and initialized.
Then, we try to load the comp unit again, and follow the stale
comp_unit variable pointing to the original comp unit.
Fix should be as attached. Note the fix is, at worst, harmless (unless
I messed up), so we should apply it anyway just because it's good not
to leave stale pointers lying around even if we hope that the OS
unmaps them at some point.
Pip
[-- Attachment #2: 0001-Fix-stale-pointers-in-comp-units-causing-crashes-bug.patch --]
[-- Type: text/x-patch, Size: 2001 bytes --]
From a2ab9701e48e5443809664d50c924b9d83062b4e Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Sun, 7 Mar 2021 21:26:29 +0000
Subject: [PATCH] Fix stale pointers in comp units causing crashes (bug#46256)
* src/alloc.c (cleanup_vector): Call unload_comp_unit.
* src/comp.c (unload_comp_unit): New function.
---
src/alloc.c | 3 +--
src/comp.c | 14 ++++++++++++++
src/comp.h | 2 ++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index af08336177070..fee8cc08aa483 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3157,8 +3157,7 @@ cleanup_vector (struct Lisp_Vector *vector)
{
struct Lisp_Native_Comp_Unit *cu =
PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit);
- eassert (cu->handle);
- dynlib_close (cu->handle);
+ unload_comp_unit (cu);
}
else if (NATIVE_COMP_FLAG
&& PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR))
diff --git a/src/comp.c b/src/comp.c
index b68adf31d68bd..c9e068b90aa2c 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4936,6 +4936,20 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
return res;
}
+void
+unload_comp_unit (struct Lisp_Native_Comp_Unit *cu)
+{
+ if (cu->handle == NULL)
+ return;
+
+ Lisp_Object *saved_cu = dynlib_sym (cu->handle, COMP_UNIT_SYM);
+ Lisp_Object this_cu;
+ XSETNATIVE_COMP_UNIT (this_cu, cu);
+ if (EQ (this_cu, *saved_cu))
+ *saved_cu = Qnil;
+ dynlib_close (cu->handle);
+}
+
Lisp_Object
native_function_doc (Lisp_Object function)
{
diff --git a/src/comp.h b/src/comp.h
index f7d17f398c75d..d01bc17565d7d 100644
--- a/src/comp.h
+++ b/src/comp.h
@@ -78,6 +78,8 @@ XNATIVE_COMP_UNIT (Lisp_Object a)
extern Lisp_Object load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
bool loading_dump, bool late_load);
+extern void unload_comp_unit (struct Lisp_Native_Comp_Unit *);
+
extern Lisp_Object native_function_doc (Lisp_Object function);
extern void syms_of_comp (void);
--
2.30.1
next prev parent reply other threads:[~2021-03-08 6:48 UTC|newest]
Thread overview: 179+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 11:11 bug#46256: [feature/native-comp] AOT eln files ignored if run from build tree Andy Moreton
2021-02-03 20:51 ` akrl--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-04 0:03 ` Andy Moreton
2021-02-04 1:40 ` Andy Moreton
2021-02-05 14:42 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-05 20:59 ` Andy Moreton
2021-02-05 23:55 ` Andy Moreton
2021-02-17 22:39 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-18 20:48 ` Andy Moreton
2021-02-18 21:00 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-19 8:02 ` Eli Zaretskii
2021-02-19 14:49 ` Andy Moreton
2021-02-19 15:28 ` Eli Zaretskii
2021-02-19 16:01 ` Andrea Corallo
2021-02-26 20:34 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-26 20:45 ` Eli Zaretskii
2021-02-26 20:48 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-26 20:52 ` Eli Zaretskii
2021-02-27 6:58 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-27 7:55 ` Eli Zaretskii
2021-02-27 12:08 ` Andy Moreton
2021-02-27 19:14 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-27 19:20 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-27 19:46 ` Andy Moreton
2021-02-27 21:58 ` Andy Moreton
2021-02-28 17:35 ` Eli Zaretskii
2021-02-28 21:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-01 5:36 ` Eli Zaretskii
2021-03-01 6:34 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-01 9:48 ` Andy Moreton
2021-03-03 18:27 ` Eli Zaretskii
2021-03-03 18:43 ` Eli Zaretskii
2021-03-03 19:46 ` Eli Zaretskii
2021-03-03 20:04 ` Eli Zaretskii
2021-03-03 20:21 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 8:30 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 11:54 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 14:13 ` Eli Zaretskii
2021-03-04 14:24 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 14:49 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 17:24 ` Eli Zaretskii
2021-03-04 18:56 ` Eli Zaretskii
2021-03-04 20:11 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 21:33 ` Eli Zaretskii
2021-03-05 9:32 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-05 10:09 ` Pip Cet
2021-03-05 10:19 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 1:47 ` Andy Moreton
2021-03-06 9:54 ` Pip Cet
2021-03-06 10:30 ` Eli Zaretskii
2021-03-06 12:15 ` Andy Moreton
2021-03-06 13:10 ` Eli Zaretskii
2021-03-06 15:18 ` Andy Moreton
2021-03-06 18:37 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 9:22 ` Pip Cet
2021-03-05 11:55 ` Eli Zaretskii
2021-03-05 13:56 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-05 14:54 ` Eli Zaretskii
2021-03-05 15:18 ` Pip Cet
2021-03-05 15:22 ` Eli Zaretskii
2021-03-05 15:54 ` Pip Cet
2021-03-05 18:44 ` Eli Zaretskii
2021-03-05 15:26 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-04 21:30 ` Andy Moreton
2021-03-04 20:47 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-05 13:52 ` Eli Zaretskii
2021-03-05 14:04 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-05 15:00 ` Eli Zaretskii
2021-03-05 15:56 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-05 18:46 ` Eli Zaretskii
2021-03-05 19:22 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-05 20:31 ` Eli Zaretskii
2021-03-05 22:25 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 7:39 ` Eli Zaretskii
2021-03-06 14:38 ` Eli Zaretskii
2021-03-06 15:35 ` Eli Zaretskii
2021-03-06 17:47 ` Eli Zaretskii
2021-03-06 18:31 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 18:48 ` Eli Zaretskii
2021-03-06 19:19 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 19:40 ` Pip Cet
2021-03-06 19:48 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 20:24 ` Eli Zaretskii
2021-03-06 20:31 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 20:53 ` Eli Zaretskii
2021-03-06 21:02 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 5:55 ` Eli Zaretskii
2021-03-07 6:57 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 7:40 ` Eli Zaretskii
2021-03-07 19:05 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 18:56 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 19:08 ` Eli Zaretskii
2021-03-06 20:08 ` Eli Zaretskii
2021-03-06 20:19 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 18:30 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 18:44 ` Eli Zaretskii
2021-03-06 19:21 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 20:10 ` Eli Zaretskii
2021-03-06 20:26 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-06 0:33 ` Andy Moreton
2021-03-06 7:42 ` Eli Zaretskii
2021-03-06 12:09 ` Andy Moreton
2021-03-06 13:05 ` Eli Zaretskii
2021-03-06 15:46 ` Andy Moreton
2021-03-06 19:31 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 17:59 ` Eli Zaretskii
2021-03-07 18:53 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 19:15 ` Eli Zaretskii
2021-03-07 20:16 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 21:27 ` Pip Cet
2021-03-07 21:47 ` Pip Cet
2021-03-07 21:51 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-07 22:16 ` Pip Cet
2021-03-08 13:26 ` Eli Zaretskii
2021-03-08 13:52 ` Pip Cet
2021-03-08 14:39 ` Eli Zaretskii
2021-03-08 14:50 ` Pip Cet
2021-03-08 15:14 ` Eli Zaretskii
2021-03-08 17:40 ` Eli Zaretskii
2021-03-08 3:31 ` Eli Zaretskii
2021-03-08 5:54 ` Pip Cet
2021-03-08 6:48 ` Pip Cet [this message]
2021-03-08 10:14 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-08 10:45 ` Pip Cet
2021-03-08 15:02 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-08 15:09 ` Pip Cet
2021-03-08 15:38 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 12:36 ` Eli Zaretskii
2021-03-09 8:32 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 13:05 ` Eli Zaretskii
2021-03-09 13:58 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 16:36 ` Eli Zaretskii
2021-03-09 17:10 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-08 14:11 ` Eli Zaretskii
2021-03-08 14:27 ` Pip Cet
2021-03-08 18:06 ` Eli Zaretskii
2021-03-08 18:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-08 20:37 ` Eli Zaretskii
2021-03-09 7:03 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 12:55 ` Eli Zaretskii
2021-03-09 14:55 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 16:42 ` Eli Zaretskii
2021-03-09 18:31 ` Eli Zaretskii
2021-03-09 19:38 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 16:30 ` Eli Zaretskii
2021-03-10 13:14 ` Alan Mackenzie
2021-03-10 13:20 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-10 14:07 ` Eli Zaretskii
2021-03-10 15:24 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-10 16:56 ` Alan Mackenzie
2021-03-10 17:43 ` Eli Zaretskii
2021-03-08 18:18 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-08 18:32 ` Pip Cet
2021-03-08 20:47 ` Eli Zaretskii
2021-03-08 20:50 ` Pip Cet
2021-03-09 8:28 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 8:35 ` Pip Cet
2021-03-09 8:43 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 14:32 ` Eli Zaretskii
2021-03-08 20:49 ` Eli Zaretskii
2021-03-09 8:35 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 14:34 ` Eli Zaretskii
2021-03-09 15:38 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 16:51 ` Eli Zaretskii
2021-03-09 17:04 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-09 18:20 ` Eli Zaretskii
2021-03-09 19:23 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-08 18:13 ` Eli Zaretskii
2021-03-08 20:53 ` Pip Cet
2021-03-08 15:07 ` Eli Zaretskii
2021-03-03 18:48 ` Eli Zaretskii
2021-03-03 19:28 ` Eli Zaretskii
2021-03-03 19:50 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-03 20:08 ` Eli Zaretskii
2021-03-03 19:37 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-03 20:13 ` Eli Zaretskii
2021-02-28 21:04 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-05 14:39 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-02-05 15:08 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOqdjBeYSLeFCQi3jG33CH297B1a2CRUEYVPG_o3_iF9_JamnQ@mail.gmail.com \
--to=pipcet@gmail.com \
--cc=46256@debbugs.gnu.org \
--cc=akrl@sdf.org \
--cc=andrewjmoreton@gmail.com \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.