Subject: Re: bug#47115: Failure building grub-img.png when reconfiguring

From: Jack Hill <[email-masked]>
Date: Sun, 14 Mar 2021 17:14:14 -0400 (EDT)

Trying to document some more information in the hopes that others can 
reproduce this bug.

On the host that fails:

$ guix describe
Generation 7    Mar 14 2021 16:14:58    (current)
   guix d4e29f3
     repository URL: https://git.savannah.gnu.org/git/guix.git
     branch: master
     commit: d4e29f3628ad0c7576d7cab659d7fcc19d21999a

jackhill@kalessin ~$ cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
stepping	: 9
microcode	: 0x1
cpu MHz		: 2599.990
cache size	: 16384 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm 
constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq 
vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes 
xsave avx f16c rdrand hypervisor lahf_lm cpuid_fault pti ssbd ibrs ibpb 
tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust smep erms 
xsaveopt arat md_clear
vmx flags	: vnmi preemption_timer posted_intr invvpid ept_x_only 
ept_1gb flexpriority apicv tsc_offset vtpr mtf vapic ept vpid 
unrestricted_guest vapic_reg vid
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass 
l1tf mds swapgs itlb_multihit srbds
bogomips	: 5199.98
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
stepping	: 9
microcode	: 0x1
cpu MHz		: 2599.990
cache size	: 16384 KB
physical id	: 1
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca 
cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm 
constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq 
vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes 
xsave avx f16c rdrand hypervisor lahf_lm cpuid_fault pti ssbd ibrs ibpb 
tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust smep erms 
xsaveopt arat md_clear
vmx flags	: vnmi preemption_timer posted_intr invvpid ept_x_only 
ept_1gb flexpriority apicv tsc_offset vtpr mtf vapic ept vpid 
unrestricted_guest vapic_reg vid
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass 
l1tf mds swapgs itlb_multihit srbds
bogomips	: 5199.98
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

jackhill@kalessin ~$ cat /config.scm
;; This is an operating system configuration for a VM image.
;; Modify it as you see fit and instantiate the changes by running:
;;
;;   guix system reconfigure /etc/config.scm
;;

(use-modules (gnu) (guix))
(use-service-modules networking ssh)
(use-package-modules bootloaders certs linux
                      package-management)

