GNU bug report logs - #69952
[PATCH] Support pdumping compiled queries by dumping their source

Previous Next

Package: emacs;

Reported by: Sergey Vinokurov <serg.foo <at> gmail.com>

Date: Sat, 23 Mar 2024 03:29:01 UTC

Severity: normal

Tags: patch

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #38 received at 69952 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: serg.foo <at> gmail.com, Daniel Colascione <dancol <at> dancol.org>,
 69952 <at> debbugs.gnu.org
Subject: Re: bug#69952: [PATCH] Support pdumping compiled queries by dumping
 their source
Date: Sun, 21 Apr 2024 23:04:47 -0700

> On Apr 21, 2024, at 10:47 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Sun, 21 Apr 2024 16:41:54 -0700
>> Cc: Daniel Colascione <dancol <at> dancol.org>,
>> serg.foo <at> gmail.com,
>> 69952 <at> debbugs.gnu.org
>> 
>> 
>> 
>>> On Apr 20, 2024, at 9:53 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>> 
>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>> Date: Sat, 20 Apr 2024 15:50:36 -0700
>>>> Cc: Daniel Colascione <dancol <at> dancol.org>,
>>>> serg.foo <at> gmail.com,
>>>> 69952 <at> debbugs.gnu.org
>>>> 
>>>>>>> On Apr 13, 2024, at 12:41 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>>>> 
>>>>>>>> And I have a question: what happens if the pdumper file dumped with
>>>>>>>> tree-sitter available is loaded by an Emacs session in which
>>>>>>>> tree-sitter is not available?  That can happen on Windows, for
>>>>>>>> example, if the tree-sitter library or the grammar library required
>>>>>>>> for recomputing the query is not available.  I think we need some code
>>>>>>>> to prevent Emacs from crashing on startup in that case.
>>>>>> 
>>>>>> Yeah, being able to dump queries is certainly nice. There will be problems if the Emacs session that later loads the query either have a different grammar version loaded, or a difference grammar library for the same language, or outright doesn’t have tree-sitter like Eli mentioned. I don’t know if they are big enough problems to give up dumping queries, though.
>>>>> 
>>>>> Giving up: no.  But I think the code which loads the queries from the
>>>>> pdumper file should be protected from crashing in those cases.  Can
>>>>> you suggest how to do that?
>>>> 
>>>> Would Emacs crash? If the dump file just contains the query (which is a string), then Emacs would just compile the query with treesit-query-compile, it could fail (due to the reasons I mentioned), but shouldn’t crash Emacs.
>>> 
>>> Can Emacs compile a query if the tree-sitter shared library and/or the
>>> grammar library is not available?
>> 
>> No. You need both tree-sitter library and the grammar library.
> 
> That's what I thought.  So starting Emacs in that case will attempt to
> call a function from the tree-sitter library, and will segfault,
> right?  If so, we should have some protection in the code in
> pdumper.c that loads queries, which tests that tree-sitter is
> availabale, and if not does something to prevent the segfault, like
> not loading the query, perhaps?

Right, it can use Ftreesit_available_p (we can define a C equivalent if pdumper can’t call lisp), and decide whether to compile the query or just keep the query as a string, or signal an error?

Yuan





This bug report was last modified 302 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.