From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Charalampos Mitrodimas Newsgroups: gmane.emacs.bugs Subject: bug#73800: 30.0.91; infinite loop in c-ts-mode--anchor-prev-sibling Date: Mon, 14 Oct 2024 13:12:10 +0000 Message-ID: <87froyltg5.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31258"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73800@debbugs.gnu.org To: Renato Fernandes de Queiroz Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 14 15:20:27 2024 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 1t0Kzq-0007wA-P9 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Oct 2024 15:20:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0KzD-0001Vj-W8; Mon, 14 Oct 2024 09:19:48 -0400 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 1t0KzC-0001VP-7l for bug-gnu-emacs@gnu.org; Mon, 14 Oct 2024 09:19:46 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0KzB-0000Pq-VV for bug-gnu-emacs@gnu.org; Mon, 14 Oct 2024 09:19:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=2sCjmlaziD7NEWOOvPBbOXouG1w3vgqU3rrPLBbKBAA=; b=eMk+Zt8wAjNr2He3SDDIlC9blMWTWCFZG2Cg8LkayogPvb9z95ciTdy/Eb8bEmJmw9WjBPDXkXtsHLjImiX5nVgnO+U/uUNWnPxtkc06SU4UAzkzbr9/Kp+l7fAYOoqX3Vznhea/gl/b08x1oYyB+uBNjJrUUp0GaEgi79zvjGTZpUwhadMp1gsKtoZ0PYKhP6hOA15Dqfzc3iI1qflaRL9cw5pr+jy2ifYu6trwX4HCwGlWsdCWp3vgMTOC+YqmJXzRLg3DuKCLYWZmY+zhNsMl8yPSu5FYM4MFKMgUIntOhq/u4wTO8CQNj0xmcPBuNSOXC7FjnuE/j3HyEjYbrw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t0KzS-0002Pk-Hk for bug-gnu-emacs@gnu.org; Mon, 14 Oct 2024 09:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Charalampos Mitrodimas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Oct 2024 13:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73800 X-GNU-PR-Package: emacs Original-Received: via spool by 73800-submit@debbugs.gnu.org id=B73800.17289119619118 (code B ref 73800); Mon, 14 Oct 2024 13:20:02 +0000 Original-Received: (at 73800) by debbugs.gnu.org; 14 Oct 2024 13:19:21 +0000 Original-Received: from localhost ([127.0.0.1]:37449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t0Kym-0002Mn-VU for submit@debbugs.gnu.org; Mon, 14 Oct 2024 09:19:21 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:53791) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t0Kyj-0002MB-KZ for 73800@debbugs.gnu.org; Mon, 14 Oct 2024 09:19:19 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 9C98B240027 for <73800@debbugs.gnu.org>; Mon, 14 Oct 2024 15:12:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1728911532; bh=7Hz8IsuEYMcAcBZek60GG0bev16q6+AYYdlu7U45e5A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=gxoTTTJDcBI7zL/gHbCukArgYvJxwrmig7ZPf1QfssxLAGX9ImKIGOKc/PQd2503v evPwnR+C5xwA9Fk64F122Z5vXjQq9WRUSwSv7n0Vk1uTPYzeCS2NZX57h+Wq3Z+bJD OKu3EKO+uIfTdq47tRunHbinZ+WPjjYgc4HIYdTKegTYSQemdWXTfesLO6l9tbUpnF L5ONwXlKNgBTucF3sFQdLAmVWDv48jpV/Ih/f6RskXHyCXYBhRUiDAz9ov5xbI5iNo P+0EEReQbL3jYr82W+2qwy9+28Uex7S3sJpIrT75lAd1ac84bfur+NcNONN01obb2M Eqbddia/x79PA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4XRyLg6Y2vz9rxG; Mon, 14 Oct 2024 15:12:11 +0200 (CEST) In-Reply-To: (Renato Fernandes de Queiroz's message of "Mon, 14 Oct 2024 00:53:56 -0300") 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:293570 Archived-At: Hi, I also had this issue a week but didn't bother looking into it. The proposed fix works. Thanks Renato! C. Mitrodimas Renato Fernandes de Queiroz writes: > Steps to reproduce: > 1. Open a new buffer and load c-ts-mode > 2. insert the following code > > int > main (int argc, char *argv[]) > { > int x; > > a > } > > 3. Move point past 'a' > 4. Hit TAB > > Emacs enters a infinite loop. > > I've set debug-on-quit to t and got > > Debugger entered--Lisp error: (quit) > looking-back("^[[:space:]]*" 283) > c-ts-mode--anchor-prev-sibling(# in 304-337> # 304) > treesit--simple-indent-eval((c-ts-mode--anchor-prev-sibling > # # compound_statement in 281-390> 304)) > treesit-simple-indent(# 304-337> # 304) > apply(treesit-simple-indent (# 304-337> # 304)) > #[128 "\301\302\300!\2\"\207" [treesit-indent-function apply > default-value] 4 advice--forward](# expression_statement in 304-337> # in 281-390> 304) > apply(#[128 "\301\302\300!\2\"\207" [treesit-indent-function apply > default-value] 4 advice--forward] (# expression_statement in 304-337> # in 281-390> 304)) > #f(advice c-ts-base--before-indent :filter-args #[128 > "\301\302\300!\2\"\207" [treesit-indent-function apply > default-value] 4 advice--forward])(# expression_statement in 304-337> # in 281-390> 304) > treesit--indent-1() > treesit-indent() > indent--funcall-widened(treesit-indent) > indent-for-tab-command(nil) > funcall-interactively(indent-for-tab-command nil) > command-execute(indent-for-tab-command) > > > Looking at the function code I saw that a form that shoud be inside the > condition. Probably a typo. The fix is trivial: > > > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el > index 576d715510d..9003201c651 100644 > --- a/lisp/progmodes/c-ts-mode.el > +++ b/lisp/progmodes/c-ts-mode.el > @@ -329,8 +329,8 @@ c-ts-mode--anchor-prev-sibling > ;; and starting the items on the same line as {. > (_ (goto-char (treesit-node-start prev-sibling)) > (if (or (looking-back (rx bol (* whitespace)) > - (line-beginning-position))) > - (null (treesit-node-prev-sibling prev-sibling t)) > + (line-beginning-position)) > + (null (treesit-node-prev-sibling prev-sibling t))) > (setq continue nil) > (setq prev-sibling > (treesit-node-prev-sibling prev-sibling))))))) > > This bug was introduced at e49b479f869. > > > > In GNU Emacs 30.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version > 3.24.43, cairo version 1.18.2) of 2024-10-13 built on carcara > Repository revision: ae75ea62324598654b32ed28bf644ec2bc4c04b2 > Repository branch: emacs-30 > System Description: Arch Linux > > Configured using: > 'configure --with-pgtk --without-gconf --with-sound=no --without-gpm > --without-xaw3d --with-tree-sitter --with-modules --without-libotf > --without-m17n-flt --with-native-compilation' > > Configured features: > ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG > LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK > PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER > WEBP XIM GTK3 ZLIB > > Important settings: > value of $LANG: pt_BR.UTF-8 > locale-coding-system: utf-8-unix > > Major mode: C/* > > Minor modes in effect: > tooltip-mode: t > global-eldoc-mode: t > show-paren-mode: t > electric-indent-mode: t > mouse-wheel-mode: t > tool-bar-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > blink-cursor-mode: t > minibuffer-regexp-mode: t > line-number-mode: t > indent-tabs-mode: t > transient-mark-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > > Load-path shadows: > None found. > > Features: > (shadow sort mail-extr emacsbug message mailcap yank-media puny rfc822 > mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode > mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader > sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils > dired-aux dired dired-loaddefs cl-print debug backtrace find-func > cus-edit pp wid-edit cus-start cus-load time-date c++-ts-mode c-ts-mode > c-ts-common treesit cl-extra noutline outline help-fns radix-tree > help-mode vc-git diff-mode track-changes easy-mmode vc-dispatcher > cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine > cc-vars cc-defs compile text-property-search comint ansi-osc ansi-color > ring comp-run comp-common rx ffap thingatpt url-parse auth-source cl-seq > eieio eieio-core cl-macs icons cl-loaddefs cl-lib password-cache json > subr-x map byte-opt gv bytecomp byte-compile url-vars rmc iso-transl > tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks > lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win > touch-screen pgtk-dnd tool-bar dnd fontset image regexp-opt fringe > tabulated-list replace newcomment text-mode lisp-mode prog-mode register > page tab-bar menu-bar rfn-eshadow isearch easymenu timer select > scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors > frame minibuffer nadvice seq simple cl-generic indonesian philippine > cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao > korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech > european ethiopic indian cyrillic chinese composite emoji-zwj charscript > charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure > cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp > files window text-properties overlay sha1 md5 base64 format env > code-pages mule custom widget keymap hashtable-print-readable backquote > threads dbusbind inotify dynamic-setting system-font-setting > font-render-setting cairo gtk pgtk lcms2 multi-tty move-toolbar > make-network-process native-compile emacs) > > Memory information: > ((conses 16 170635 186225) (symbols 48 13031 15) > (strings 32 39676 2329) (string-bytes 1 1551295) (vectors 16 21497) > (vector-slots 8 267270 42860) (floats 8 55 133) > (intervals 56 1333 679) (buffers 992 18))