[PATCH] scripts: package: Disable searching with the empty string

  • Open
  • quality assurance status badge
2 participants
  • Dale Mellor
  • Richard Sent
Submitted by
Richard Sent
Richard Sent wrote on 6 Apr 03:05 +0200
(address . guix-patches@gnu.org)(name . Richard Sent)(address . richard@freakingpenguin.com)

* 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(+)

Toggle diff (17 lines)
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))

base-commit: 886ed061d7c57eb9d707b2af2c87402b86becf70
Dale Mellor wrote on 30 Apr 19:54 +0200
Fwd: I haven't been able to trigger this bug
(address . 70226@debbugs.gnu.org)
Can you give a command-line use-case which actually triggers this bug?

Richard Sent wrote on 30 Apr 22:20 +0200
(name . Dale Mellor)(address . guix-devel-0brg6a@rdmp.org)(address . 70226@debbugs.gnu.org)

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

Toggle quote (2 lines)
> 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

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:

Toggle snippet (9 lines)
modified guix/scripts/system/search.scm
@@ -189,5 +189,4 @@ (define (guix-system-search . args)
(display-search-results matches (current-output-port)
#:print service-type->recutils
- #:regexps regexps
#:command "guix system search")))))

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.
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 70226@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 70226
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch