Build afl-clang-fast failed, seek help...

2,651 views
Skip to first unread message

Sam

unread,
Jun 30, 2018, 6:15:58 PM6/30/18
to afl-users
When I tried to use the make command under the llvm_mode directory, it failed. Does anyone have this kind of issue before?

rtes1@rtes1-MS-7721:~/Desktop/afl-2.52b/llvm_mode$ LLVM_CONFIG=llvm-config make
[*] Checking for working 'llvm-config'...
[*] Checking for working 'clang'...
[*] Checking for '../afl-showmap'...
[+] All set and ready to build.
[*] Building 32-bit variant of the runtime (-m32)... failed (that's fine)
[*] 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-6.0: error: unable to execute command: Segmentation fault (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/rtes1/Desktop/research/clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-16.04/bin
clang-6.0: 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-6.0: error: unable to execute command: Segmentation fault (core dumped)
clang-6.0: note: diagnostic msg: Error generating preprocessed source(s).
Makefile:97: recipe for target 'test_build' failed

Jakub Wilk

unread,
Jun 30, 2018, 6:45:08 PM6/30/18
to afl-...@googlegroups.com
* Sam <forevers...@gmail.com>, 2018-06-30, 15:15:
>[*] 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-6.0: error: unable to execute command: Segmentation fault (core dumped)

Sounds similar to this:
https://groups.google.com/d/topic/afl-users/D3-jbylxHeg

TL;DR: try passing CXX=g++ to make.

--
Jakub Wilk

Sam

unread,
Jun 30, 2018, 7:26:42 PM6/30/18
to afl-users
Thanks for your replay. I did try it and I got this:

[*] 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++
g++ `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 `llvm-config --ldflags` 
g++: error: unrecognized command line option ‘-Wcovered-switch-default’
g++: error: unrecognized command line option ‘-Wstring-conversion’
Makefile:83: recipe for target '../afl-llvm-pass.so' failed
make: *** [../afl-llvm-pass.so] Error 1

Sam

unread,
Jun 30, 2018, 7:44:16 PM6/30/18
to afl-users
I downgraded my clang to 4.0 and the problem is fixed now. Thanks!


On Saturday, June 30, 2018 at 6:45:08 PM UTC-4, Jakub Wilk wrote:

Vincent Ulitzsch

unread,
Jul 10, 2018, 11:21:23 AM7/10/18
to afl-users
I am having the exact same issues. However, given the program I want to fuzz, downgrading to clang-4.0 is not an option for me. Do you see any other option/fix for this issue? I am using clang-6.0 and llvm-6.0 to build the software together with g++-7 and either clang segfaults or g++ complains about wrong parameters. Any suggestions on how to fix this?

Arjun

unread,
Jul 10, 2018, 4:41:08 PM7/10/18
to afl-users
refer to the link that Jakub has provided above
https://groups.google.com/d/topic/afl-users/D3-jbylxHeg 

I have similar configuration as yours and following worked for me:

In your base afl directory (i.e. in afl-2.52b), run following:
make && make -C llvm_mode LLVM_CONFIG=llvm-config-6.0 CC=clang-6.0

The above should build both, afl and llvm.  

Jakub Wilk

unread,
Jul 11, 2018, 12:57:27 PM7/11/18
to afl-...@googlegroups.com
* Sam <forevers...@gmail.com>, 2018-06-30, 16:26:
>g++ `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 `llvm-config --ldflags`
>g++: error: unrecognized command line option ‘-Wcovered-switch-default’
>g++: error: unrecognized command line option ‘-Wstring-conversion’
>Makefile:83: recipe for target '../afl-llvm-pass.so' failed
>make: *** [../afl-llvm-pass.so] Error 1

Bummer. What compiler did you use to build LLVM? It's probably safest
bet to use the same compiler to build AFL's code.

What's the output of the "llvm-config --cxxflags" command?

--
Jakub Wilk

Vincent Ulitzsch

unread,
Jul 16, 2018, 7:23:30 PM7/16/18
to afl-users
Sorry for the late response. As pointed out in your comment, I could resolve the issue by building llvm myself using the sample compiler as afl code uses. Apparently I got the error because I was using prebuild binaries from the ubuntu repositories. Building llvm resolved the issue.

For future reference, I built llvm following this guide: http://clang.llvm.org/get_started.html

Best & Thanks for your help
Reply all
Reply to author
Forward
0 new messages