GNU bug report logs - #70226
[PATCH] scripts: package: Disable searching with the empty string

Previous Next

Package: guix-patches;

Reported by: Richard Sent <richard <at> freakingpenguin.com>

Date: Sat, 6 Apr 2024 01:12:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 70226 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#70226; Package guix-patches. (Sat, 06 Apr 2024 01:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Richard Sent <richard <at> freakingpenguin.com>:
New bug report received and forwarded. Copy sent to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, rekado <at> elephly.net, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org. (Sat, 06 Apr 2024 01:12:02 GMT) Full text and rfc822 format available.

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

From: Richard Sent <richard <at> freakingpenguin.com>
To: guix-patches <at> gnu.org
Cc: Richard Sent <richard <at> freakingpenguin.com>
Subject: [PATCH] scripts: package: Disable searching with the empty string
Date: Fri,  5 Apr 2024 21:05:53 -0400
Reported in <https://issues.guix.gnu.org/70223>.

* guix/scripts/package.scm (process-query): search operating no longer passes
empty strings to make-regexp to avoid unbounded memory usage.

Change-Id: I8194591f0428c4f88fb101c0226b98f593a55709
---
Hi Guix!

Not sure of the usefulness of small patches like this, but figure it
gives me an excuse to trawl the repo and it's better to send it and
not be needed than the inverse.

I considered adding a --force flag to forcefully allow "" searches,
but since multiple scripts use package.scm and there's a lot of CLI
flags already it didn't seem appropriate to add another one,
particularly if it just results in a system freeze.

 guix/scripts/package.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index a489e06e73..66e5384ddc 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -891,6 +891,8 @@ (define (process-query opts)
 
       (('search _)
        (let* ((patterns (filter-map (match-lambda
+                                      ;; https://issues.guix.gnu.org/70223
+                                      (('query 'search "") #f)
                                       (('query 'search rx) rx)
                                       (_                   #f))
                                     opts))

base-commit: 886ed061d7c57eb9d707b2af2c87402b86becf70
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#70226; Package guix-patches. (Tue, 30 Apr 2024 17:56:03 GMT) Full text and rfc822 format available.

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

From: Dale Mellor <guix-devel-0brg6a <at> rdmp.org>
To: 70226 <at> debbugs.gnu.org
Subject: Fwd: I haven't been able to trigger this bug
Date: Tue, 30 Apr 2024 18:54:40 +0100
Can you give a command-line use-case which actually triggers this bug?

Thanks.






Information forwarded to guix-patches <at> gnu.org:
bug#70226; Package guix-patches. (Tue, 30 Apr 2024 20:21:02 GMT) Full text and rfc822 format available.

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

From: Richard Sent <richard <at> freakingpenguin.com>
To: Dale Mellor <guix-devel-0brg6a <at> rdmp.org>
Cc: 70226 <at> debbugs.gnu.org
Subject: Re: [bug#70226] Fwd: I haven't been able to trigger this bug
Date: Tue, 30 Apr 2024 16:20:10 -0400
Hi!

Dale Mellor <guix-devel-0brg6a <at> rdmp.org> writes:

> Can you give a command-line use-case which actually triggers this bug?

Certainly. I've replicated this issue on guix a1ffa8a with:

$ guix search ""

$ guix system search ""

$ guix home search ""

guix search "" takes ~30 seconds before the bug occurs. (Once the first
result is printed to stdout.) system search and home search are
basically instant. That's probably due to the smaller pool of
candidates.

Working on this a bit more the problem isn't the regex search itself.
Instead, I'm confident it has to do with the highlighting performed by
display-search-results when passed a list containing a "" regex. The
issue does not occur for system search with just the following diff:

--8<---------------cut here---------------start------------->8---
modified   guix/scripts/system/search.scm
@@ -189,5 +189,4 @@ (define (guix-system-search . args)
       (leave-on-EPIPE
        (display-search-results matches (current-output-port)
                                #:print service-type->recutils
-                               #:regexps regexps
                                #:command "guix system search")))))
--8<---------------cut here---------------end--------------->8---

V1 of this patch shouldn't be merged. The bug should be fixed in
display-search-results's highlighting logic instead.

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.




This bug report was last modified 3 days ago.

Previous Next


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