[PATCH] D62733: Add FuzzedDataProvider helper class / single header library.

Max Moroz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 23:39:54 PDT 2019


Dor1s added a comment.

Nico, Reid, Jonathan, I'd greatly appreciate your Windows expertise here. If I remove lines 11-16 from `lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp`, I'm getting the following link errors on Windows:

  C:\src\llvm\build>ninja -v check-fuzzer-unit
  [1/3] cmd.exe /C "cd /D C:\src\llvm\build\projects\compiler-rt\lib\fuzzer\tests && C:\src\llvm\build\.\bin\clang.exe -DWIN32 -D_WINDOWS -Wno-unknown-warning-option -DGTEST_NO_LLVM_RAW_OSTREAM=1 -DGTEST_HAS_RTTI=0 -IC:/src/llvm/llvm/utils/unittest/googletest/include -IC:/src/llvm/llvm/utils/unittest/googletest -Wno-deprecated-declarations -IC:/src/llvm/llvm/projects/compiler-rt/lib/fuzzer -fno-rtti -O2 -c -o FuzzedDataProviderTestObjects.FuzzedDataProviderUnittest.cpp.x86_64.o C:/src/llvm/llvm/projects/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp"
  [2/3] cmd.exe /C "cd /D C:\src\llvm\build\projects\compiler-rt\lib\fuzzer\tests && C:\src\llvm\build\.\bin\clang.exe FuzzedDataProviderTestObjects.FuzzedDataProviderUnittest.cpp.x86_64.o FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/RTFuzzerTest.x86_64.lib -o C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./FuzzerUtils-x86_64-Test.exe --driver-mode=g++"
  FAILED: projects/compiler-rt/lib/fuzzer/tests/FuzzerUtils-x86_64-Test.exe
  cmd.exe /C "cd /D C:\src\llvm\build\projects\compiler-rt\lib\fuzzer\tests && C:\src\llvm\build\.\bin\clang.exe FuzzedDataProviderTestObjects.FuzzedDataProviderUnittest.cpp.x86_64.o FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/RTFuzzerTest.x86_64.lib -o C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./FuzzerUtils-x86_64-Test.exe --driver-mode=g++"
     Creating library C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./FuzzerUtils-x86_64-Test.lib and object C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./FuzzerUtils-x86_64-Test.exp
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol fdopen referenced in function "void __cdecl testing::internal::DeathTestAbort(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?DeathTestAbort at internal@testing@@YAXAEBV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@@Z)
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol read referenced in function "protected: void __cdecl testing::internal::DeathTestImpl::ReadAndInterpretStatusByte(void)" (?ReadAndInterpretStatusByte at DeathTestImpl@internal at testing@@IEAAXXZ)
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol close referenced in function "protected: void __cdecl testing::internal::DeathTestImpl::ReadAndInterpretStatusByte(void)" (?ReadAndInterpretStatusByte at DeathTestImpl@internal at testing@@IEAAXXZ)
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol write referenced in function "protected: virtual void __cdecl testing::internal::DeathTestImpl::Abort(enum testing::internal::DeathTest::AbortReason)" (?Abort at DeathTestImpl@internal at testing@@MEAAXW4AbortReason at DeathTest@23@@Z)
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol dup referenced in function "public: __cdecl testing::internal::CapturedStream::CapturedStream(int)" (??0CapturedStream at internal@testing@@QEAA at H@Z)
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol creat referenced in function "public: __cdecl testing::internal::CapturedStream::CapturedStream(int)" (??0CapturedStream at internal@testing@@QEAA at H@Z)
  FuzzedDataProviderTestObjects.gtest-all.cc.x86_64.o : error LNK2019: unresolved external symbol dup2 referenced in function "public: __cdecl testing::internal::CapturedStream::CapturedStream(int)" (??0CapturedStream at internal@testing@@QEAA at H@Z)
  C:/src/llvm/build/projects/compiler-rt/lib/fuzzer/tests/./FuzzerUtils-x86_64-Test.exe : fatal error LNK1120: 7 unresolved externals
  clang: error: linker command failed with exit code 1120 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

To me the issue looks like `libc` (or whatever equivalent it has on Windows) isn't specified as a `gtest` dependency, that's why symbols like `read`, `write`, or `dup2` are unresolved. It also looks like libFuzzer has the correct dependencies specified on Windows, and that's why everything works fine if my `FuzzedDataProviderUnittest` depends on libFuzzer (and actually uses it). However, I was not able to track this down and find any magic dependency that I should specify in the `CMakeLists.txt` for `FuzzedDataProviderUnittest`.

Does this look familiar at all?  My `FuzzedDataProviderUnittest` doesn't really need libFuzzer (aka `RTFuzzer`), it actually needs only `lib/fuzzer/utils/FuzzedDataProvider.h` and `gtest`.


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62733/new/

https://reviews.llvm.org/D62733





More information about the llvm-commits mailing list