From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60237: 30.0.50; tree sitter core dumps when I edebug view a node Date: Fri, 10 Mar 2023 13:28:20 -0500 Message-ID: References: <9FCDA5B7-D216-45B1-8051-35B05633BEFB@gmail.com> <83sfeukwsb.fsf@gnu.org> <574817C4-3FD8-43EA-B53C-B2BCB60A6D0A@gmail.com> <83mt51j6mv.fsf@gnu.org> <83a60xhou5.fsf@gnu.org> <83mt4wfvpd.fsf@gnu.org> <83fsaofp0x.fsf@gnu.org> <83v8jgaeqy.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7462"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: luangruo@yahoo.com, casouri@gmail.com, mickey@masteringemacs.org, 60237@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 10 19:29:28 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pahUe-0001jn-DU for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Mar 2023 19:29:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pahUG-0005Ev-7z; Fri, 10 Mar 2023 13:29:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pahUE-0005Ei-V0 for bug-gnu-emacs@gnu.org; Fri, 10 Mar 2023 13:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pahUE-0001Fb-Mf for bug-gnu-emacs@gnu.org; Fri, 10 Mar 2023 13:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pahUE-0005J6-AW for bug-gnu-emacs@gnu.org; Fri, 10 Mar 2023 13:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Mar 2023 18:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60237 X-GNU-PR-Package: emacs Original-Received: via spool by 60237-submit@debbugs.gnu.org id=B60237.167847290920345 (code B ref 60237); Fri, 10 Mar 2023 18:29:02 +0000 Original-Received: (at 60237) by debbugs.gnu.org; 10 Mar 2023 18:28:29 +0000 Original-Received: from localhost ([127.0.0.1]:55865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pahTh-0005I5-96 for submit@debbugs.gnu.org; Fri, 10 Mar 2023 13:28:29 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:22190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pahTg-0005Hr-Dz for 60237@debbugs.gnu.org; Fri, 10 Mar 2023 13:28:28 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id BC4DF1000BD; Fri, 10 Mar 2023 13:28:22 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2495510009E; Fri, 10 Mar 2023 13:28:21 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1678472901; bh=1qB58S5PowsNUOOC/xGuhE+6BysUsR2sMFcqEU0NrQE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=U1SnFXKTjN81ltSZqUHb7VIuIy/Ayw0bE9gIqlgQpHHQmqPfaJyMH8JORdvSoyWOf do52adA//EpB1q1gXm8HvZcYPKLRe2T5doh+GSNEm7b0hy+8vFgBmzJnhUY4ClfbOh zgLxZgHhSHIvoR3nYEbL3fGvgXlzynKENFdWU5AHqewq0y/8hnxjZA9ctJLUil/5Od 3lCh+QKqHZ7Z9yO3f/MUVZ+wTIsRaKSsPVsgltgDAthF4Hg3MzJHEozYLJDJ6JTSaN lgLWfYZ0x4c6ZUd+S20+aZPKTkNjmu1Eufgj3zXFLO7h2YMJSd1aLrAcGBDBgaXN0P aNRTUtN23re4A== Original-Received: from ceviche (modemcable137.21-80-70.mc.videotron.ca [70.80.21.137]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EA51312324B; Fri, 10 Mar 2023 13:28:20 -0500 (EST) In-Reply-To: (Stefan Monnier's message of "Wed, 08 Mar 2023 11:34:14 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257712 Archived-At: >> 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? > > Hmm... I just took a look but can't see neither why your change would > be more likely to trigger this error than the existing code for the > `cpu` case, nor why this assertion should always be true. I can imagine corner cases where this could trigger, but they all involve funny business where we change `profiler-max-stack-depth` during a single profiling run (I think you'd need to write ad-hoc ELisp code for that). The only other explanation I can see is that we somehow end up with a backtrace that includes `Automatic_GC` somewhere not at the top (maybe this can happen with a `post-gc-hook`?). If you manage to reproduce it, I'd be interested to know the value of `backtrace` and `parent` when the assertion fails (and maybe just save the `log` hash-table so we can look at it). It might be a symptom of another bug. And I still can't see how/why this would happen only for the `memory` profiler and not for the `cpu` profiler, so I assume it can also happen for the `cpu` profiler and we've just been lucky not to bump into it yet. This said, I think the patch below should fix it for the `cpu` profiler and a similar change should fix it for your patch (and the patch is arguably right in the sense that without this `nil` entry, the backtrace entry created for `Automatic_GC` is not really complete). Stefan diff --git a/src/profiler.c b/src/profiler.c index 8247b2e90c6..295c47a2acd 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -423,7 +423,7 @@ DEFUN ("profiler-cpu-log", Fprofiler_cpu_log, Sprofiler_cpu_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. */ cpu_log = profiler_cpu_running ? make_log () : Qnil; - Fputhash (make_vector (1, QAutomatic_GC), + Fputhash (CALLN (Fvector, QAutomatic_GC, Qnil), make_fixnum (cpu_gc_count), result); cpu_gc_count = 0;