haskell/zlib

unknown symbol `inflateReset'

Closed this issue · 10 comments

ii8 commented

I get the following build error when building a haskell program that uses the wai-app-static package. I'm not 100% sure this is the correct place to report this error but it does look like the problem lies in the zlib part which I'm guessing is used by wai-app-static.

wai-app-static > ghc-9.4.4: /home/dude/.stack/snapshots/x86_64-linux/28ecbfa8d3a82c3a295081db670ff5e7002fda74f91285cbe3eab1ed42167def/9.4.4/lib/x86_64-linux-ghc-9.4.4/zlib-0.6.3.0-GcrDIyj6sLL3AXxniz0lAg/HSzlib-0.6.3.0-GcrDIyj6sLL3AXxniz0lAg.o: unknown symbol `inflateReset'
wai-app-static > ghc-9.4.4: Could not load Object Code /home/dude/.stack/snapshots/x86_64-linux/28ecbfa8d3a82c3a295081db670ff5e7002fda74f91285cbe3eab1ed42167def/9.4.4/lib/x86_64-linux-ghc-9.4.4/zlib-0.6.3.0-GcrDIyj6sLL3AXxniz0lAg/HSzlib-0.6.3.0-GcrDIyj6sLL3AXxniz0lAg.o.
wai-app-static > <no location info>: error: unable to load unit `zlib-0.6.3.0'

A relevant piece of information here is that I am trying to link statically, using stack and musl libc on alpine linux.

Sorry but this is not actionable without a reproducer, ideally in a form of CI job.

ii8 commented

Here is how to reproduce it using docker, to do it as a CI job I'll have to do some reading first and it seems to take a very long time for anything to run.

Create a file called Dockerfile with these contents:

FROM alpine:latest

RUN apk upgrade --no-cache && \
    apk add --no-cache binutils-gold curl gcc g++ gmp-dev libc-dev libffi-dev make musl-dev ncurses-dev perl tar xz sudo zlib-dev

RUN adduser -D -s /bin/ash dude
RUN echo 'dude ALL = NOPASSWD: ALL' > /etc/sudoers.d/dude && chmod 0440 /etc/sudoers.d/dude
USER dude
WORKDIR /home/dude

ARG BOOTSTRAP_HASKELL_NONINTERACTIVE=1
ARG BOOTSTRAP_HASKELL_GHC_VERSION=9.4.4
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
ENV PATH="$PATH:/home/dude/.ghcup/bin"

RUN stack new zlibtest
WORKDIR /home/dude/zlibtest
RUN echo 'resolver: nightly-2023-02-14' > stack.yaml
RUN sed -i '/^dependencies:$/a - wai-app-static' package.yaml

Then, in the directory with this file run these two commands:

docker build -t testimg .
docker run -it testimg stack build

FWIW I don't have a Linux machine to run docker. Could you try to minimise your reproducer? Does it fail if you use cabal instead of stack? If you use different version of GHC? If you build just zlib, not wai-app-static?

ii8 commented

Yes I have tried just cabal and it comes up with a segmentation fault instead, I'll post the error in a bit, I meant to mention that earlier but got distracted.

A different version of GHC (9.2.5) causes a different error, this one: https://gitlab.haskell.org/ghc/ghc/-/issues/19421 claimed to have been fixed in newer GHC versions which is why I'm using the newer one.

Building just zlib on it's own works fine.

It's very odd, I've tried a lot of different ways to build this but each time there is a new different problem.

One more thing to try is GHC 9.6.0 alpha3, it's available through ghcup prereleases channel.

If there are segmentation faults in Cabal build, this is probably better to be upstreamed directly to https://gitlab.haskell.org/ghc/ghc/-/issues, because whatever zlib does, ghc should not segfault.

ii8 commented

Here is the error when I run

sudo docker run -it testimg cabal install wai-app-static

Very much not helpful, but I said I'd post it so here it is.

Starting     wai-app-static-3.1.7.4 (lib)
Building     wai-app-static-3.1.7.4 (lib)
cabal: Failed to build wai-app-static-3.1.7.4 (which is required by exe:warp
from wai-app-static-3.1.7.4). The build process segfaulted (i.e. SIGSEGV).
ii8 commented

GHC 9.6.0 has a different problem as well:

unix-compat > /tmp/stack-abadd9188bb9e9f8/unix-compat-0.6/src/System/PosixCompat/User.hsc:20:7: error: [GHC-76037]
unix-compat >     Not in scope: type constructor or class ‘GroupEntry’
unix-compat >    |                        
unix-compat > 20 |     , GroupEntry(..)   
unix-compat >    |       ^^^^^^^^^^^^^^   

@ii8, regarding unknown symbol 'inflateReset', I think I experienced something similar trying to build the stack package on Alpine Linux/x86_64 and that it went away after I commanded sudo apk add zlib-static.

Given the discussion at https://gitlab.haskell.org/ghc/ghc/-/issues/23043, I don't think this is something we can fix on zlib's side.