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

libfuzzer/FuzzerInterceptors.cpp:62:36: error: 'size_t' has not been declared #87

Open
kolbma opened this issue Jan 19, 2022 · 2 comments

Comments

@kolbma
Copy link

kolbma commented Jan 19, 2022

Can't build it on target x86_64-unknown-linux-musl ...
Seems to be missed to #include <cstddef> somewhere to be compatible?

  running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-w" "-o" "/home/rocket/Rocket_v0.5.0-rc.2/core/lib/fuzz/target/debug/build/libfuzzer-sys-6a0b651a20d3591b/out/libfuzzer/FuzzerInterceptors.o" "-c" "libfuzzer/FuzzerInterceptors.cpp"
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:62:36: error: 'size_t' has not been declared
  cargo:warning=   62 |                                    size_t n) {
  cargo:warning=      |                                    ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp: In function 'int internal_strcmp_strncmp(const char*, const char*, bool, int)':
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:63:3: error: 'size_t' was not declared in this scope; did you mean 'std::size_t'?
  cargo:warning=   63 |   size_t i = 0;
  cargo:warning=      |   ^~~~~~
  cargo:warning=      |   std::size_t
  cargo:warning=In file included from /usr/include/c++/10.3.1/cassert:43,
  cargo:warning=                 from libfuzzer/FuzzerInterceptors.cpp:27:
  cargo:warning=/usr/include/c++/10.3.1/x86_64-alpine-linux-musl/bits/c++config.h:264:26: note: 'std::size_t' declared here
  cargo:warning=  264 |   typedef __SIZE_TYPE__  size_t;
  cargo:warning=      |                          ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:66:11: error: 'i' was not declared in this scope
  cargo:warning=   66 |       if (i == n)
  cargo:warning=      |           ^
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:68:7: error: 'i' was not declared in this scope
  cargo:warning=   68 |       i++;
  cargo:warning=      |       ^
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp: At global scope:
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:82:61: error: 'size_t' has not been declared
  cargo:warning=   82 | static int internal_strncmp(const char *s1, const char *s2, size_t n) {
  cargo:warning=      |                                                             ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:90:60: error: 'size_t' has not been declared
  cargo:warning=   90 | static int internal_memcmp(const void *s1, const void *s2, size_t n) {
  cargo:warning=      |                                                            ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp: In function 'int internal_memcmp(const void*, const void*, int)':
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:93:8: error: 'size_t' was not declared in this scope; did you mean 'std::size_t'?
  cargo:warning=   93 |   for (size_t i = 0; i < n; ++i, ++t1, ++t2)
  cargo:warning=      |        ^~~~~~
  cargo:warning=      |        std::size_t
  cargo:warning=In file included from /usr/include/c++/10.3.1/cassert:43,
  cargo:warning=                 from libfuzzer/FuzzerInterceptors.cpp:27:
  cargo:warning=/usr/include/c++/10.3.1/x86_64-alpine-linux-musl/bits/c++config.h:264:26: note: 'std::size_t' declared here
  cargo:warning=  264 |   typedef __SIZE_TYPE__  size_t;
  cargo:warning=      |                          ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:93:22: error: 'i' was not declared in this scope
  cargo:warning=   93 |   for (size_t i = 0; i < n; ++i, ++t1, ++t2)
  cargo:warning=      |                      ^
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp: At global scope:
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:99:8: error: 'size_t' does not name a type
  cargo:warning=   99 | static size_t internal_strlen(const char *s) {
  cargo:warning=      |        ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:30:1: note: 'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
  cargo:warning=   29 | #include <dlfcn.h> // for dlsym()
  cargo:warning=  +++ |+#include <cstddef>
  cargo:warning=   30 | 
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp: In function 'char* internal_strstr(const char*, const char*)':
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:108:3: error: 'size_t' was not declared in this scope; did you mean 'std::size_t'?
  cargo:warning=  108 |   size_t len1 = internal_strlen(haystack);
  cargo:warning=      |   ^~~~~~
  cargo:warning=      |   std::size_t
  cargo:warning=In file included from /usr/include/c++/10.3.1/cassert:43,
  cargo:warning=                 from libfuzzer/FuzzerInterceptors.cpp:27:
  cargo:warning=/usr/include/c++/10.3.1/x86_64-alpine-linux-musl/bits/c++config.h:264:26: note: 'std::size_t' declared here
  cargo:warning=  264 |   typedef __SIZE_TYPE__  size_t;
  cargo:warning=      |                          ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:109:9: error: expected ';' before 'len2'
  cargo:warning=  109 |   size_t len2 = internal_strlen(needle);
  cargo:warning=      |         ^~~~~
  cargo:warning=      |         ;
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:110:7: error: 'len1' was not declared in this scope
  cargo:warning=  110 |   if (len1 < len2)
  cargo:warning=      |       ^~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:110:14: error: 'len2' was not declared in this scope
  cargo:warning=  110 |   if (len1 < len2)
  cargo:warning=      |              ^~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:112:14: error: expected ';' before 'pos'
  cargo:warning=  112 |   for (size_t pos = 0; pos <= len1 - len2; pos++) {
  cargo:warning=      |              ^~~~
  cargo:warning=      |              ;
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:112:24: error: 'pos' was not declared in this scope
  cargo:warning=  112 |   for (size_t pos = 0; pos <= len1 - len2; pos++) {
  cargo:warning=      |                        ^~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:112:31: error: 'len1' was not declared in this scope
  cargo:warning=  112 |   for (size_t pos = 0; pos <= len1 - len2; pos++) {
  cargo:warning=      |                               ^~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:112:38: error: 'len2' was not declared in this scope
  cargo:warning=  112 |   for (size_t pos = 0; pos <= len1 - len2; pos++) {
  cargo:warning=      |                                      ^~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp: At global scope:
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:124:51: error: 'size_t' has not been declared
  cargo:warning=  124 |                                   const void *s2, size_t n, int result);
  cargo:warning=      |                                                   ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:126:52: error: 'size_t' has not been declared
  cargo:warning=  126 |                                    const char *s2, size_t n, int result);
  cargo:warning=      |                                                    ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:128:56: error: 'size_t' has not been declared
  cargo:warning=  128 |                                        const char *s2, size_t n, int result);
  cargo:warning=      |                                                        ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:137:68: error: 'size_t' has not been declared
  cargo:warning=  137 | void __sanitizer_weak_hook_memmem(void *called_pc, const void *s1, size_t len1,
  cargo:warning=      |                                                                    ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:138:51: error: 'size_t' has not been declared
  cargo:warning=  138 |                                   const void *s2, size_t len2, void *result);
  cargo:warning=      |                                                   ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:140:52: error: 'size_t' has not been declared
  cargo:warning=  140 | DEFINE_REAL(int, bcmp, const void *, const void *, size_t)
  cargo:warning=      |                                                    ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:22:39: note: in definition of macro 'DEFINE_REAL'
  cargo:warning=   22 |   typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);                            \
  cargo:warning=      |                                       ^~~~~~~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:141:54: error: 'size_t' has not been declared
  cargo:warning=  141 | DEFINE_REAL(int, memcmp, const void *, const void *, size_t)
  cargo:warning=      |                                                      ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:22:39: note: in definition of macro 'DEFINE_REAL'
  cargo:warning=   22 |   typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);                            \
  cargo:warning=      |                                       ^~~~~~~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:142:55: error: 'size_t' has not been declared
  cargo:warning=  142 | DEFINE_REAL(int, strncmp, const char *, const char *, size_t)
  cargo:warning=      |                                                       ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:22:39: note: in definition of macro 'DEFINE_REAL'
  cargo:warning=   22 |   typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);                            \
  cargo:warning=      |                                       ^~~~~~~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:144:59: error: 'size_t' has not been declared
  cargo:warning=  144 | DEFINE_REAL(int, strncasecmp, const char *, const char *, size_t)
  cargo:warning=      |                                                           ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:22:39: note: in definition of macro 'DEFINE_REAL'
  cargo:warning=   22 |   typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);                            \
  cargo:warning=      |                                       ^~~~~~~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:148:43: error: 'size_t' has not been declared
  cargo:warning=  148 | DEFINE_REAL(void *, memmem, const void *, size_t, const void *, size_t)
  cargo:warning=      |                                           ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:22:39: note: in definition of macro 'DEFINE_REAL'
  cargo:warning=   22 |   typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);                            \
  cargo:warning=      |                                       ^~~~~~~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:148:65: error: 'size_t' has not been declared
  cargo:warning=  148 | DEFINE_REAL(void *, memmem, const void *, size_t, const void *, size_t)
  cargo:warning=      |                                                                 ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:22:39: note: in definition of macro 'DEFINE_REAL'
  cargo:warning=   22 |   typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__);                            \
  cargo:warning=      |                                       ^~~~~~~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:150:62: error: 'size_t' has not been declared
  cargo:warning=  150 | ATTRIBUTE_INTERFACE int bcmp(const char *s1, const char *s2, size_t n) {
  cargo:warning=      |                                                              ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:158:64: error: 'size_t' has not been declared
  cargo:warning=  158 | ATTRIBUTE_INTERFACE int memcmp(const void *s1, const void *s2, size_t n) {
  cargo:warning=      |                                                                ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:166:65: error: 'size_t' has not been declared
  cargo:warning=  166 | ATTRIBUTE_INTERFACE int strncmp(const char *s1, const char *s2, size_t n) {
  cargo:warning=      |                                                                 ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:182:69: error: 'size_t' has not been declared
  cargo:warning=  182 | ATTRIBUTE_INTERFACE int strncasecmp(const char *s1, const char *s2, size_t n) {
  cargo:warning=      |                                                                     ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:212:30: error: 'size_t' has not been declared
  cargo:warning=  212 | void *memmem(const void *s1, size_t len1, const void *s2, size_t len2) {
  cargo:warning=      |                              ^~~~~~
  cargo:warning=libfuzzer/FuzzerInterceptors.cpp:212:59: error: 'size_t' has not been declared
  cargo:warning=  212 | void *memmem(const void *s1, size_t len1, const void *s2, size_t len2) {
  cargo:warning=      |                                                           ^~~~~~
  exit status: 1

  --- stderr


  error occurred: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-std=c++11" "-fno-omit-frame-pointer" "-w" "-o" "/home/rocket/Rocket_v0.5.0-rc.2/core/lib/fuzz/target/debug/build/libfuzzer-sys-6a0b651a20d3591b/out/libfuzzer/FuzzerInterceptors.o" "-c" "libfuzzer/FuzzerInterceptors.cpp" with args "c++" did not execute successfully (status code exit status: 1).
@kolbma
Copy link
Author

kolbma commented Jan 20, 2022

After updating libfuzzer directory to the llvm branch release/13.x it can be compiled.

The only change is

$ diff -uw libfuzzer.20220120095225 libfuzzer
--- libfuzzer.20220120095225/FuzzerInterceptors.cpp
+++ libfuzzer/FuzzerInterceptors.cpp
@@ -25,6 +25,7 @@
   }
 
 #include <cassert>
+#include <cstddef> // for size_t
 #include <cstdint>
 #include <dlfcn.h> // for dlsym()

kolbma added a commit to kolbma/Rocket that referenced this issue Jan 20, 2022
Using source checkout in core/lib/libfuzzer-sys with updated
llvm libfuzzer directory to todays release/13.x branch
which fixes a missing `#include <cstddef>`.

See rust-fuzz/libfuzzer#87
@fitzgen
Copy link
Member

fitzgen commented Jan 20, 2022

Happy to merge a PR that updates the vendored libfuzzer!

kolbma added a commit to kolbma/libfuzzer that referenced this issue Jan 22, 2022
Add missing `cstddef` header for `size_t`.  
Fixes rust-fuzz#87  
libfuzzer code is then up-to-date with llvm branch release/13.x up to 2022/01/20.  
Upstream fix is with llvm/llvm-project@60e32a1
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