GNU bug report logs - #47678
27.1; `completion-boundaries` assertion failure for file

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Daniel Mendler <mail@HIDDEN>; dated Fri, 9 Apr 2021 20:36:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 47678 <at> debbugs.gnu.org:


Received: (at 47678) by debbugs.gnu.org; 13 Apr 2021 14:44:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 13 10:44:54 2021
Received: from localhost ([127.0.0.1]:60483 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lWKHe-0006Pw-5P
	for submit <at> debbugs.gnu.org; Tue, 13 Apr 2021 10:44:54 -0400
Received: from server.qxqx.de ([178.63.65.180]:37451 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lWKHb-0006Pg-Nx
 for 47678 <at> debbugs.gnu.org; Tue, 13 Apr 2021 10:44:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=On3cP+8cGsnJO/9fXLm7PZzCyzB8QSNNWFgpoJmRJSo=; b=rz9zEf3E3wS8jTMH7ok0U0B1Ri
 PuKc7zOjVQwhYumDd/LV8wUiC+i+2QV7Gfw1/DZ2yVtgCkvgu/GJP7dFD9oumyrlo/Mz55Lpn0Sru
 60iPQSZGLomopANK+/G126F+6qFRDJF4yFD5zrLtg63BkOXVchY6CI9VJTe4+yn2gDs4=;
Subject: Re: bug#47678: 27.1; `completion-boundaries` assertion failure for
 file
To: Stefan Monnier <monnier@HIDDEN>
References: <8d537117-d036-ad84-e013-d98efb3ae0c4@HIDDEN>
 <jwvpmyz9knm.fsf-monnier+emacs@HIDDEN>
 <e87cf9ba-ba66-6c12-5b92-ec390dc4a5c2@HIDDEN>
 <jwv4kga5pjm.fsf-monnier+emacs@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <c62c028e-ccce-7b4a-f6c0-40aa48af1ad8@HIDDEN>
Date: Tue, 13 Apr 2021 16:44:42 +0200
MIME-Version: 1.0
In-Reply-To: <jwv4kga5pjm.fsf-monnier+emacs@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 47678
Cc: 47678 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 4/13/21 2:46 PM, Stefan Monnier wrote:
> The problem has to do with quoting/unquoting: in `C-x C-f` we do not
> quite enter "raw file name" because the name typed by the user is passed
> through `substitute-in-file-name` which expands envvar references (and
> de-doubles dollars for those files whose name looks like an envvar
> reference) and does some truncation (like foo//bar => /bar).

I am aware of that feature and use it but for now I avoided looking into 
how this is exactly implemented :)

> So the `completion-file-name-table` (which completes raw file names) is
> wrapped via `completion-table-with-quoting` and this function has to be
> able to relate the unquoted text back to the quoted text, for example in
> order to convert the boundaries returned by `completion-file-name-table`
> (on the unquoted file name) into the corresponding boundaries that apply
> to the quoted file name.
> 
> This is in general somewhere between hard and impossible.  So if/when we
> get those boundaries wrong (for example) it may lead to misbehavior down
> the line.
> I'd rather not try and guess what those might be.
> I'm just hoping that they're minor enough and rare enough.

Thank you for the detailed explanation.

Ok, but in the case where this issue occurs we already have a somehow 
broken path, especially when moving with the point over the shadowed 
parts. So as a user I would not be worried to much if this does not work.

I hope most assumptions down the line are checked by conditions. However 
given that in this particular case we already have an error we could 
only get more errors at worst down the line?

(Btw, in Vertico I throw out the shadowed paths as soon as I get the 
opportunity (vertico--tidy-shadowed-file) in the same way as Icomplete 
does it if enabled.)

Daniel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47678; Package emacs. Full text available.

Message received at 47678 <at> debbugs.gnu.org:


Received: (at 47678) by debbugs.gnu.org; 13 Apr 2021 12:46:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 13 08:46:33 2021
Received: from localhost ([127.0.0.1]:59254 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lWIR7-0003Bq-2m
	for submit <at> debbugs.gnu.org; Tue, 13 Apr 2021 08:46:33 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34985)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1lWIR5-0003Bc-Nf
 for 47678 <at> debbugs.gnu.org; Tue, 13 Apr 2021 08:46:32 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 30F8E10001F;
 Tue, 13 Apr 2021 08:46:26 -0400 (EDT)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B0BBA100205;
 Tue, 13 Apr 2021 08:46:23 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1618317983;
 bh=S8qGulzPwoz2KswQAhUlkj6FdzKQr5fgR7aFj5VXSUg=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=G4E4s64wOTGyEC1CKVS4Ie4DIZGiLODYs1mVJ7UxDjmDoIfRLRL/pWoaMzlHvxh57
 RKe0K+zUGmEsy5jgEQ9wS1Jlu2FiOMfErSA2xTnAlio81GCpBuYSOfn2slJ8rYyh/7
 R1JgIpfWvcv/9m8a77K1BGpz2GxViZm/9v0L0/a8288kWhPyw4r2CfKX6QdvkhgM4m
 4QgYVmqF5RaP0THtZncYCL2bUxN0d/2X6U7G6FummLnp1UWIuNGyBUZRX8K9mkkpu1
 SBzwevZYO11SBiVt/ckvDl4Ow9PCOI8l6RMMW89SzvC1smDsmR3fnmyoOehnhMNqb9
 Nd2jtoEImqBuw==
Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8101F1201A7;
 Tue, 13 Apr 2021 08:46:23 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
Subject: Re: bug#47678: 27.1; `completion-boundaries` assertion failure for
 file
Message-ID: <jwv4kga5pjm.fsf-monnier+emacs@HIDDEN>
References: <8d537117-d036-ad84-e013-d98efb3ae0c4@HIDDEN>
 <jwvpmyz9knm.fsf-monnier+emacs@HIDDEN>
 <e87cf9ba-ba66-6c12-5b92-ec390dc4a5c2@HIDDEN>
Date: Tue, 13 Apr 2021 08:46:22 -0400
In-Reply-To: <e87cf9ba-ba66-6c12-5b92-ec390dc4a5c2@HIDDEN> (Daniel
 Mendler's message of "Tue, 13 Apr 2021 06:04:24 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.011 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 47678
Cc: 47678 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Thank you for looking into this. I hope this will not lead to further
> problems, it is mostly an edge case when moving around the cursor and the
> path at that point is not really valid? What kind of issues could happen?
> I can always enter some invalid/shadowed path ///, /~~~/, ~/~/~, which do
> not make problems (at least with this patch).

The problem has to do with quoting/unquoting: in `C-x C-f` we do not
quite enter "raw file name" because the name typed by the user is passed
through `substitute-in-file-name` which expands envvar references (and
de-doubles dollars for those files whose name looks like an envvar
reference) and does some truncation (like foo//bar => /bar).

So the `completion-file-name-table` (which completes raw file names) is
wrapped via `completion-table-with-quoting` and this function has to be
able to relate the unquoted text back to the quoted text, for example in
order to convert the boundaries returned by `completion-file-name-table`
(on the unquoted file name) into the corresponding boundaries that apply
to the quoted file name.

This is in general somewhere between hard and impossible.  So if/when we
get those boundaries wrong (for example) it may lead to misbehavior down
the line.
I'd rather not try and guess what those might be.
I'm just hoping that they're minor enough and rare enough.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47678; Package emacs. Full text available.

Message received at 47678 <at> debbugs.gnu.org:


Received: (at 47678) by debbugs.gnu.org; 13 Apr 2021 04:04:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 13 00:04:35 2021
Received: from localhost ([127.0.0.1]:58694 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lWAHz-0004Od-N4
	for submit <at> debbugs.gnu.org; Tue, 13 Apr 2021 00:04:35 -0400
Received: from server.qxqx.de ([178.63.65.180]:42479 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lWAHx-0004OF-Ak
 for 47678 <at> debbugs.gnu.org; Tue, 13 Apr 2021 00:04:34 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=GOAn4zZPaOQR8MymFfmFSptEcKeNnt75S/yBr3ZOOOY=; b=sbNQzbsEOqUymuQ8cFzDGlBILF
 dtl56zXJAkF9dLchh7zBPlj7T0y2eMWVHsGyqRl+3zt8wXi7G7jMZbOC4r/kdLm1++I2rr1kRetXQ
 rTUNta7oq1/hN+LemS9wpS+0Xx87a5hveNaWfYrFPK2Z1Atr45ppg9nighT911PMddLc=;
Subject: Re: bug#47678: 27.1; `completion-boundaries` assertion failure for
 file
To: Stefan Monnier <monnier@HIDDEN>
References: <8d537117-d036-ad84-e013-d98efb3ae0c4@HIDDEN>
 <jwvpmyz9knm.fsf-monnier+emacs@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <e87cf9ba-ba66-6c12-5b92-ec390dc4a5c2@HIDDEN>
Date: Tue, 13 Apr 2021 06:04:24 +0200
MIME-Version: 1.0
In-Reply-To: <jwvpmyz9knm.fsf-monnier+emacs@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 47678
Cc: 47678 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 4/13/21 1:28 AM, Stefan Monnier wrote:
>> 2. Press "C-x C-f"
>> 3. Enter the path "~//"
>> 4. Move the point between the slashes, "~/|/"
>> 5. Press "C-."
> 
> Thanks!
> [ It would have helped to say what happens for you there.  ]

Yes, I wrote "assertion failure". Sorry for not having been more precise 
(out of bounds error/assertion failure and pasted a stack trace, I will 
do that the next time). On Emacs 28 it seems to only give an out of 
bounds error directly. But from the patch below you identified the 
relevant line. I had seen ufull/ustring/usomething in the error message.

> I installed the patch below, which seems to fix the immediate problem
> I managed to reproduce, but it might lead to further problems down
> the road.

Thank you for looking into this. I hope this will not lead to further 
problems, it is mostly an edge case when moving around the cursor and 
the path at that point is not really valid? What kind of issues could 
happen? I can always enter some invalid/shadowed path ///, /~~~/, ~/~/~, 
which do not make problems (at least with this patch).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47678; Package emacs. Full text available.

Message received at 47678 <at> debbugs.gnu.org:


Received: (at 47678) by debbugs.gnu.org; 12 Apr 2021 23:28:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 12 19:28:11 2021
Received: from localhost ([127.0.0.1]:58321 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lW5yV-0005oZ-7u
	for submit <at> debbugs.gnu.org; Mon, 12 Apr 2021 19:28:11 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43315)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1lW5yT-0005oM-T0
 for 47678 <at> debbugs.gnu.org; Mon, 12 Apr 2021 19:28:10 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 549034416F9;
 Mon, 12 Apr 2021 19:28:04 -0400 (EDT)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5C683440FB4;
 Mon, 12 Apr 2021 19:28:02 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1618270082;
 bh=TKY6x0CwFJwUMINFda4dBIpgMcS8ZUJbuBNJAmiaP9k=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=j2zX4vsHBdSu5VBQvfEtr6jFrBDj04WJScV6FHVMyDP3tFYryOw4ASSGbwqXtv9B1
 6Xlpk4GVxxxTONm8WmjL5eXHdhuIc2T4Wu93lBVirZldeoI/JVc+KnZunoOZ+xuH5b
 0XgC86I4S0It9WAfNdN0mGDm5Qcn3kP9spAotjmCZRroDruLIXUYiNm9wJ8iW/UGDW
 cHkM9tFXG03dTqSAuFRMIxL4Z9/qESRa5Z9fjvbhyg+GvJSkzdOs3amU+S1BHVgtf6
 YoUOJstvD3ZU9ZJIzw2/RdYcnifJ0SNxFV3OkCuO4UqAEVJQtvBtJYvQKriwST3o1Z
 XheJwJ/2MEUYw==
Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 194CD120434;
 Mon, 12 Apr 2021 19:28:02 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
Subject: Re: bug#47678: 27.1; `completion-boundaries` assertion failure for
 file
Message-ID: <jwvpmyz9knm.fsf-monnier+emacs@HIDDEN>
References: <8d537117-d036-ad84-e013-d98efb3ae0c4@HIDDEN>
Date: Mon, 12 Apr 2021 19:28:00 -0400
In-Reply-To: <8d537117-d036-ad84-e013-d98efb3ae0c4@HIDDEN> (Daniel
 Mendler's message of "Fri, 9 Apr 2021 22:35:28 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.108 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 47678
Cc: 47678 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> 2. Press "C-x C-f"
> 3. Enter the path "~//"
> 4. Move the point between the slashes, "~/|/"
> 5. Press "C-."

Thanks!
[ It would have helped to say what happens for you there.  ]

> The function `test-boundaries' should determine the completion
> boundaries correctly. I assume that the function `completion-boundaries'
> should never fail with an error.

[ From this I can guess that you maybe got some kind of error?
  Including a backtrace or the text of the error or some
  description of the error would have been helpful.  ]

I installed the patch below, which seems to fix the immediate problem
I managed to reproduce, but it might lead to further problems down
the road.


        Stefan


diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5f594679ca..c900b0d7ce 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -488,8 +488,17 @@ completion-table-with-quoting
              (qsuffix (cdr action))
              (ufull (if (zerop (length qsuffix)) ustring
                       (funcall unquote (concat string qsuffix))))
-             (_ (cl-assert (string-prefix-p ustring ufull)))
-             (usuffix (substring ufull (length ustring)))
+             ;; If (not (string-prefix-p ustring ufull)) we have a problem:
+             ;; the unquoting the qfull gives something "unrelated" to ustring.
+             ;; E.g. "~/" and "/" where "~//" gets unquoted to just "/" (see
+             ;; bug#47678).
+             ;; In that case we can't even tell if we're right before the
+             ;; "/" or right after it (aka if this "/" is from qstring or
+             ;; from qsuffix), which which usuffix to use is very unclear.
+             (usuffix (if (string-prefix-p ustring ufull)
+                          (substring ufull (length ustring))
+                        ;; FIXME: Maybe "" is preferable/safer?
+                        qsuffix))
              (boundaries (completion-boundaries ustring table pred usuffix))
              (qlboundary (car (funcall requote (car boundaries) string)))
              (qrboundary (if (zerop (cdr boundaries)) 0 ;Common case.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47678; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Apr 2021 20:35:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 09 16:35:41 2021
Received: from localhost ([127.0.0.1]:51031 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lUxqv-0002ow-7V
	for submit <at> debbugs.gnu.org; Fri, 09 Apr 2021 16:35:41 -0400
Received: from lists.gnu.org ([209.51.188.17]:36430)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lUxqs-0002on-NL
 for submit <at> debbugs.gnu.org; Fri, 09 Apr 2021 16:35:39 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:55546)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>)
 id 1lUxqr-0000P7-6v
 for bug-gnu-emacs@HIDDEN; Fri, 09 Apr 2021 16:35:38 -0400
Received: from server.qxqx.de ([2a01:4f8:121:346::180]:38647 helo=mail.qxqx.de)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>)
 id 1lUxqn-00035D-HZ
 for bug-gnu-emacs@HIDDEN; Fri, 09 Apr 2021 16:35:36 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Date:
 Message-ID:Subject:From:To:Sender:Reply-To:Cc:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=T/0GKJw5zYS0Fg6PPyRyzguMtSVIW1RSbzIWF52XpgI=; b=pqleKi+ajGSKO7MUhZFb9YmAdT
 XKpQMBvX1lYdyM5pehzOqgCvfxvIOi+RvarURpJHC3A5qdKh0iwpUNRJ1zUFC6sKCt5kKT16J7aVj
 /CF3rDYuw/4zKlSG21Gg/9fXZwjfPEOPnh2X8f1hzuBZgfVPOJhRn1AR3H+Ts2M08h7g=;
To: bug-gnu-emacs@HIDDEN
From: Daniel Mendler <mail@HIDDEN>
Subject: 27.1; `completion-boundaries` assertion failure for file
Message-ID: <8d537117-d036-ad84-e013-d98efb3ae0c4@HIDDEN>
Date: Fri, 9 Apr 2021 22:35:28 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Received-SPF: pass client-ip=2a01:4f8:121:346::180;
 envelope-from=mail@HIDDEN; helo=mail.qxqx.de
X-Spam_score_int: -41
X-Spam_score: -4.2
X-Spam_bar: ----
X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

1. Start emacs -Q, evaluate the following code:

~~~
(defun test-boundaries ()
   (interactive)
   (let* ((contents (minibuffer-contents-no-properties))
          (pt (max 0 (- (point) (minibuffer-prompt-end))))
          (before (substring contents 0 pt))
          (after (substring contents pt)))
     (completion-boundaries before
                            minibuffer-completion-table
                            minibuffer-completion-predicate
                            after)))
(global-set-key (kbd "C-.") #'test-boundaries)
~~~

2. Press "C-x C-f"
3. Enter the path "~//"
4. Move the point between the slashes, "~/|/"
5. Press "C-."

The function `test-boundaries' should determine the completion
boundaries correctly. I assume that the function `completion-boundaries'
should never fail with an error. This bug is hard to trigger with
default completion but occurs more often with continuously updating
interactive completion systems like "Vertico", when entering some path
and moving the point around.

I've got confirmation that the bug is still present in Emacs 28, but I 
have not tested this myself.

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, 
cairo version 1.16.0)
  of 2021-02-09, modified by Debian built on 3df710f593d9
Repository revision: b0229d4bbaea7fcddffced393512c650212830db
Repository branch: deb/emacs/d/sid/master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)

Recent messages:
test-boundaries [2 times]
Quit
completion--some: Assertion failed: (string-prefix-p ustring ufull) [2 
times]
Quit
(basic)
nil [2 times]
completion--some: Assertion failed: (string-prefix-p ustring ufull) [2 
times]
Quit [2 times]
next-line: End of buffer
Mark set

Configured using:
  'configure --build x86_64-linux-gnu --prefix=/usr
  --sharedstatedir=/var/lib --libexecdir=/usr/lib
  --localstatedir=/var/lib --infodir=/usr/share/info
  --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 
--enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
  --with-sound=alsa --without-gconf --with-mailutils --build
  x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
  --libexecdir=/usr/lib --localstatedir=/var/lib
  --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
  --with-pop=yes
 
--enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
  --with-sound=alsa --without-gconf --with-mailutils --with-cairo
  --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
  'CFLAGS=-g -O2
  -fdebug-prefix-map=/emacs/emacs=. -fstack-protector-strong -Wformat
  -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
  -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
JSON PDUMPER LCMS2 GMP

Important settings:
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils edmacro kmacro vc-git
diff-mode easymenu easy-mmode cl-loaddefs cl-lib tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
x multi-tty make-network-process emacs)




Acknowledgement sent to Daniel Mendler <mail@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#47678; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 13 Apr 2021 15:00:02 UTC

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