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 15:56:56 -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="7666"; 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 21:58:10 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 1pajoX-0001g9-U1 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Mar 2023 21:58:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pajoR-0005ar-Q6; Fri, 10 Mar 2023 15:58:03 -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 1pajoQ-0005ai-O6 for bug-gnu-emacs@gnu.org; Fri, 10 Mar 2023 15:58: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 1pajoQ-00039u-Fl for bug-gnu-emacs@gnu.org; Fri, 10 Mar 2023 15:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pajoQ-0001IX-20 for bug-gnu-emacs@gnu.org; Fri, 10 Mar 2023 15:58: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 20:58: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.16784818274920 (code B ref 60237); Fri, 10 Mar 2023 20:58:02 +0000 Original-Received: (at 60237) by debbugs.gnu.org; 10 Mar 2023 20:57:07 +0000 Original-Received: from localhost ([127.0.0.1]:55974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pajnX-0001HH-9F for submit@debbugs.gnu.org; Fri, 10 Mar 2023 15:57:07 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pajnV-0001Go-SK for 60237@debbugs.gnu.org; Fri, 10 Mar 2023 15:57:06 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 24E621000BD; Fri, 10 Mar 2023 15:57:00 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 241EC10009E; Fri, 10 Mar 2023 15:56:58 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1678481818; bh=M5dhhG5ZXLWCacILZR/sEReQkvGdFUE3PDX2Ri1ReUw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MFSR4xDmlO9UOBgR6q9eVQDqvJcCGw52t/UEPt+t3Jx1qz4jwXiI5wj3m+4xgIcsn H23BMuX46FX+bgVdbgjBNQfaG/3yFB6sywXuL4YOALaGhOZ/+lHRMYnxhnOlGyRrzc zTK3JVw0DKj7+WyIe0fcneQvF6CQ9TgVfV/V83wgQ6IRYQJlCUNgqPkHrEbMSYO9+D 0b0hlvkRmEpJFVgwd/L2aPBnmyAi2VV/kocHK7PdWXB1UeR6A0IiEqLGz6tno0HNve U6Ks1sWvFzxLjBpdPzW61IsF8sI9OlLzmN2LgzO1wKyvVEKe3edgktfjbCCwFB5+gJ /9B/qUaJmRqYQ== Original-Received: from pastel (unknown [216.154.34.24]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B8FD2120E8A; Fri, 10 Mar 2023 15:56:57 -0500 (EST) In-Reply-To: (Stefan Monnier's message of "Fri, 10 Mar 2023 13:28:20 -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:257720 Archived-At: I pushed your change to `master`, with my patch on top. Plus a few other patches to reduce redundancy a bit and fix a FIXME. Stefan Stefan Monnier [2023-03-10 13:28:20] wrote: >>> 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;