Failing to build with clang-6.0

2,617 views
Skip to first unread message

Bob McChesney

unread,
May 12, 2018, 4:51:13 AM5/12/18
to afl-users
Hello,

Now that gcc-7 is fixed in Debian Testing and afl-gcc is building fine, I've moved on to trying to build llvm_mode. I'm using clang-6.0 version 6.0-3 in Debian Testing, and I get the following issues when building:

root@5cbf72e5a03c:~/afl-2.52b/llvm_mode# make
[*] Checking for working 'llvm-config'...
[*] Checking for working 'clang'...
[*] Checking for '../afl-showmap'...
[+] All set and ready to build.
[*] Testing the CC wrapper and instrumentation output...
unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=clang ../afl-clang-fast -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -DAFL_PATH=\"/usr/local/lib/afl\" -DBIN_PATH=\"/usr/local/bin\" -DVERSION=\"2.52b\"  ../test-instr.c -o test-instr
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.0-3 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: note: diagnostic msg: Error generating preprocessed source(s).
Makefile:97: recipe for target 'test_build' failed
make: *** [test_build] Error 254
root@5cbf72e5a03c:~/afl-2.52b/llvm_mode#

Does anyone have any idea what might be the problem? (By the way, this is being run in a Docker container, but the issue seems to be the same in a VM.)

This also affects Ubuntu 18.04 I believe.

Regards,
Bob

Jakub Wilk

unread,
May 12, 2018, 5:22:04 AM5/12/18
to afl-...@googlegroups.com
* Bob McChesney <bmcch...@gmail.com>, 2018-05-12, 01:51:
>clang: error: unable to execute command: Segmentation fault (core dumped)

https://groups.google.com/d/msg/afl-users/TDLrTu3V_Pw/K4svutarAAAJ

I gave up on debugging this for the time being, because debug packages
for LLVM are broken[0], and there's a straight-forward work-around.

[0] https://bugs.debian.org/880957

--
Jakub Wilk

Bob McChesney

unread,
May 12, 2018, 10:27:35 AM5/12/18
to afl-users
On Saturday, 12 May 2018 10:22:04 UTC+1, Jakub Wilk wrote:

https://groups.google.com/d/msg/afl-users/TDLrTu3V_Pw/K4svutarAAAJ

I gave up on debugging this for the time being, because debug packages
for LLVM are broken[0], and there's a straight-forward work-around.

Thank you. I can confirm that from clean, "make && make -C llvm_mode LLVM_CONFIG=llvm-config-6.0 CC=clang-6.0" works. Is that the workaround you recommend?

Regards,
Bob

Jakub Wilk

unread,
May 12, 2018, 2:00:10 PM5/12/18
to afl-...@googlegroups.com
* Bob McChesney <bmcch...@gmail.com>, 2018-05-12, 07:27:
>I can confirm that from clean, "make && make -C llvm_mode
>LLVM_CONFIG=llvm-config-6.0 CC=clang-6.0" works. Is that the workaround
>you recommend?

That works, but for building against default version of LLVM/clang, this
is simpler:

make && make -C llvm_mode CXX=g++

--
Jakub Wilk

Bob McChesney

unread,
May 12, 2018, 2:04:43 PM5/12/18
to afl-users
On Saturday, 12 May 2018 19:00:10 UTC+1, Jakub Wilk wrote:
That works, but for building against default version of LLVM/clang, this
is simpler:

make && make -C llvm_mode CXX=g++

Cheers, Jakub! You're a star.

Bob

Simon Johansson

unread,
May 17, 2018, 4:05:08 AM5/17/18
to afl-users
I have the same issue, making a docker with all tools i need for my development. I want to use AFL persistent mode and need llvm mode. Using this dockerfile i get the same result:
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install wget git cmake gcc g++ gdb lcov gcc-multilib libsodium-dev default-jre default-jdk screen clang clang-tools -y

