Subject: Re: bug#71681: 29.3.50; tree-sitter crash

From: Stefan Kangas <[email-masked]>
Date: Fri, 28 Feb 2025 18:00:39 -0800

Yuan Fu <[email-masked]> writes:

>> On Jun 30, 2024, at 11:49 PM, Juri Linkov <[email-masked]> wrote:
>>
>>> I reduced the crash to a signal and pushed the fix to emacs-30.
>>> Next I’ll make sure the signal is properly handled.
>>
>> Now with the latest emacs-30 at the commit b2c966f8396
>> there is another problem:
>>
>> 0. emacs -Q
>> 1. eval: (setq backtrace-on-redisplay-error t)
>> 2. eval: (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
>> 3. C-x v L
>> 4. in the *vc-change-log* buffer move point to the commit b2c966f8396
>> 5. type D
>>
>> Warning (error): Error in a redisplay Lisp hook.
>> See buffer *Redisplay-trace*
>>
>> Error: treesit-node-outdated (#<treesit-node-outdated>)
>>  treesit--font-lock-fontify-region-1(#<treesit-node-outdated> #<treesit-compiled-query> 99654 99975 nil nil)
>>  treesit-font-lock-fontify-region(99654 99975 nil)
>>  font-lock-fontify-syntactically-region(99654 99975 nil)
>>  font-lock-default-fontify-region(99654 99974 nil)
>>  font-lock-fontify-region(99654 99974)
>>  font-lock-ensure(99654 99974)
>>  diff-syntax-fontify-hunk(122 539 t)
>>  diff-syntax-fontify(122 539)
>>  diff--font-lock-syntax(539)
>>  font-lock-fontify-keywords-region(1 539 nil)
>>  font-lock-default-fontify-region(1 539 nil)
>>  font-lock-fontify-region(1 539)
>>  jit-lock--run-functions(1 539)
>>  jit-lock-fontify-now(1 539)
>>  jit-lock-function(1)
>>  vc-diff-finish(#<buffer *vc-diff*> nil nil)
>>  vc-exec-after(#f(compiled-function () #<bytecode -0xcd6e6e57937525e>))
>>  log-view-diff-common(1 1 t)
>>  log-view-diff-changeset(1 1)
>>  funcall-interactively(log-view-diff-changeset 1 1)
>>  command-execute(log-view-diff-changeset)
>
> Yes, that’s what meant by “reduced crash to signal”. The crash is fixed, but I
> need to fix the font-lock code so it can handle the signal gracefully (or don’t
> cause the signal from the first place). It’s not yet clear to me why does
> treesit-font-lock-fontify-region end up using an outdated node for query.

Did you make any progress with the second part of this fix?