From: Gemini Lasswell <gazally@runbox.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 33014@debbugs.gnu.org
Subject: bug#33014: 26.1.50; 27.0.50; Fatal error after re-evaluating a thread's function
Date: Fri, 19 Oct 2018 13:05:19 -0700 [thread overview]
Message-ID: <878t2tbt34.fsf@runbox.com> (raw)
In-Reply-To: <83va5ypbpo.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 19 Oct 2018 11:44:35 +0300")
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> > Anyway, are you saying that stack marking doesn't work in optimized
>> > code? We've been using this technique for the last 17 years without
>> > problems; why would the fact that we have more than one thread change
>> > that? The same arguments you submit are valid for a single-threaded
>> > Emacs, right?
>>
>> Apparently so. I set up a single-threaded situation where I could
>> redefine a function while exec_byte_code was running it, and got a
>> segfault. I've gained some insights from debugging this version of the
>> bug which I will put into a separate email.
>
> If this is the case, then I think we should protect the definition of
> a running function from GC, in some way, either by making sure it is
> referenced by some stack-based Lisp object, even in heavily optimized
> code (e.g., by using 'volatile' qualifiers); or by some other method
> that will ensure that definition is marked and not swept.
Maybe code optimizers have improved over the last 17 years?
I have patched Emacs with a 'volatile' on the definition of 'fun' in
Ffuncall, and so far haven't managed to reproduce the bug with it:
[-- Attachment #2: 0001-src-eval.c-Ffuncall-Make-local-variable-fun-volatile.patch --]
[-- Type: text/plain, Size: 801 bytes --]
From a1fc2dfd392e0ba8754159d855da231a56ca275b Mon Sep 17 00:00:00 2001
From: Gemini Lasswell <gazally@runbox.com>
Date: Sun, 14 Oct 2018 12:12:04 -0700
Subject: [PATCH] * src/eval.c (Ffuncall): Make local variable 'fun' volatile
(bug#33014)
---
src/eval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/eval.c b/src/eval.c
index 5e25caaa84..75b30f9c7d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2817,8 +2817,8 @@ Thus, (funcall \\='cons \\='x \\='y) returns (x . y).
usage: (funcall FUNCTION &rest ARGUMENTS) */)
(ptrdiff_t nargs, Lisp_Object *args)
{
- Lisp_Object fun, original_fun;
- Lisp_Object funcar;
+ Lisp_Object volatile fun;
+ Lisp_Object original_fun, funcar;
ptrdiff_t numargs = nargs - 1;
Lisp_Object val;
ptrdiff_t count;
--
2.16.4
[-- Attachment #3: Type: text/plain, Size: 354 bytes --]
I'll go back now to working on my benchmarking project which I hope
someday will make it easy to see if that 'volatile' causes measurable
harm to performance. I'll also keep using 'eval-region' and 'eval-buffer'
while I have threads running byte-compiled functions which get redefined
by doing that, and report back here if I encounter this bug again.
next prev parent reply other threads:[~2018-10-19 20:05 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 5:30 bug#33014: 26.1.50; 27.0.50; Fatal error after re-evaluating a thread's function Gemini Lasswell
2018-10-12 8:12 ` Eli Zaretskii
2018-10-12 20:02 ` Gemini Lasswell
2018-10-13 6:23 ` Eli Zaretskii
2018-10-13 17:17 ` Gemini Lasswell
2018-10-13 18:04 ` Eli Zaretskii
2018-10-14 19:29 ` Gemini Lasswell
2018-10-15 2:37 ` Eli Zaretskii
2018-10-14 19:46 ` Andreas Schwab
2018-10-15 14:59 ` Eli Zaretskii
2018-10-15 16:22 ` Gemini Lasswell
2018-10-15 16:41 ` Eli Zaretskii
2018-10-16 18:46 ` Gemini Lasswell
2018-10-16 19:25 ` Eli Zaretskii
2018-10-16 19:38 ` Eli Zaretskii
2018-10-19 0:22 ` Gemini Lasswell
2018-10-19 8:44 ` Eli Zaretskii
2018-10-19 20:05 ` Gemini Lasswell [this message]
2018-10-20 6:41 ` Eli Zaretskii
2018-10-20 8:23 ` Andreas Schwab
2018-10-20 10:20 ` Eli Zaretskii
2018-10-20 11:30 ` Andreas Schwab
2018-10-29 18:24 ` Gemini Lasswell
2018-10-29 19:41 ` Eli Zaretskii
2018-10-19 19:32 ` Gemini Lasswell
2018-10-17 16:21 ` Eli Zaretskii
2018-10-18 1:07 ` Gemini Lasswell
2018-10-18 17:04 ` Eli Zaretskii
2018-10-19 0:39 ` Gemini Lasswell
2018-10-19 8:38 ` Eli Zaretskii
2018-10-29 18:56 ` Stefan Monnier
2018-10-31 4:49 ` Paul Eggert
2018-10-31 15:33 ` Eli Zaretskii
2018-11-01 23:15 ` Gemini Lasswell
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878t2tbt34.fsf@runbox.com \
--to=gazally@runbox.com \
--cc=33014@debbugs.gnu.org \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).