ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.21k stars 261 forks source link

Fuzzing in v1.32 on Windows doesn't work with VS2019, requires VS2022 #4349

Open MrSmith33 opened 1 year ago

MrSmith33 commented 1 year ago

When I compiled a test program with VS2019 I got linker errors

ldc_rt.fuzzer.lib(FuzzerDriver.cpp.obj) : error LNK2019: unresolved external symbol __std_find_trivial_1 referenced in function "int __cdecl fuzzer::CleanseCrashInput(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &,struct fuzzer::FuzzingOptions const &)" (?CleanseCrashInput@fuzzer@@YAHAEBV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBUFuzzingOptions@1@@Z)
ldc_rt.fuzzer.lib(FuzzerMerge.cpp.obj) : error LNK2001: unresolved external symbol __std_find_trivial_1
ldc_rt.fuzzer.lib(FuzzerFork.cpp.obj) : error LNK2001: unresolved external symbol __std_find_trivial_1
ldc_rt.fuzzer.lib(FuzzerDataFlowTrace.cpp.obj) : error LNK2001: unresolved external symbol __std_find_trivial_1
ldc_rt.fuzzer.lib(FuzzerLoop.cpp.obj) : error LNK2019: unresolved external symbol __std_find_trivial_4 referenced in function "public: <auto> __cdecl `public: bool __cdecl fuzzer::Fuzzer::RunOne(unsigned char const *,unsigned __int64,bool,struct fuzzer::InputInfo *,bool,bool *)'::`1'::<lambda_1>::operator()(unsigned int)const " (??R<lambda_1>@?0??RunOne@Fuzzer@fuzzer@@QEAA_NPEBE_K_NPEAUInputInfo@3@2PEA_N@Z@QEBA?A?<auto>@@I@Z)
example.exe : fatal error LNK1120: 2 unresolved externals
Error: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\link.exe failed with status: 1120

__std_find_trivial_1 and __std_find_trivial_4 are unresolved

Compiled with ldc2 -betterC -m64 -g -d-debug -fsanitize=fuzzer -fsanitize=address example.d

Searching for the problem led me to this issue https://github.com/actions/runner-images/issues/6091, which solved the error by updating VS to the newer version.

Freshly installed VS2022 solved the problem for me. The MSVC version is now 14.35.32215 (was 14.28.29910)

It is probably a good idea to mention this in release notes.

JohanEngelen commented 1 year ago

Would a text like this cover it and be correct?

Platform Support

MrSmith33 commented 1 year ago

sounds good

kinke commented 1 year ago

Yeah this is an unfortunate side effect of the prebuilt package now being generated on a CI runner with VS2022 image.