all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Yuan Fu <casouri@gmail.com>, Eli Zaretskii <eliz@gnu.org>,
	Denis Zubarev <dvzubarev@yandex.ru>,
	"67977@debbugs.gnu.org" <67977@debbugs.gnu.org>
Subject: bug#67977: 30.0.50; tree-sitter: Emacs crashes when accessing treesit-nodes in a narrowed buffer
Date: Tue, 2 Jan 2024 15:34:35 +0200	[thread overview]
Message-ID: <8702f943-54c4-47ee-b9eb-c9540ed4043a@gutov.dev> (raw)
In-Reply-To: <jwv34vg4a98.fsf-monnier+emacs@gnu.org>

On 02/01/2024 06:46, Stefan Monnier wrote:
>> diff --git a/lisp/treesit.el b/lisp/treesit.el
>> index 264b95dc3a3..46ebadcf057 100644
>> --- a/lisp/treesit.el
>> +++ b/lisp/treesit.el
>> @@ -1150,7 +1150,7 @@ treesit--pre-syntax-ppss
>>       (if (and new-start (< new-start start))
>>           (progn
>>             (setq treesit--syntax-propertize-start nil)
>> -          (cons new-start end))
>> +          (cons (max new-start (point-min)) end))
>>         nil)))
>>
>>   ;;; Indent
> Sounds fine to me.  Often the caller of `syntax-propertize-function`
> should widen beforehand, but in cases like `mmm-mode` indeed that's not
> always desired.

Thank you, I've pushed that fix.

>> Or maybe syntax-propertize itself should have a protection against going
>> outside of bounds:
>>
>> diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
>> index e35992298a6..61a9e79b59c 100644
>> --- a/lisp/emacs-lisp/syntax.el
>> +++ b/lisp/emacs-lisp/syntax.el
>> @@ -431,7 +431,7 @@ syntax-propertize
>>                        (if (or (null new)
>>                                (and (>= (car new) start) (<= (cdr new) end)))
>>                            nil
>> -                       (setq start (car new))
>> +                       (setq start (max (car new) (point-min)))
>>                          (setq end (cdr new))
>>                          ;; If there's been a change, we should go through
>>                            the
>>                          ;; list again since this new position may
> I think it's preferable for the expand-region function to perform this
> test.  We could `cl-assert` that it's within BOB...EOB to help catch
> such bugs (and clarify who's in charge of avoiding the problem), but
> maybe we can mention it in the docstring.  But I personally consider
> that anything that sends buffer positions is in charge to make sure that
> they're within bounds, unless specifically documented otherwise, so
> documenting it seems redundant.

Fair enough.

And I'll leave the question of adding cl-assert (or not) to you or 
others. Though might be that the signaled args-out-of-range will be a 
reliable indicator of this situation anyway.





  reply	other threads:[~2024-01-02 13:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 23:18 bug#67977: 30.0.50; tree-sitter: Emacs crashes when accessing treesit-nodes in a narrowed buffer Denis Zubarev
2023-12-23  7:26 ` Eli Zaretskii
2023-12-23  8:08   ` Yuan Fu
2023-12-24  3:00     ` Yuan Fu
2023-12-24  7:11       ` Eli Zaretskii
2023-12-27  4:15         ` Yuan Fu
2023-12-27 12:57           ` Eli Zaretskii
2023-12-28  8:07             ` Yuan Fu
2023-12-28 11:44               ` Dmitry Gutov
2023-12-28 13:53                 ` Eli Zaretskii
2023-12-28 16:16                   ` Dmitry Gutov
2023-12-29  7:00                     ` Yuan Fu
2023-12-29 12:48                       ` Dmitry Gutov
2023-12-30  4:35                         ` Yuan Fu
2023-12-30 16:21       ` Denis Zubarev
2023-12-30 20:23         ` Yuan Fu
2023-12-31  0:08           ` Dmitry Gutov
2023-12-31 10:39           ` Denis Zubarev
2023-12-31 12:56             ` Eli Zaretskii
2023-12-31 13:40             ` Dmitry Gutov
2024-01-02  4:46               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-02 13:34                 ` Dmitry Gutov [this message]
2024-01-02 22:58                   ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8702f943-54c4-47ee-b9eb-c9540ed4043a@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=67977@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=dvzubarev@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.