Subject: bug#53296: Intermittent segfaults when parsing (?) custom package from repo.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 17 Jan 2022 16:42:23 +0100

Hi,

[email-masked] skribis:

> Recently working on a package, I have been encounting intermittent segfault
> during a build.
>
> The segfault seems to only occur when I have some error in my code that causes
> a crash, and the segfaults tend to cluster, appearing unexpectedly for a few
> build attempts, and then disappearing right as I think they are reproducible
> and try to grab an strace or something. Unfortunately, that's about the extent
> of information I have been able to gleen.
>
> The latest segfault happened with the attached package definition. Note, the
> offending code is at line 77, where I forgot to remove a docstring from a
> variable that used to be a procedure.

Here’s how I tried (and failed) to reproduce the segfault:

--8<---------------cut here---------------start------------->8---
$ find /tmp/test
/tmp/test
/tmp/test/gnu
/tmp/test/gnu/packages
/tmp/test/gnu/packages/jsoftware.scm

$ guix build -L /tmp/test jsoftware
/tmp/test/gnu/packages/jsoftware.scm:76:0: warning: source expression failed to match any pattern
guix build: error: jsoftware: nekonata pako

$ guix build -f /tmp/test/gnu/packages/jsoftware.scm 
/tmp/test/gnu/packages/jsoftware.scm:76:0: error: (define ijconsole "G-exp script that detects AVX/AVX2 support at runtime and executes jconsole\n  with the appropriate libj.so and profile.ijs." (with-imported-modules (quote ((guix cpu) (guix memoization) (guix profiling) (guix sets) (srfi srfi-26))) (program-file "ijconsole" (gexp (begin (use-modules ((guix cpu) #:select (cpu-flags current-cpu)) ((guix sets) #:select (set-contains?)) ((srfi srfi-26) #:select (cute))) (define %basedir (dirname (dirname (current-filename)))) (let* ((jconsole (string-append %basedir "/libexec/j/jconsole")) (cpu-has-flag? (cute set-contains? (cpu-flags (current-cpu)) <>)) (libj (format #f "~a/lib/j/libj~a.so" %basedir (cond ((cpu-has-flag? "avx2") "-avx2") ((cpu-has-flag? "avx") "-avx") (else "")))) (jprofile (string-append %basedir "/etc/j/profile.ijs"))) (apply execl jconsole "ijconsole" "-lib" libj "-jprofile" jprofile (cdr (command-line))))))))): source expression failed to match any pattern

$ guix describe
Generacio 201   Jan 12 2022 23:15:13    (nuna)
  guix 0052c3b
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 0052c3b0458fba32920a1cfb48b8311429f0d6b5
--8<---------------cut here---------------end--------------->8---

Is there another way to reproduce it?

Is the ‘LD_LIBRARY_PATH’ variable set on your system?

Thanks,
Ludo’.