Subject: guix should not ask me to report a bug if it fails due to running out of memory

From: "Zack Weinberg" <[email-masked]>
Date: Sun, 28 Jul 2024 16:02:33 +0000

If a guix operation fails due to running out of memory, it's reported
to the user as an internal error, instructing them to report a bug to
bug-guix.  For example:

# guix pull
Updating channel 'guix' from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
Building from this channel:
  guix      https://git.savannah.gnu.org/git/guix.git	46a64c7
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
 module-import  2KiB                  56KiB/s 00:00 ▕██████████████████▏ 100.0%
 module-import-compiled  1.3MiB      2.4MiB/s 00:01 ▕██████████████████▏ 100.0%
 compute-guix-derivation  1KiB       877KiB/s 00:00 ▕██████████████████▏ 100.0%
Computing Guix derivation for 'x86_64-linux'... \
GC Warning: Failed to expand heap by 8388608 bytes
[previous line repeats 79 more times]
GC Warning: Failed to expand heap by 69632 bytes
GC Warning: Out of Memory! Heap size: 402 MiB. Returning NULL!
Warning: Unwind-only out of memory exception; skipping pre-unwind handler.
guix pull: error: You found a bug: the program
'/gnu/store/6pckga173mjbpfz7a2bl93h4gimd8fp5-compute-guix-derivation'
failed to compute the derivation for Guix (version:
"46a64c7fdd057283063aae6df058579bb07c4b6a"; system: "x86_64-linux";
host version: "e4aabf42b33346849cb565199cfafc49d4f0aeff";
pull-version: 1).  Please report the COMPLETE output above by email to
<[email-masked]>.

The fact that it ran the computer out of RAM is *not* a bug per se --
perhaps we could talk about reducing "guix pull"'s memory
requirements, but that's a big hairy design challenge probably.

But that means there *is* a bug: the fatal exception handler should
have a dedicated message for out-of-memory conditions, directing the
user to add more swap or something, instead of reporting a bug.

For reference, this is a server with this much RAM as of when I ran
the above command:

# free -h
               total        used        free      shared  buff/cache   available
Mem:           969Mi       229Mi       557Mi          0B       319Mi       739Mi
Swap:          613Mi        39Mi       574Mi

Enabling zswap did not permit a successful "guix pull" but increasing
the amount of available swap space to 2Gi did.  (Memory overcommit is
disabled.  Peak memory usage, with the increased swap, was roughly
1.5Gi.)

zw