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

Docker + write_(aig|cnf)_external -> abc: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory #1211

Closed
weaversa opened this issue Apr 24, 2021 · 2 comments · Fixed by #1214

Comments

@weaversa
Copy link
Contributor

I'm unable to try write_aig_external etc. because I'm using Docker and abc seems to be installed incorrectly? Maybe?

$ docker pull galoisinc/saw:nightly
nightly: Pulling from galoisinc/saw
Digest: sha256:38c6ca19ccd5710166e1ca773372e79a63d4d0d774a09ed8b3b0a72143447610
Status: Image is up to date for galoisinc/saw:nightly
$ docker run --rm -it --mount type=bind,src=/Users,dst=/Users --workdir=$(pwd) --user=$(id -u):$(id -g) --env CRYPTOLPATH=$(pwd) galoisinc/saw:nightly $*

docker.io/galoisinc/saw:nightly
 ┏━━━┓━━━┓━┓━┓━┓
 ┃ ━━┓ ╻ ┃ ┃ ┃ ┃
 ┣━━ ┃ ╻ ┃┓ ╻ ┏┛
 ┗━━━┛━┛━┛┗━┛━┛ version 0.7.0.99 (<non-dev-build>)



sawscript> write_cnf_external "test.cnf" {{ \x -> x == 0b0001 }}

Stack trace:
"write_cnf_external" (<stdin>:1:1-1:19):
abc returned non-zero exit code: ExitFailure 127
Standard output:

Standard error:
abc: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory


sawscript> exec "which" ["abc"] ""
[18:13:37.295] "/usr/local/bin/abc\n"
@RyanGlScott
Copy link
Contributor

I can reproduce this with the Docker invocation you're using (minus the filesystem-specific parts such as --mount type=bind,src=/Users,dst=/Users) but not if I use the saw binary from https://saw.galois.com/downloads.html, so this is likely related to the way the Docker image is built.

@RyanGlScott
Copy link
Contributor

Some further digging reveals that saw's Dockerfile is to blame. It installs libreadline-dev (which comes with libreadline.so) in one stage:

FROM debian:buster AS solvers
# Install needed packages for building
RUN apt-get update \
&& apt-get install -y curl cmake gcc g++ git libreadline-dev unzip

The result of that stage is copied over in a subsequent stage:

FROM debian:buster-slim
RUN apt-get update \
&& apt-get install -y libgmp10 libgomp1 libffi6 wget libncurses5 unzip
COPY --from=build /home/saw/rootfs /
COPY --from=solvers /solvers/rootfs /

However, that later stage doesn't install libreadline-dev, so it will fail at runtime if any code path involving libreadline.so is invoked. I can confirm that installing libreadline-dev in that last stage fixes the issue:

diff --git a/saw/Dockerfile b/saw/Dockerfile
index f7f13c46..345bd48e 100644
--- a/saw/Dockerfile
+++ b/saw/Dockerfile
@@ -60,7 +60,7 @@ RUN chown -R root:root /home/saw/rootfs
 
 FROM debian:buster-slim
 RUN apt-get update \
-    && apt-get install -y libgmp10 libgomp1 libffi6 wget libncurses5 unzip
+    && apt-get install -y libgmp10 libgomp1 libffi6 wget libncurses5 libreadline-dev unzip
 COPY --from=build /home/saw/rootfs /
 COPY --from=solvers /solvers/rootfs /
 RUN useradd -m saw && chown -R saw:saw /home/saw

Patch incoming.

RyanGlScott added a commit that referenced this issue Apr 26, 2021
This is necessary for `saw` commands that rely on `libreadline` to
work, such as `write_cnf_external`.

Fixes #1211.
@mergify mergify bot closed this as completed in #1214 Apr 26, 2021
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

Successfully merging a pull request may close this issue.

2 participants