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

error: static assertion failed due to requirement 'always_false<unsigned char *>': => Type not supported yet #929

Open
thealberto opened this issue Jan 20, 2024 · 2 comments

Comments

@thealberto
Copy link

Hi all,
I'm trying to port the example woff2 fuzzer to bazel. I have prepared the project so I can run simple tests but when I try to mimic the original LibFuzzer entry point I get an error.

This is the code

#include <stddef.h>
#include <stdint.h>
#include "fuzztest/fuzztest.h"
#include "gtest/gtest.h"

#include <woff2/decode.h>

void ConvertWOFF2ToTTF(uint8_t* data, int size) {
}
FUZZ_TEST(AlbertoFuzzTest, ConvertWOFF2ToTTF);

// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  std::string buf;
  woff2::WOFF2StringOut out(&buf);
  out.SetMaxSize(30 * 1024 * 1024);
  woff2::ConvertWOFF2ToTTF(data, size, &out);
  return 0;
}

This is the output when I run bazel run --config=fuzztest --copt=-I./include :alberto -- --fuzz=AlbertoFuzzTest.ConvertWOFF2ToTTF

In file included from external/com_google_fuzztest/fuzztest/fuzztest.h:24:
In file included from external/com_google_fuzztest/./fuzztest/domain.h:18:
In file included from external/com_google_fuzztest/./fuzztest/domain_core.h:48:
external/com_google_fuzztest/./fuzztest/internal/domains/arbitrary_impl.h:60:17: error: static assertion failed due to requirement 'always_false<unsigned char *>': => Type not supported yet. Consider filing an issue.
   60 |   static_assert(always_false<T>,
      |                 ^~~~~~~~~~~~~~~
external/com_google_fuzztest/./fuzztest/domain_core.h:398:10: note: in instantiation of template class 'fuzztest::internal::ArbitraryImpl<unsigned char *>' requested here
  398 |   return internal::ArbitraryImpl<T>{};
      |          ^
external/com_google_fuzztest/./fuzztest/internal/registration.h:65:20: note: in instantiation of function template specialization 'fuzztest::internal_no_adl::Arbitrary<unsigned char *>' requested here
   65 |     return TupleOf(Arbitrary<Args>()...);
      |                    ^
external/com_google_fuzztest/./fuzztest/internal/registry.h:84:66: note: in instantiation of member function 'fuzztest::internal::DefaultRegistrationBase<unsigned char *, int>::GetDomains' requested here
   84 |     return [target_function = reg.target_function_, domain = reg.GetDomains(),
      |                                                                  ^
external/com_google_fuzztest/./fuzztest/internal/registry.h:65:18: note: in instantiation of function template specialization 'fuzztest::internal::RegistrationToken::GetFuzzTestFuzzerFactory<fuzztest::internal::DefaultRegistrationBase<unsigned char *, int>, fuzztest::internal::NoFixture, void (*)(unsigned char *, int), void *>' requested here
   65 |                  GetFuzzTestFuzzerFactory(std::move(reg)));
      |                  ^
src/alberto.cc:11:1: note: in instantiation of function template specialization 'fuzztest::internal::RegistrationToken::operator=<fuzztest::internal::DefaultRegistrationBase<unsigned char *, int>, fuzztest::internal::NoFixture, void (*)(unsigned char *, int), void *>' requested here
   11 | FUZZ_TEST(AlbertoFuzzTest, ConvertWOFF2ToTTF);
      | ^
external/com_google_fuzztest/fuzztest/fuzztest.h:66:37: note: expanded from macro 'FUZZ_TEST'
   66 | #define FUZZ_TEST(suite_name, func) INTERNAL_FUZZ_TEST(suite_name, func)
      |                                     ^
external/com_google_fuzztest/./fuzztest/internal/registry.h:107:53: note: expanded from macro 'INTERNAL_FUZZ_TEST'
  107 |           ::fuzztest::internal::RegistrationToken{} =             \
      |                                                     ^
1 error generated.
Target //:alberto failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 7.115s, Critical Path: 6.92s
INFO: 66 processes: 26 internal, 40 linux-sandbox.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
➜  woff2 git:(ccbeb246d2)

Which type should I use instead? Any other way to fix it?

@racko
Copy link

racko commented Jan 20, 2024

How about the following?

void ConvertWOFF2ToTTF(const std::vector<std::uint8_t>& bytes) {
    const uint8_t* const data{bytes.data()};
    const int size{static_cast<int>(bytes.size())};
    // ...
}
FUZZ_TEST(AlbertoFuzzTest, ConvertWOFF2ToTTF);

@thealberto
Copy link
Author

@racko

Thanks it worked!

INFO: Found 1 target...
Target //:alberto up-to-date:
  bazel-bin/alberto
INFO: Elapsed time: 3.321s, Critical Path: 3.27s
INFO: 3 processes: 1 internal, 2 linux-sandbox.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: external/bazel_tools/tools/test/test-setup.sh ./alberto '--fuzz=AlbertoFuzzTest.ConvertWOFF2ToTTF'
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:alberto
-----------------------------------------------------------------------------
[.] Sanitizer coverage enabled. Counter map size: 30385, Cmp map size: 262144
Note: Google Test filter = AlbertoFuzzTest.ConvertWOFF2ToTTF
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from AlbertoFuzzTest
[ RUN      ] AlbertoFuzzTest.ConvertWOFF2ToTTF
FUZZTEST_PRNG_SEED=tnaxpgtwGcTdechb4cT-MAbJTMn3j09oJQQ1jE_rR5Y
[*] Corpus size:     1 | Edges covered:    152 | Fuzzing time:        342.062us | Total runs:  1.00e+00 | Runs/secs:  2923 | Max stack usage:     2880
[*] Corpus size:     2 | Edges covered:    152 | Fuzzing time:        745.952us | Total runs:  3.00e+00 | Runs/secs:  4021 | Max stack usage:     2880
[*] Corpus size:     3 | Edges covered:    154 | Fuzzing time:        1.85638ms | Total runs:  3.50e+01 | Runs/secs: 18853 | Max stack usage:     2880
[*] Corpus size:     4 | Edges covered:    154 | Fuzzing time:       4.787332ms | Total runs:  3.90e+01 | Runs/secs:  8146 | Max stack usage:     2880
[*] Corpus size:     5 | Edges covered:    154 | Fuzzing time:        6.88421ms | Total runs:  4.20e+01 | Runs/secs:  6100 | Max stack usage:     2880

Is it worth to add an example in the docs?

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

No branches or pull requests

2 participants