Subject: Re: bug#76327: 29.4; random segfaults after switch to tree-sitter

From: Evgeniy Dushistov <[email-masked]>
Date: Sun, 16 Feb 2025 15:42:33 +0300

On Sun, Feb 16, 2025 at 11:48:52AM +0200, Eli Zaretskii wrote:
> > Date: Sun, 16 Feb 2025 11:45:38 +0300
> > From:  Evgeniy Dushistov via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <[email-masked]>
> > 
> > Just random crash during editing text (cut or delete text).
> 
> What do you mean by "after switch to tree-sitter"?  What exactly did
> you change and how in order to switch?

For c/c++/python:

(use-package treesit
   :preface 
   (dolist (mapping
           '(
             (c-mode . c-ts-mode)
             (c++-mode . c++-ts-mode)
             (c-or-c++-mode . c-or-c++-ts-mode)
             (python-mode . python-ts-mode)
             ))
    (add-to-list 'major-mode-remap-alist mapping))
)

For rust:
(use-package rust-mode
  :init
  (setq rust-mode-treesitter-derive t)
)

And after two weeks after these changes emacs start crashes.
Usually emacs crashes once every two days.

I suppose this starts after update of some arch linux's packages.
During attempts to fix issue,
I tried two variants, tree-sitter grammar build from source code (with
emacs help) and these packages from Arch distro:
tree-sitter-cpp,tree-sitter-c,tree-sitter-python,tree-sitter-rust

Both variants cause crash.

And last week after update of 3 packages: 
- tree-sitter
- emacs
- tree-sitter-c

emacs works 5 days without crash,
I was hoping that everything was finally fixed,
and even reports that all ok in arch linux issue tracker:
https://gitlab.archlinux.org/archlinux/packaging/packages/emacs/-/issues/6

But today two crashes in the row happens.

> 
> > (gdb) bt full
> > #0  SYMBOL_NAME (sym=0x55555e5d3ba0) at /usr/src/debug/emacs/emacs-29.4/src/lisp.h:1152
> 
> Please show this symbol:
> 

I already closed gdb process, so next time it crashes,
I try what you suggest.

-- 
/Evgeniy