From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: luangruo@yahoo.com, casouri@gmail.com, mickey@masteringemacs.org,
60237@debbugs.gnu.org
Subject: bug#60237: 30.0.50; tree sitter core dumps when I edebug view a node
Date: Sat, 04 Mar 2023 14:21:41 +0200 [thread overview]
Message-ID: <83v8jgaeqy.fsf@gnu.org> (raw)
In-Reply-To: <jwv8rggz81h.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Wed, 01 Mar 2023 12:39:03 -0500)
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: casouri@gmail.com, luangruo@yahoo.com, mickey@masteringemacs.org,
> 60237@debbugs.gnu.org
> Date: Wed, 01 Mar 2023 12:39:03 -0500
>
> >> For `emacs-29` I suggest we just use the patch below which should
> >> circumvent the problem.
> >
> > Fine with me, please install, and thanks.
>
> Thanks, pushed. Hopefully we can do a bit better on `master`, but
> I don't have time for it right now. Maybe someone else?
I tried cargo-culting the cpu_gc_count stuff for the memory profiler,
see the patch below. However, something is amiss: this assertion in
profiler.el sometimes triggers:
(maphash
(lambda (backtrace _count)
(let* ((max (1- (length backtrace)))
(head (aref backtrace max))
(best-parent nil)
(best-match (1+ max))
(parents (gethash head fun-map)))
(pcase-dolist (`(,i . ,parent) parents)
(when t ;; (<= (- max i) best-match) ;Else, it can't be better.
(let ((match max)
(imatch i))
(cl-assert (>= match imatch)) <<<<<<<<<<<<<<<<<<<<<<<<<<<<
(cl-assert (function-equal (aref backtrace max)
(aref parent i)))
I cannot reliably reproduce this, and don't understand what causes the
assertion. Any hints?
Here's the patch:
diff --git a/src/profiler.c b/src/profiler.c
index 8247b2e..92d8a0a 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -227,6 +227,9 @@ record_backtrace (log_t *log, EMACS_INT count)
/* Separate counter for the time spent in the GC. */
static EMACS_INT cpu_gc_count;
+/* Separate counter for the memory allocations during GC. */
+static EMACS_INT mem_gc_count;
+
/* The current sampling interval in nanoseconds. */
static EMACS_INT current_sampling_interval;
@@ -451,7 +454,10 @@ DEFUN ("profiler-memory-start", Fprofiler_memory_start, Sprofiler_memory_start,
error ("Memory profiler is already running");
if (NILP (memory_log))
- memory_log = make_log ();
+ {
+ mem_gc_count = 0;
+ memory_log = make_log ();
+ }
profiler_memory_running = true;
@@ -495,6 +501,10 @@ DEFUN ("profiler-memory-log",
more for our use afterwards since we can't rely on its special
pre-allocated keys anymore. So we have to allocate a new one. */
memory_log = profiler_memory_running ? make_log () : Qnil;
+ Fputhash (make_vector (1, QAutomatic_GC),
+ make_fixnum (mem_gc_count),
+ result);
+ mem_gc_count = 0;
return result;
}
@@ -506,10 +516,19 @@ DEFUN ("profiler-memory-log",
malloc_probe (size_t size)
{
if (EQ (backtrace_top_function (), QAutomatic_GC)) /* bug#60237 */
- /* FIXME: We should do something like what we did with `cpu_gc_count`. */
- return;
- eassert (HASH_TABLE_P (memory_log));
- record_backtrace (XHASH_TABLE (memory_log), min (size, MOST_POSITIVE_FIXNUM));
+ /* Special case the malloc-count inside GC because the hash-table
+ code is not prepared to be used while the GC is running.
+ More specifically it uses ASIZE at many places where it does
+ not expect the ARRAY_MARK_FLAG to be set. We could try and
+ harden the hash-table code, but it doesn't seem worth the
+ effort. */
+ mem_gc_count = saturated_add (mem_gc_count, 1);
+ else
+ {
+ eassert (HASH_TABLE_P (memory_log));
+ record_backtrace (XHASH_TABLE (memory_log),
+ min (size, MOST_POSITIVE_FIXNUM));
+ }
}
DEFUN ("function-equal", Ffunction_equal, Sfunction_equal, 2, 2, 0,
next prev parent reply other threads:[~2023-03-04 12:21 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-21 12:24 bug#60237: 30.0.50; tree sitter core dumps when I edebug view a node Mickey Petersen
2022-12-24 7:23 ` Eli Zaretskii
2022-12-24 9:20 ` Yuan Fu
2022-12-29 14:21 ` Mickey Petersen
2023-02-24 23:22 ` Yuan Fu
2023-02-25 7:13 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-25 7:51 ` Eli Zaretskii
2023-02-26 2:01 ` Yuan Fu
2023-02-26 2:37 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-26 6:18 ` Eli Zaretskii
2023-02-26 6:14 ` Eli Zaretskii
2023-02-26 15:16 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-28 14:00 ` Eli Zaretskii
2023-03-01 4:07 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-01 13:27 ` Eli Zaretskii
2023-03-01 14:08 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-01 15:51 ` Eli Zaretskii
2023-03-01 17:39 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-04 12:21 ` Eli Zaretskii [this message]
2023-03-08 16:34 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-10 18:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-10 20:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-11 6:45 ` Eli Zaretskii
2023-03-11 17:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-10 23:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-11 2:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-11 3:29 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-11 3:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-02 5:53 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-02 20:24 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-26 9:41 ` Mickey Petersen
2023-02-27 0:34 ` Yuan Fu
2023-02-27 8:22 ` Mickey Petersen
2023-02-27 9:05 ` Yuan Fu
2023-02-27 14:29 ` Mickey Petersen
2023-02-27 22:37 ` Yuan Fu
2023-02-27 22:45 ` Dmitry Gutov
2023-02-24 23:29 ` Yuan Fu
2023-02-25 7:55 ` Eli Zaretskii
2023-02-26 2:02 ` Yuan Fu
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=83v8jgaeqy.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=60237@debbugs.gnu.org \
--cc=casouri@gmail.com \
--cc=luangruo@yahoo.com \
--cc=mickey@masteringemacs.org \
--cc=monnier@iro.umontreal.ca \
/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.