Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault during configuring #41

Closed
nnmm opened this issue Jan 22, 2024 · 8 comments
Closed

Segfault during configuring #41

nnmm opened this issue Jan 22, 2024 · 8 comments

Comments

@nnmm
Copy link

nnmm commented Jan 22, 2024

I have enabled the ghc-musl container in my stack.yaml like so:

docker:
  enable: true
  image: utdemir/ghc-musl:v25-ghc944

The resolver is lts-21.16, which I think should be compatible.

In the cabal file, I've added

    cc-options:
        -static
    ld-options:
        -static -pthread

as recommended by this comment.

However, when running stack build, every build process exits with code -11 (segfault).

Is there something I should do differently?

Full build output

``` ➜ stack build --ghc-options ' -static -optl-static -optl-pthread -fPIC' --no-nix OneTuple > configure Only > configure StateVar > configure appar > configure Progress 4/208

Error: [S-7282]
Stack failed to execute the build
plan.

   While executing the build plan,
   Stack encountered the following
   errors:

   [S-7011]
   While
   building package appar-0.1.8 (scroll
   up to its section to see the
   error) using:
   /home/user/.stack/setup-exe-cache/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/Cabal-simple_6HauvNHV_3.8.1.0_ghc-9.4.7 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/ghc-9.4.7 configure --with-ghc=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-9.4.7 --with-ghc-pkg=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-pkg-9.4.7 --user --package-db=clear --package-db=global --package-db=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/pkgdb --libdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/lib --bindir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/bin --datadir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/share --libexecdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/libexec --sysconfdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/etc --docdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/appar-0.1.8 --htmldir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/appar-0.1.8 --haddockdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/appar-0.1.8 --dependency=base=base-4.17.2.0 --dependency=bytestring=bytestring-0.11.5.2 --exact-configuration --ghc-option=-fhide-source-paths
   Process exited with
   code: ExitFailure (-11)

   [S-7011]
   While
   building package StateVar-1.2.2 (scroll
   up to its section to see the
   error) using:
   /home/user/.stack/setup-exe-cache/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/Cabal-simple_6HauvNHV_3.8.1.0_ghc-9.4.7 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/ghc-9.4.7 configure --with-ghc=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-9.4.7 --with-ghc-pkg=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-pkg-9.4.7 --user --package-db=clear --package-db=global --package-db=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/pkgdb --libdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/lib --bindir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/bin --datadir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/share --libexecdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/libexec --sysconfdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/etc --docdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/StateVar-1.2.2 --htmldir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/StateVar-1.2.2 --haddockdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/StateVar-1.2.2 --dependency=base=base-4.17.2.0 --dependency=stm=stm-2.5.1.0 --dependency=transformers=transformers-0.5.6.2 --exact-configuration --ghc-option=-fhide-source-paths
   Process exited with
   code: ExitFailure (-11)

   [S-7011]
   While
   building package Only-0.1 (scroll
   up to its section to see the
   error) using:
   /home/user/.stack/setup-exe-cache/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/Cabal-simple_6HauvNHV_3.8.1.0_ghc-9.4.7 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/ghc-9.4.7 configure --with-ghc=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-9.4.7 --with-ghc-pkg=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-pkg-9.4.7 --user --package-db=clear --package-db=global --package-db=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/pkgdb --libdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/lib --bindir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/bin --datadir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/share --libexecdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/libexec --sysconfdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/etc --docdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/Only-0.1 --htmldir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/Only-0.1 --haddockdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/Only-0.1 --dependency=base=base-4.17.2.0 --dependency=deepseq=deepseq-1.4.8.0 --exact-configuration --ghc-option=-fhide-source-paths
   Process exited with
   code: ExitFailure (-11)

   [S-7011]
   While
   building package OneTuple-0.4.1.1 (scroll
   up to its section to see the
   error) using:
   /home/user/.stack/setup-exe-cache/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/Cabal-simple_6HauvNHV_3.8.1.0_ghc-9.4.7 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/ghc-9.4.7 configure --with-ghc=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-9.4.7 --with-ghc-pkg=/home/user/.stack/programs/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb/ghc-musl-9.4.7/bin/ghc-pkg-9.4.7 --user --package-db=clear --package-db=global --package-db=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/pkgdb --libdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/lib --bindir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/bin --datadir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/share --libexecdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/libexec --sysconfdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/etc --docdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/OneTuple-0.4.1.1 --htmldir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/OneTuple-0.4.1.1 --haddockdir=/home/user/.stack/snapshots/x86_64-linux-dk85569e7f830e7dc606115fd702e078fb-musl/356fad6ceb12428804ff3010eb5d77595b26288ae84277ce1fb6cc995fc531f4/9.4.7/doc/OneTuple-0.4.1.1 --dependency=base=base-4.17.2.0 --dependency=ghc-prim=ghc-prim-0.9.1 --dependency=template-haskell=template-haskell-2.19.0.0 --exact-configuration --ghc-option=-fhide-source-paths
   Process exited with
   code: ExitFailure (-11)
</p>
</details> 
@benz0li
Copy link
Contributor

benz0li commented Mar 7, 2024

@nnmm Maybe benz0li/ghc-musl#1 (comment) and the following posts have the answer you are looking for.

@benz0li
Copy link
Contributor

benz0li commented Mar 7, 2024

IMHO ld-options: -static -pthread should be sufficient.

@nnmm See also jgm/pandoc#9068 for a similar case.

@nnmm
Copy link
Author

nnmm commented Mar 20, 2024

@benz0li Thanks for your comment. I don't think I'm doing anything all that different from what is suggested in these threads.

I've uploaded a minimal reproducer here: https://github.com/nnmm/stack-musl-repro - I've also tried using a package.yaml instead of a cabal file, but the result is the same (segfault during configuring).

@benz0li
Copy link
Contributor

benz0li commented Mar 20, 2024

On a host with docker installed

docker run --rm -ti glcr.b-data.ch/ghc/ghc-musl:9.8.2 bash

Inside the container

cd /var/tmp/ \
  && git clone https://github.com/nnmm/stack-musl-repro.git \
  && cd stack-musl-repro \
  && cabal build \
  && file /var/tmp/stack-musl-repro/dist-newstyle/build/x86_64-linux/ghc-9.8.2/repro-0.1.0.0/x/repro/build/repro/repro

output:

Cloning into 'stack-musl-repro'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
Config file path source is default config file.
Config file not found: /root/.config/cabal/config
Writing default configuration to /root/.config/cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - repro-0.1.0.0 (exe:repro) (first run)
Configuring executable 'repro' for repro-0.1.0.0..
Warning: The 'license-file' field refers to the file 'LICENSE' which does not
exist.
Preprocessing executable 'repro' for repro-0.1.0.0..
Building executable 'repro' for repro-0.1.0.0..
[1 of 1] Compiling Main             ( app/Main.hs, /var/tmp/stack-musl-repro/dist-newstyle/build/x86_64-linux/ghc-9.8.2/repro-0.1.0.0/x/repro/build/repro/repro-tmp/Main.o )
[2 of 2] Linking /var/tmp/stack-musl-repro/dist-newstyle/build/x86_64-linux/ghc-9.8.2/repro-0.1.0.0/x/repro/build/repro/repro
/var/tmp/stack-musl-repro/dist-newstyle/build/x86_64-linux/ghc-9.8.2/repro-0.1.0.0/x/repro/build/repro/repro: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=ea4b874dedbf8d2efd08f79aedc237e10c465def, with debug_info, not stripped

👉 statically linked

@benz0li
Copy link
Contributor

benz0li commented Mar 20, 2024

You may try the following stack.yaml:

flags: {}
packages:
- '.'
resolver: lts-22.7
# This enables static linking, so that there are no libc problems with the Debian server
docker:
  enable: true
  image: quay.io/benz0li/ghc-musl:9.6.4

@nnmm
Copy link
Author

nnmm commented Mar 20, 2024

@benz0li That works, thanks so much! Seems like the conclusion is that I should have been looking at https://github.com/benz0li/ghc-musl instead of this repo :)

@nnmm
Copy link
Author

nnmm commented Mar 20, 2024

That is, the configuring error is gone - there is still a linker error. But I can create a separate issue for that if needed.

@nnmm nnmm closed this as completed Mar 20, 2024
@benz0li
Copy link
Contributor

benz0li commented Mar 21, 2024

That is, the configuring error is gone - there is still a linker error. But I can create a separate issue for that if needed.

@nnmm You may create an issue at https://github.com/benz0li/ghc-musl.

If possible: Use a Dev Container so it can be easily reproduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants