GNU bug report logs -
#59574
29.0.50; Emacs crashes when using tree-sitter-based mode in an empty buffer
Previous Next
Reported by: Eli Zaretskii <eliz <at> gnu.org>
Date: Fri, 25 Nov 2022 15:05:02 UTC
Severity: normal
Found in version 29.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #13 received at 59574-done <at> debbugs.gnu.org (full text, mbox):
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Fri, 25 Nov 2022 19:18:09 -0800
> Cc: 59574 <at> debbugs.gnu.org
>
> > There's also something strange in treesit_record_change: when it is called
> > for the first time in a buffer which was empty and you insert one character,
> > we bypass the updating of visible_beg and visible_end fields of the Lisp
> > parser object, because XTS_PARSER (lisp_parser)->tree is NULL. But it looks
> > to me that we should still update these two fields regardless, no? Only the
> > call to treesit_tree_edit_1 needs the tree. (I thought that maybe this lack
> > of update explains the assertion, but even if I move the condition to guard
> > only treesit_tree_edit_1, the assertion still happens, so I guess my
> > hypothesis eats dust.)
>
> We don’t need to update visible_beg/end in treesit_record_change if tree is NULL, because visible_beg/end represents the range of buffer that the tree sees, so if there is no tree, visible_beg/end can be considered uninitialized. However you are right about needing to update visible_beg/end, but in treesit_ensure_position_synced (I renamed it to treesit_sync_visible_region): that’s where we ensure visible_beg/end equals to BUF_BEGV_BYTE/friends.
>
> The problem is we don’t update visible_beg/end for the very first parse, when tree is NULL.
>
> I also added some comments, hopefully they sufficiently explain everything.
Thanks, the problem is gone, so I'm closing the bug.
This bug report was last modified 2 years and 234 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.