google / honggfuzz

Security oriented software fuzzer. Supports evolutionary, feedback-driven fuzzing based on code coverage (SW and HW based)
https://honggfuzz.dev
Apache License 2.0
3.04k stars 511 forks source link

Compile error on WSL2 Ubuntu #490

Closed gtrab99 closed 11 months ago

gtrab99 commented 1 year ago

Hello,

I have been able to compile honggfuzz on my system in the past without issue, but recently I tried and am getting the following errors from bfd.c:

image

Could this be a compiler compatibility issue?

benner commented 1 year ago

I have same issue

jinnypenny commented 1 year ago

I have same issue

vivi50 commented 1 year ago

I have same issue, but when I reset to the previous commit f7b69eefb28b48e481dfa414873e2960b77452ac, it compiles successfully. i think the issue may be caused by the latest commit

douglasbagnall commented 1 year ago

Same issue on Ubuntu 22.04 with binutils-dev 2.38-4ubuntu2.2

As @vivi50 suggests, reverting 37e8e813c9daa94dff29654b262268481d8c53ee solves the issue.

In order to make this searchable, I present the error message as text:

cc -c -fuse-ld=lld  -std=c11 -I/usr/local/include -D_GNU_SOURCE -Wall -Wextra -Werror -Wno-format-truncation -Wno-override-init -I. -D_FILE_OFFSET_BITS=64 -finline-limit=4000 -D_HF_ARCH_LINUX  -o linux/bfd.o linux/bfd.c
linux/bfd.c:202:21: error: ‘enum disassembler_style’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
  202 |     void* buf, enum disassembler_style style HF_ATTR_UNUSED, const char* fmt, ...) {
      |                     ^~~~~~~~~~~~~~~~~~
linux/bfd.c:202:40: error: parameter 2 (‘style’) has incomplete type
  202 |     void* buf, enum disassembler_style style HF_ATTR_UNUSED, const char* fmt, ...) {
linux/bfd.c: In function ‘arch_bfdDisasm’:
linux/bfd.c:249:9: error: cast between incompatible function types from ‘void (*)(struct disassemble_info *, void *, int (*)(void *, const char *, ...))’ to ‘void (*)(void *, void *, void *, void *)’ [-Werror=cast-function-type]
  249 |         (void (*)(void*, void*, void*, void*))init_disassemble_info;
      |         ^
gusti6 commented 1 year ago

I have same issue, but when I reset to the previous commit f7b69ee, it compiles successfully. i think the issue may be caused by the latest commit

Compiled with this commit, but now when I run hongfuzz I get the following error: honggfuzz --linux_perf_bts_edge -- /usr/bin/djpeg FILE

As above, maximize unique code blocks via Intel Processor Trace (requires libipt.so):

honggfuzz --linux_perf_ipt_block -- /usr/bin/djpeg FILE

[2023-08-13T17:16:50-0400][F][82300] main():340 Parsing of the cmd-line arguments failed

robertswiecki commented 1 year ago

I think WSL2 is a virtualization-based environment, the CPU performance event would have to be exported into the VM.

It's relatively easy to do it with --linux_perf_instr or --linux_perf_branch (at least qemu-kvm supportes them via Linux kernel), but BTS and IntelPT are quite complex, and unless I misunderstand WSL2 severly, they probably not handled by the Linux VMM under Windows :(

vanhauser-thc commented 11 months ago

This has nothing to do with WSL2. I have this error too on a native Ubuntu and a Debian.

D_HF_ARCH_LINUX -g -ggdb -g3  -o linux/bfd.o linux/bfd.c
  linux/bfd.c:202:21: error: ‘enum disassembler_style’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
    202 |     void* buf, enum disassembler_style style HF_ATTR_UNUSED, const char* fmt, ...) {
        |                     ^~~~~~~~~~~~~~~~~~
  linux/bfd.c:202:40: error: parameter 2 (‘style’) has incomplete type
    202 |     void* buf, enum disassembler_style style HF_ATTR_UNUSED, const char* fmt, ...) {
  linux/bfd.c: In function ‘arch_bfdDisasm’:
  linux/bfd.c:249:9: error: cast between incompatible function types from ‘void (*)(struct disassemble_info *, void *, int (*)(void *, const char *, ...))’ to ‘void (*)(void *, void *, void *, void *)’ [-Werror=cast-function-type]
    249 |         (void (*)(void*, void*, void*, void*))init_disassemble_info;
        |         ^
  In file included from ./libhfcommon/util.h:28,
                   from ./honggfuzz.h:39,
                   from ./sanitizers.h:26,
                   from ./linux/unwind.h:27,
                   from ./linux/bfd.h:32,
                   from linux/bfd.c:26:
  linux/bfd.c: In function ‘arch_bfdFPrintFStyled’:
  linux/bfd.c:204:5: error: ‘va_start’ used in function with fixed args
    204 |     va_start(args, fmt);
        |     ^~~~~~~~
  cc1: all warnings being treated as errors
robertswiecki commented 11 months ago

This should help the situation a bit (undefined enum disassembler_style)

https://github.com/google/honggfuzz/commit/c0522ed374b7ba1ac7faa721ff62bb6d4b319347

As for the cast between incompatible function types, I'm not sure how to do it for now. I was thinking that casting from any pointer to void* is ok, but apparently not.

robertswiecki commented 11 months ago

And this https://github.com/google/honggfuzz/commit/ad389c48f6dca9064b4a866dab7cafca6ad8b27f will maybe help with function conversions.

vanhauser-thc commented 11 months ago

Hi Robert,

I still get:

linux/bfd.c: In function ‘arch_bfdDisasm’:
linux/bfd.c:257:9: error: cast between incompatible function types from ‘void (*)(struct disassemble_info *, void *, int (*)(void *, const char *, ...))’ to ‘void (*)(void *, void *, void *, void *)’ [-Werror=cast-function-type]
  257 |         (void (*)(void*, void*, void*, void*))init_disassemble_info;
      |         ^
cc1: all warnings being treated as errors
make: *** [Makefile:279: linux/bfd.o] Error 1

this is on a Ubuntu 20.04.6 LTS

robertswiecki commented 11 months ago

What about this? https://github.com/google/honggfuzz/commit/4c8517383e8070f6d8d0308253e4b33d11605c98

vanhauser-thc commented 11 months ago

this fixes it for me :)