RUN mkdir -p fuzz
RUN cd /fuzz; wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz; tar -xvf afl-latest.tgz
RUN cd /fuzz/afl-2.52b; export CC=clang; export CXX=/usr/bin/clang++; make install
RUN cd /fuzz/afl-2.52b/llvm_mode; export CC=clang; export CXX=/usr/bin/clang++; export LLVM_CONFIG=/usr/lib/llvm-6.0/bin/llvm-config; make

Step 7/7 : RUN cd /fuzz/afl-2.52b/llvm_mode; export CC=clang; export CXX=/usr/bin/clang++; export LLVM_CONFIG=/usr/lib/llvm-6.0/bin/llvm-config; make

 ---> Running in f09d4734f515

[*] Checking for working 'llvm-config'...

[*] Checking for working 'clang'...

[*] Checking for '../afl-showmap'...

[+] All set and ready to build.

clang -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -DAFL_PATH=\"/usr/local/lib/afl\" -DBIN_PATH=\"/usr/local/bin\" -DVERSION=\"2.52b\"  afl-clang-fast.c -o ../afl-clang-fast 

ln -sf afl-clang-fast ../afl-clang-fast++

/usr/bin/clang++ `/usr/lib/llvm-6.0/bin/llvm-config --cxxflags` -fno-rtti -fpic -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -DVERSION=\"2.52b\" -Wno-variadic-macros -shared afl-llvm-pass.so.cc -o ../afl-llvm-pass.so `/usr/lib/llvm-6.0/bin/llvm-config --ldflags` 

warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]

1 warning generated.

clang -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -DAFL_PATH=\"/usr/local/lib/afl\" -DBIN_PATH=\"/usr/local/bin\" -DVERSION=\"2.52b\"  -fPIC -c afl-llvm-rt.o.c -o ../afl-llvm-rt.o

[*] Building 32-bit variant of the runtime (-m32)... success!

[*] Building 64-bit variant of the runtime (-m64)... success!

[*] Testing the CC wrapper and instrumentation output...

unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=clang ../afl-clang-fast -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -DAFL_PATH=\"/usr/local/lib/afl\" -DBIN_PATH=\"/usr/local/bin\" -DVERSION=\"2.52b\"  ../test-instr.c -o test-instr 

clang: error: unable to execute command: Segmentation fault

clang: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

Target: x86_64-pc-linux-gnu

Thread model: posix

InstalledDir: /usr/bin

clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.

clang: error: unable to execute command: Segmentation fault

clang: note: diagnostic msg: Error generating preprocessed source(s).

Makefile:97: recipe for target 'test_build' failed

make: *** [test_build] Error 254

Bob McChesney

unread,
May 17, 2018, 5:46:06 PM5/17/18
to afl-users
On 17 May 2018 at 09:05, Simon Johansson <sijoh...@gmail.com> wrote:
I have the same issue, making a docker with all tools i need for my development. I want to use AFL persistent mode and need llvm mode. Using this dockerfile i get the same result:

Same here. I've given up on 18.04 for now because of the gcc issue. I've raised an issue (https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1770342) but I don't know how likely it will be to get picked up.

I've created a Dockerfile against Debian Testing, and with Jakub's suggestion, it's all building (afl-gcc and afl-clang-fast) fine for me:

FROM debian:testing
RUN apt update
RUN apt install -y sudo build-essential clang-6.0 wget
RUN useradd -G sudo -m bob
USER bob
WORKDIR "/home/bob"
ADD --chown=bob:bob http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz /home/bob/
RUN tar -xf afl-latest.tgz && rm afl-latest.tgz && mv afl-* afl-latest
WORKDIR "afl-latest"
RUN make && make -C llvm_mode LLVM_CONFIG=llvm-config-6.0 CC=clang-6.0 CXX=g++
USER root
RUN make install
USER bob
ENTRYPOINT ["bash"]

Bob

Reply all
Reply to author
Forward
0 new messages