all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70223: Search for empty string uses excessive memory
@ 2024-04-05 20:16 Athena Martin via Bug reports for GNU Guix
  2024-04-06  1:13 ` Richard Sent
  2024-04-30 17:46 ` bug#70223: I haven't been able to trigger this bug Dale Mellor
  0 siblings, 2 replies; 7+ messages in thread
From: Athena Martin via Bug reports for GNU Guix @ 2024-04-05 20:16 UTC (permalink / raw)
  To: 70223

[-- Attachment #1: Type: text/plain, Size: 636 bytes --]

I ran

  $ guix system search ""

A minute later, my desktop froze. I did it again with htop running and
saw that memory usage climbed right up to the full 32GiB in my
(swapless) machine. Right as it reached that point, the freeze recurred.

I haven't tested but it seems likely this same issue would occur with
guix search and guix home search as well. The best fix I can think of
is to refuse to search for an empty string without --force.

I looked for the following on issues.guix and found no existing bug:

empty string
empty search
guix search
system search
home search
service search
package search
""
''

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#70226] [PATCH] scripts: package: Disable searching with the empty string
@ 2024-04-06  1:05   ` Richard Sent
  2024-04-30 17:54     ` [bug#70226] Fwd: I haven't been able to trigger this bug Dale Mellor
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Sent @ 2024-04-06  1:05 UTC (permalink / raw)
  To: 70226
  Cc: Richard Sent, Christopher Baines, Josselin Poiret,
	Ludovic Courtès, Mathieu Othacehe, Ricardo Wurmus,
	Simon Tournier, Tobias Geerinckx-Rice

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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#70223: Search for empty string uses excessive memory
  2024-04-05 20:16 bug#70223: Search for empty string uses excessive memory Athena Martin via Bug reports for GNU Guix
@ 2024-04-06  1:13 ` Richard Sent
  2024-04-30 17:46 ` bug#70223: I haven't been able to trigger this bug Dale Mellor
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Sent @ 2024-04-06  1:13 UTC (permalink / raw)
  To: Athena Martin; +Cc: 70223

Patch submitted at https://issues.guix.gnu.org/70226.

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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70223: I haven't been able to trigger this bug
  2024-04-05 20:16 bug#70223: Search for empty string uses excessive memory Athena Martin via Bug reports for GNU Guix
  2024-04-06  1:13 ` Richard Sent
@ 2024-04-30 17:46 ` Dale Mellor
  2024-04-06  1:05   ` [bug#70226] [PATCH] scripts: package: Disable searching with the empty string Richard Sent
  2024-04-30 17:55   ` bug#70223: Scratch: " Dale Mellor
  1 sibling, 2 replies; 7+ messages in thread
From: Dale Mellor @ 2024-04-30 17:46 UTC (permalink / raw)
  To: 70223

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

Thanks.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#70226] Fwd: I haven't been able to trigger this bug
  2024-04-06  1:05   ` [bug#70226] [PATCH] scripts: package: Disable searching with the empty string Richard Sent
@ 2024-04-30 17:54     ` Dale Mellor
  2024-04-30 20:20       ` Richard Sent
  0 siblings, 1 reply; 7+ messages in thread
From: Dale Mellor @ 2024-04-30 17:54 UTC (permalink / raw)
  To: 70226

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

Thanks.






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70223: Scratch: Re: I haven't been able to trigger this bug
  2024-04-30 17:46 ` bug#70223: I haven't been able to trigger this bug Dale Mellor
  2024-04-06  1:05   ` [bug#70226] [PATCH] scripts: package: Disable searching with the empty string Richard Sent
@ 2024-04-30 17:55   ` Dale Mellor
  1 sibling, 0 replies; 7+ messages in thread
From: Dale Mellor @ 2024-04-30 17:55 UTC (permalink / raw)
  To: 70223

Sorry, sent to wrong bug.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#70226] Fwd: I haven't been able to trigger this bug
  2024-04-30 17:54     ` [bug#70226] Fwd: I haven't been able to trigger this bug Dale Mellor
@ 2024-04-30 20:20       ` Richard Sent
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Sent @ 2024-04-30 20:20 UTC (permalink / raw)
  To: Dale Mellor; +Cc: 70226

Hi!

Dale Mellor <guix-devel-0brg6a@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.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-30 22:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-05 20:16 bug#70223: Search for empty string uses excessive memory Athena Martin via Bug reports for GNU Guix
2024-04-06  1:13 ` Richard Sent
2024-04-30 17:46 ` bug#70223: I haven't been able to trigger this bug Dale Mellor
2024-04-06  1:05   ` [bug#70226] [PATCH] scripts: package: Disable searching with the empty string Richard Sent
2024-04-30 17:54     ` [bug#70226] Fwd: I haven't been able to trigger this bug Dale Mellor
2024-04-30 20:20       ` Richard Sent
2024-04-30 17:55   ` bug#70223: Scratch: " Dale Mellor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.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.