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: Wed, 08 Mar 2023 11:34:14 -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="2184"; 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 Wed Mar 08 17:35:25 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 1pZwlA-0000M7-Cv for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Mar 2023 17:35:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZwkq-0003zi-TP; Wed, 08 Mar 2023 11:35: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 1pZwkp-0003zC-0x for bug-gnu-emacs@gnu.org; Wed, 08 Mar 2023 11:35:03 -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 1pZwko-0005TJ-OP for bug-gnu-emacs@gnu.org; Wed, 08 Mar 2023 11:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZwko-0000wf-AV for bug-gnu-emacs@gnu.org; Wed, 08 Mar 2023 11:35: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: Wed, 08 Mar 2023 16:35: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.16782932743583 (code B ref 60237); Wed, 08 Mar 2023 16:35:02 +0000 Original-Received: (at 60237) by debbugs.gnu.org; 8 Mar 2023 16:34:34 +0000 Original-Received: from localhost ([127.0.0.1]:50048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZwkM-0000vj-DC for submit@debbugs.gnu.org; Wed, 08 Mar 2023 11:34:34 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZwkJ-0000vP-Ms for 60237@debbugs.gnu.org; Wed, 08 Mar 2023 11:34:32 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 764931000BD; Wed, 8 Mar 2023 11:34:25 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C3521100054; Wed, 8 Mar 2023 11:34:23 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1678293263; bh=9YQBIQNv7Lhd3UQTHhyb1vtF0h3ImGHygBLwyt2x9jM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=k3ExxyS+ko3gY+e7FdbA2nT9gROFPyI1VTEYm3f00qoCjWOFOV9AexN9gYfO7HRLA VzkFx+lCF2wyrUOS1gvoMZjn760/jozMLfylip+R2tLho/1FJTZsCjCs9kYmhjmWUR tdWTGJ02RXzrNbVU2gl9dfplMikW71KtdnBw3TjyMwmxpPZscgYvF6qJuCZNL6QeBq ilutAKrhOxEzacXB7FvtGcGAi6d78qupNBfxCdhDf/7NeblViFYUsgRmLkxHiMKvQu qql5pEFDCoNu/CRWdmx6Jy3S9mHyWfEAoxbETl4Tpm/UUOx0HyPvMC8D9qjP2Hjnme yzVdSKqIRrKDQ== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 070C812327D; Wed, 8 Mar 2023 11:34:23 -0500 (EST) In-Reply-To: <83v8jgaeqy.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 04 Mar 2023 14:21:41 +0200") 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:257548 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. IOW, I'm going to have to find the original author to ask him what he was thinking back then. > Here's the patch: Looks good. Just one nitpick: > 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); Here we should increase by `size` rather than by 1. Stefan