From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu 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: Sat, 25 Feb 2023 15:13:44 +0800 Message-ID: <874jra43pz.fsf@yahoo.com> References: <87o7rx7xml.fsf@masteringemacs.org> <9FCDA5B7-D216-45B1-8051-35B05633BEFB@gmail.com> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5704"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: eliz@gnu.org, Mickey Petersen , 60237@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 25 08:17:26 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 1pVoo9-00017a-8f for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Feb 2023 08:17:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVono-0006C4-Oj; Sat, 25 Feb 2023 02:17: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 1pVonn-0006Be-5k for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2023 02:17: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 1pVonm-0005oi-TO for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2023 02:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVonm-0002kp-HK for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2023 02:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Feb 2023 07:17: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.167730937510521 (code B ref 60237); Sat, 25 Feb 2023 07:17:02 +0000 Original-Received: (at 60237) by debbugs.gnu.org; 25 Feb 2023 07:16:15 +0000 Original-Received: from localhost ([127.0.0.1]:38875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVon1-0002jd-Af for submit@debbugs.gnu.org; Sat, 25 Feb 2023 02:16:15 -0500 Original-Received: from sonic303-47.consmr.mail.ne1.yahoo.com ([66.163.188.173]:38160) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVomz-0002jO-Lr for 60237@debbugs.gnu.org; Sat, 25 Feb 2023 02:16:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1677309367; bh=+1Bz8zfA6UlS9Jzxs5vSZ6i7EmQnZsgvYVLxc33MQsE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=L/wTLLwq98eNj2wMyx9tUIEPblW2XGobJX8RsDyhYlXQc6ySqYSfLfS7kVX1qYWbY334Hic8Bc/sk9Y4CqrzSrMw9Z8/eatT4afgPXvABrzUad1avTz4pHn8bkIpF27O6MIDlOhL4Ch+5OhsWy6CuaWI8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Vh_OMZDr1iM9iaNpKaKKKAfNBkxezuVSq3tMlUySTBUQn4VaQgaaQYbd5A2utxtccIO9uergDEx nYFqgsoU2zzm3vDS4almeaUOEcyeuT8BT0Bg6xTHZKb6uzxY1ztF.g.J504xuB4cIzIzwgYvIv59 ykPKvLKT_G.cHdHXqYN73WQ_bav1mEE1MUgFV9AUWzA1u.9NywbwGmhO0rPVw4BnwJ974xAPUXSS LYUXrdqvnPdL2ipEvuYDon4mgisuKcoAGYo2R0Fq.xO27svn0GCeTxWkZIDfd5TbucvU4jP_TvWb qRlnjtlbzRl138BIF_A4p1MI0oEvehuGVS8RWBAA6GQrO1YO0Fjm3qjns___jr8a8H8ofcaaExBr 3ipSl.IrFwq61eSHMyi535woPN.pfZNUvcy2xTaRGVgRcbNmki3KXFMaCKc.bvztoUegEYH9IXBJ Nne9eXZhN2fjdXGk2ApNuHi6Ve1rEpT8wtkCTBg284 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ne1.yahoo.com with HTTP; Sat, 25 Feb 2023 07:16:07 +0000 Original-Received: by hermes--production-sg3-9fc5746c8-28mz5 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c88e501bdc54bef5386833608372a38f; Sat, 25 Feb 2023 07:14:05 +0000 (UTC) In-Reply-To: <9FCDA5B7-D216-45B1-8051-35B05633BEFB@gmail.com> (Yuan Fu's message of "Fri, 24 Feb 2023 15:22:00 -0800") X-Mailer: WebService/1.1.21221 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:256690 Archived-At: Yuan Fu writes: > * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) > frame #0: 0x0000000100250f3d emacs`ASIZE(array=0x00000001a1889245) at lisp.h:1768:3 > 1765 ASIZE (Lisp_Object array) > 1766 { > 1767 ptrdiff_t size = XVECTOR (array)->header.size; > -> 1768 eassume (0 <= size); > 1769 return size; > 1770 } > 1771 This is a bug inside the profiler: if it is trying to hook into xmalloc, it should not call anything that can call ASIZE, because GC modifies the mark bits inside the vector header, which happen to be stored in the `size' field, and GC has been able to call xmalloc ever since the mark stack stuff was installed. Since you assume 0 <= size, LLVM is generating one of its favorite instructions, ud2, in response to a situation you told the compiler would never happen. Make sure that situation doesn't happen!! > Target 0: (emacs) stopped. > (lldb) bt > * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) > * frame #0: 0x0000000100250f3d emacs`ASIZE(array=0x00000001a1889245) at lisp.h:1768:3 > frame #1: 0x0000000100250e5e emacs`get_backtrace(array=0x00000001a1889245) at eval.c:4193:28 > frame #2: 0x00000001003001ce emacs`record_backtrace(log=0x00000001a1887d68, count=64) at profiler.c:162:3 > frame #3: 0x000000010030016d emacs`malloc_probe(size=64) at profiler.c:509:3 > frame #4: 0x0000000100204e6d emacs`xmalloc(size=64) at alloc.c:760:3 > frame #5: 0x0000000100e6c0c9 libtree-sitter.0.dylib`ts_subtree_release + 158 > frame #6: 0x0000000100e6f004 libtree-sitter.0.dylib`ts_tree_delete + 44 > frame #7: 0x0000000100307379 emacs`treesit_delete_parser(lisp_parser=0x00000001a2c0f0e0) at treesit.c:1182:3 > frame #8: 0x0000000100212c1b emacs`cleanup_vector(vector=0x00000001a2c0f0e0) at alloc.c:3179:5 > frame #9: 0x00000001002124c9 emacs`sweep_vectors at alloc.c:3254:5 > frame #10: 0x000000010020c777 emacs`gc_sweep at alloc.c:7430:3 > frame #11: 0x000000010020bb67 emacs`garbage_collect at alloc.c:6262:3 > frame #12: 0x000000010020b706 emacs`maybe_garbage_collect at alloc.c:6107:5 > frame #13: 0x00000001002b4bea emacs`maybe_gc at lisp.h:5591:5 BTW, where do you see GC being called from treesit_delete_parser? What I see is a bug in the profiler; it should use some other data structure to store its backtraces, when its xmalloc hook is called. GC has historically never called xmalloc, so the profiler will likely crash upon growing the mark stack as well. I guess another important question is why ts_delete_parser is calling xmalloc.