(define vm-image-motd (plain-file "motd" "
\x1b[1;37mThis is the GNU system.  Welcome!\x1b[0m

This instance of Guix is a template for virtualized environments.
You can reconfigure the whole system by adjusting /etc/config.scm
and running:

   guix system reconfigure /etc/config.scm

Run '\x1b[1;37minfo guix\x1b[0m' to browse documentation.

\x1b[1;33mConsider setting a password for the 'root' and 'guest' \
accounts.\x1b[0m
"))

(operating-system
  (host-name "kalessin")
  (timezone "America/New_York")
  (locale "en_US.utf8")
  (initrd-modules (cons "virtio_scsi" %base-initrd-modules))

  ;; Label for the GRUB boot menu.
  (label (string-append "GNU Guix " (package-version guix)))

  (firmware '())

  ;; Below we assume /dev/vda is the VM's hard disk.
  ;; Adjust as needed.
  (bootloader (bootloader-configuration
               (bootloader grub-bootloader)
               (target "/dev/vda")
               (terminal-outputs '(console))))
  (file-systems (cons (file-system
                       (mount-point "/")
                       (device (file-system-label "kalessin-btrfs"))
                       (type "btrfs")
 		      (options "compress=zstd"))
                      %base-file-systems))

  (users (cons* (user-account
                 (name "jackhill")
                 (comment "Jack Hill")
                 (group "users")
                 (supplementary-groups '("wheel" "netdev")))
                %base-user-accounts))

  ;; Our /etc/sudoers file.  Since 'guest' initially has an empty password,
  ;; allow for password-less sudo.
  (sudoers-file (plain-file "sudoers" "\
root ALL=(ALL) ALL
%wheel ALL=NOPASSWD: ALL\n"))

  (packages (append (list btrfs-progs nss-certs)
                    %base-packages))

  (services
   (append (list (service openssh-service-type
 			 (openssh-configuration
 			  (password-authentication? #f)
 			  (authorized-keys
 			   `(("jackhill" ,(local-file "/id_ed25519.pub")
                                          ,(local-file "/home/jackhill/tamago.ssh-key")
                                          ,(local-file "/home/jackhill/id_ed25519.pub"))))))

                 ;; Use the DHCP client service rather than NetworkManager.
                 (service dhcp-client-service-type))
 	  (modify-services %base-services
 			   (guix-service-type config =>
 					      (guix-configuration
 					       (inherit config)
 					       (extra-options
 						'("--disable-deduplication"))
 					       (authorized-keys
 						(cons
 						 (local-file "/home/jackhill/alperton-guix-key.pub")
 						 %default-authorized-guix-keys))))))))

ckhill@kalessin ~$ sudo -E guix system -v3 reconfigure /config.scm
The following derivations will be built:
    /gnu/store/cnl0pbld58rq4zn0l347ssawdxpcs2hg-grub.cfg.drv
    /gnu/store/07xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv
building /gnu/store/07xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv...
Backtrace:
            2 (primitive-load "/gnu/store/larqpc2wjhnc6jmj4885k8lynd1?")
In gnu/build/svg.scm:
      53:6  1 (svg->png _ "/gnu/store/vmldvxllh07k641wmbnlz3migga29r?" ?)
In unknown file:
            0 (rsvg-handle-render-cairo #<rsvg-handle 7ffff5b60150> #)

ERROR: In procedure rsvg-handle-render-cairo:
Wrong type (expecting finalized smob): #<cairo-context 7ffff5b60090>
builder for `/gnu/store/07xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv' failed with exit code 1
build of /gnu/store/07xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv failed
View build log at '/var/log/guix/drvs/07/xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv.bz2'.
cannot build derivation `/gnu/store/cnl0pbld58rq4zn0l347ssawdxpcs2hg-grub.cfg.drv': 1 dependencies couldn't be built
guix system: error: build of `/gnu/store/cnl0pbld58rq4zn0l347ssawdxpcs2hg-grub.cfg.drv' failed

jackhill@kalessin ~$ free -m
               total        used        free      shared  buff/cache   available
Mem:           2994         122         505           0        2366        2783
Swap:             0           0           0

Now on the host where it suceeds:

$ guix describe
Generation 112	Mar 14 2021 16:30:34	(current)
   guix-at-duke 2a57b7c
     repository URL: https://gitlab.oit.duke.edu/jackhill/guix-at-duke.git
     branch: master
     commit: d4e29f3628ad0c7576d7cab659d7fcc19d21999a
   nonguix 54b8358
     repository URL: https://gitlab.com/nonguix/nonguix
     branch: master
     commit: 54b83587669b5df5fe36bce058f4f2cf34d8a63c
   guix d4e29f3
     repository URL: https://git.savannah.gnu.org/git/guix.git
     branch: master
     commit: d4e29f3628ad0c7576d7cab659d7fcc19d21999a

jackhill@alperton ~$ cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i7 CPU       L 640  @ 2.13GHz
stepping	: 5
microcode	: 0x7
cpu MHz		: 2623.174
cache size	: 4096 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 11
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt aes lahf_lm pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flush_l1d
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips	: 4256.16
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i7 CPU       L 640  @ 2.13GHz
stepping	: 5
microcode	: 0x7
cpu MHz		: 2416.981
cache size	: 4096 KB
physical id	: 0
siblings	: 2
core id		: 2
cpu cores	: 2
apicid		: 4
initial apicid	: 4
fpu		: yes
fpu_exception	: yes
cpuid level	: 11
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt aes lahf_lm pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flush_l1d
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips	: 4256.16
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

jackhill@alperton ~$ cat repos/guix-configs/alperton/config.scm
;; This is an operating system configuration template
;; for a "desktop" setup with GNOME and Xfce where the
;; root partition is encrypted with LUKS.

(use-modules (gnu) (gnu system nss) (gnu services xorg)
 	     (gnu packages linux)
 	     (nongnu packages linux)
 	     (nongnu system linux-initrd)
 	     (srfi srfi-1))
(use-service-modules ;; afs
 		     cups desktop docker kerberos sddm)
(use-package-modules certs gnome kerberos printers
 		     scanner security-token
 		     wm)

(operating-system
  (host-name "alperton")
  (timezone "America/New_York")
  (locale "en_US.utf8")

  (bootloader (bootloader-configuration
 	      (bootloader grub-bootloader)
 	      (target "/dev/sda")))

  ;; Specify a mapped device for the encrypted root partition.
  ;; The UUID is that returned by 'cryptsetup luksUUID'.
  (mapped-devices
   (list (mapped-device
 	 (source (uuid "9cfdc1d9-d062-4269-9cbb-9cb518c4cf4c"))
 	 (target "alperton_btrfs")
 	 (type luks-device-mapping))))

  (file-systems (cons
 		(file-system
 		 (device (uuid "179969de-85a9-4e95-ba44-79566c492eb5"))
 		 (mount-point "/")
 		 (type "btrfs")
 		 (flags '(no-atime))
 		 (options "compress=zstd")
 		 (dependencies mapped-devices))
 		%base-file-systems))

  (swap-devices (list "/root/swap"))

  (users (cons (user-account
 	       (name "jackhill")
 	       (comment "Jack Hill")
 	       (group "users")
 	       (supplementary-groups '("wheel" "netdev"
 				       ;"docker"
 				       "audio" "lp" "video"))
 	       (home-directory "/home/jackhill"))
 	      %base-user-accounts))

  ;; This is where we specify system-wide packages.
  (packages (cons* nss-certs         ;for HTTPS access
 		  btrfs-progs
 		  fuse-exfat
 		  bluez
 		  mit-krb5
 		  sway
 		  gvfs              ;for user mounts
 		  %base-packages))

  ;; Add GNOME and/or Xfce---we can choose at the log-in
  ;; screen with F1.  Use the "desktop" services, which
  ;; include the X11 log-in service, networking with
  ;; NetworkManager, and more.
  (services (cons* (service gnome-desktop-service-type)
 		  (bluetooth-service)
 		  ;; (service docker-service-type)
 		  (simple-service 'custom-udev-rules udev-service-type (list sane-backends libu2f-host))
 		  (screen-locker-service swaylock)
 		  (service sddm-service-type)
 		  (service cups-service-type
 			   (cups-configuration
 			    (web-interface? #true)))
 		  (service krb5-service-type
 			  (krb5-configuration
 			   (default-realm "HCOOP.NET")
 			   (forwardable? #t)
 			   ))
 		  ;; (service afs-client-service-type)
 		  (modify-services (remove (lambda (service)
 					     (eq? (service-kind service) gdm-service-type))
 					   %desktop-services)
 				   (guix-service-type
 				    config =>
 				    (guix-configuration
 				     (inherit config)
 				     (authorized-keys
 				      (cons*
 				       (local-file "../keys/libre-01-guix-key.pub")
 				       (local-file "../keys/libre-02-guix-key.pub")
 				       %default-authorized-guix-keys)))))))

  (kernel linux)
  (kernel-arguments '("quite"
 		     "zswap.enabled=1" "zswap.compressor=zstd"
 		     "zswap.max_pool_percent=50" "zswap.zpool=z3fold"))
  (initrd-modules (cons* "zstd" "z3fold"
 			%base-initrd-modules))
  (initrd microcode-initrd)
  (firmware (append (list linux-firmware iwlwifi-firmware broadcom-bt-firmware)
 		   %base-firmware))

  ;; Allow resolution of '.local' host names with mDNS.
  (name-service-switch %mdns-host-lookup-nss))

jackhill@alperton ~$ free -m
               total        used        free      shared  buff/cache   available
Mem:           3735        2087         209         368        1438        1076
Swap:          8191        2696        5495

Clearly there as some differences between these hosts. However, the same 
derivation and png file:

jackhill@alperton ~$ guix build /gnu/store/07xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv
/gnu/store/vmldvxllh07k641wmbnlz3migga29rfn-grub-image.png
jackhill@alperton ~$ cat /gnu/store/07xw2pp63xin4c4y8ndrcdn3n8z1vmx2-grub-image.png.drv 
Derive([("out","/gnu/store/vmldvxllh07k641wmbnlz3migga29rfn-grub-image.png","","")],[("/gnu/store/6k0b8k9cl9gcrg603cxva0qnwbxv55xs-guile-rsvg-2.18.1-0.05c6a2f.drv",["out"]),("/gnu/store/b5nnbpgkvgdpzgvj67539ylcaqacj90l-guile-3.0.2.drv",["out"]),("/gnu/store/hb2q1683r8x8n28dyvr4gvdgkhmssq8q-guix-artwork-2f2fe74-checkout.drv",["out"]),("/gnu/store/kvpdmjknxqjm9k6gi2c9bijkrmk9n944-module-import-compiled.drv",["out"]),("/gnu/store/rcl324yiq7a56rwkqwgqx097dwc5mgni-guile-cairo-1.11.2.drv",["out"])],["/gnu/store/ih9cbxl2qwn9bn2yfmr2g40w7p7yafic-module-import","/gnu/store/larqpc2wjhnc6jmj4885k8lynd19fl4m-grub-image.png-builder"],"x86_64-linux","/gnu/store/0m0vd873jp61lcm4xa3ljdgx381qa782-guile-3.0.2/bin/guile",["--no-auto-compile","-L","/gnu/store/ih9cbxl2qwn9bn2yfmr2g40w7p7yafic-module-import","-L","/gnu/store/0b39xp6kndr95k6rccbp8ijwvsrkygvd-guile-rsvg-2.18.1-0.05c6a2f/share/guile/site/3.0","-L","/gnu/store/vjn7ygzzqshvsfzck8hq5lp5pfrr2xp5-guile-cairo-1.11.2/share/guile/site/3.0","-C","/gnu/store/pk1r70b4gxn9fsd53glr8alqz5h1kk65-module-import-compiled","-C","/gnu/store/0b39xp6kndr95k6rccbp8ijwvsrkygvd-guile-rsvg-2.18.1-0.05c6a2f/lib/guile/3.0/site-ccache","-C","/gnu/store/vjn7ygzzqshvsfzck8hq5lp5pfrr2xp5-guile-cairo-1.11.2/lib/guile/3.0/site-ccache","/gnu/store/larqpc2wjhnc6jmj4885k8lynd19fl4m-grub-image.png-builder"],[("out","/gnu/store/vmldvxllh07k641wmbnlz3migga29rfn-grub-image.png"),("preferLocalBuild","1")])

is used on both systems, and after copying the successfully built png file 
to "bad" host, it is used successfully.

This has been a difficult problem for me to track down, since the only way 
I know to reproduce it is with guix system reconfigure (guix system build 
isn't even enough). I think it would make troubleshooting easier if I 
could generate the problematic derivations outside of guix system 
reconfigure. At this point, I'm not sure what additional information would 
be relevant. Are there any additional places I should look?

Thanks!
Jack