Repository navigation
Hit errors when build ROOT with msvc on AddressSanitizer mode #9445
Copy link
Copy link
Closed
Labels
Description
Describe the bug
Hi All,
I have follow below steps to build root project with msvc on AddressSanitizer mode, but hit below errors. And I have seen "WARNING "Address sanitizer builds only tested with gcc and Clang" on CMakeLists. So I am not sure if root support asan mode with msvc. Could you please help have a look and confirm it? Thanks a lot!
(The error message shows "The items cannot be built in parallel." but I have tried build single parallel still hit this error)
Error:
CustomBuild:
"The build of 'F:\gitP\root-project\root\build_x86_asan2\CMakeFiles\ecd3d997f4f89e0243288555110c5833\onepcm.rule' depends on 'F:\GITP\ROOT-PROJECT\ROOT\BUILD_X86_ASAN2\ETC\ALLDICT.CXX.PCH' which is produced by the build of 'F:\gitP\root-project\root\build_x86_asan2\CMakeFiles\1b80de060c1a00976f83382f69cf2b7f\allDict.cxx.pch.rule'. The items cannot be built in parallel."
Generating etc/allDict.cxx.pch
Generating PCH for core core\clingutils core\imt core\rint core\thread graf2d\asimage graf2d\gpad graf2d\gpadv7 graf2d\graf graf2d\postscript graf2d\primitivesv7 graf2d\win32gdk graf3d\g3d graf3d\gl gui\fitpanel gui\fitpanelv7 gui\gui hist\hist hist\histdrawv7 hist\histpainter hist\histv7 hist\spectrum hist\spectrumpainter io\io math\genetic math\genvector math\mathcore math\matrix math\minuit math\minuit2 math\physics math\smatrix math\vecops net\net roofit\RDataFrameHelpers roofit\roofit roofit\roofitcore roofit\roostats tmva\sofie tmva\tmva tmva\tmvagui tree\dataframe tree\ntuple tree\tree tree\treeplayer tree\treeviewer
=================================================================
==6948==ERROR: AddressSanitizer: allocator is out of memory trying to allocate 0x203ffff bytes
#0 0x6684e141 (C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x86\clang_rt.asan_dynamic-i386.dll+0x1003e141)
#1 0x693e0308 in llvm::safe_realloc(void *, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x11970308)
#2 0x6c13ed37 in llvm::SmallVectorBase::grow_pod(void *, unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x146ced37)
#3 0x67bb3ed6 in llvm::SmallVectorImpl<char>::append<char const *, void>(char const *, char const *) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x10143ed6)
#4 0x67ddd547 in llvm::BitstreamWriter::Emit(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1036d547)
#5 0x67ddda88 in llvm::BitstreamWriter::EmitVBR(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1036da88)
#6 0x6882ed6e in llvm::BitstreamWriter::EmitRecord<class llvm::SmallVectorImpl<unsigned __int64>>(unsigned int, class llvm::SmallVectorImpl<unsigned __int64> const &, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x10dbed6e)
#7 0x68c8b61e in clang::ASTRecordWriter::EmitStmt(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b61e)
#8 0x68c8b594 in clang::ASTStmtWriter::Emit(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b594)
#9 0x68ca4c29 in clang::ASTWriter::WriteSubStmt(class clang::Stmt *) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x11234c29)
#10 0x68c8bbc1 in clang::ASTRecordWriter::FlushSubStmts(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121bbc1)
#11 0x68c8b5a6 in clang::ASTRecordWriter::EmitStmt(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b5a6)
#12 0x68c8b594 in clang::ASTStmtWriter::Emit(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b594)
#13 0x68ca4c29 in clang::ASTWriter::WriteSubStmt(class clang::Stmt *) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x11234c29)
#14 0x68c8bbc1 in clang::ASTRecordWriter::FlushSubStmts(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121bbc1)
#15 0x68c8b5a6 in clang::ASTRecordWriter::EmitStmt(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b5a6)
#16 0x68c8b594 in clang::ASTStmtWriter::Emit(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b594)
#17 0x68ca4c29 in clang::ASTWriter::WriteSubStmt(class clang::Stmt *) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x11234c29)
#18 0x68c8bbc1 in clang::ASTRecordWriter::FlushSubStmts(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121bbc1)
#19 0x68c8b5a6 in clang::ASTRecordWriter::EmitStmt(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b5a6)
#20 0x68c8b594 in clang::ASTStmtWriter::Emit(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b594)
#21 0x68ca4c29 in clang::ASTWriter::WriteSubStmt(class clang::Stmt *) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x11234c29)
#22 0x68c8bbc1 in clang::ASTRecordWriter::FlushSubStmts(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121bbc1)
#23 0x68c8b5a6 in clang::ASTRecordWriter::EmitStmt(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b5a6)
#24 0x68c8b594 in clang::ASTStmtWriter::Emit(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b594)
#25 0x68ca4c29 in clang::ASTWriter::WriteSubStmt(class clang::Stmt *) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x11234c29)
#26 0x68c8b96c in clang::ASTRecordWriter::FlushStmts(void) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x1121b96c)
#27 0x68b342ca in clang::ASTRecordWriter::Emit(unsigned int, unsigned int) (F:\gitP\root-project\root\build_x86_asan2\bin\libCling.dll+0x110c42ca)
==6948==HINT: if you don't care about these errors you may set allocator_may_return_null=1
SUMMARY: AddressSanitizer: out-of-memory (C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x86\clang_rt.asan_dynamic-i386.dll+0x1003e141)
==6948==ABORTING
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'F:\gitP\root-project\root\build_x86_asan2\CMakeFiles\1b80de060c1a00976f83382f69cf2b7f\allDict.cxx.pch.rule;F:\gitP\root-project\root\build_x86_asan2\CMakeFiles\ecd3d997f4f89e0243288555110c5833\onepcm.rule;F:\gitP\root-project\root\CMakeLists.txt' exited with code 1.
To Reproduce
- Open a x86 Native Tools Command Prompt for VS 2019
git clone https://github.com/root-project/root.git root_srcmkdir root_build && cd root_buildcmake -G"Visual Studio 16 2019" -A Win32 -Dtesting=ON -Droottest=ON ../root_srcset _CL_= /fsanitize=address /GS- /wd5072 & set _LINK_= /InferASanLibs /incremental:no /debug(please make sure use _ _ to inclose CL and LINK, since _ _ will style text Italic here )set ASAN_OPTIONS=detect_odr_violation=0cmake --build . --config Release
Setup
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIssues
Activity
bellenot commentedon Jan 10, 2022
Here are the errors I got when following your receipe:
bellenot commentedon Jan 12, 2022
@wmyyy so I can't build with ASAN on Windows (see errors above). But it's weird that you don't have the same errors. And about the "The items cannot be built in parallel.", it's fine, it's only an informative message
wmyyy commentedon Jan 21, 2022
Hi @bellenot,

Very sorry for the late response, could you please check if you install "C++ Address Sanitizer" components in Visual studio?
Thanks
bellenot commentedon Jan 21, 2022
@wmyyy Good point. I'll try and let you know
bellenot commentedon Jan 21, 2022
@wmyyy I just checked and I have the "C++ Address Sanitizer" component in Visual studio.
wmyyy commentedon Jan 25, 2022
Hi @bellenot,

Can you check if you installed these two components as well?
If it still not work, can you try to set include path? for example: set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\crt\src;%INCLUDE%
Thanks
bellenot commentedon Jan 25, 2022
Still no luck, even when adding
I still have the following error:
I'll investigate more. And BTW, I see that:
and then
So you compile in release mode and link in debug mode? Really?
wmyyy commentedon Jan 26, 2022
Hi bellenot, link option /debug creates debugging information for the executable. And this option is not really required, you can ignore it.
bellenot commentedon Jul 22, 2022
OK, back to this. For the record, the working syntax (for me) is:
And at the end of the build I got:
So not the same error with VS 2022 (64 bit). Will try in Debug mode and let you know. And since the errors are different between VS 2019 and 2022, I suspect an incompatibility between LLVM/Clang and Visual Studio. We'll see how it goes after the LLVM upgrade.
bellenot commentedon Jul 28, 2022
So I can reproduce the error in 32 bit mode. But the 64 bit mode fails as previously reported. Le's see how it goes after the LLVM upgrade.
dpiparo commentedon Apr 25, 2024
Hi @bellenot . LLVM is now at version 16: is this still an issue? Can it be closed?
bellenot commentedon Apr 25, 2024
I'll try
bellenot commentedon Apr 25, 2024
So it still fails with LLVM 16
bellenot commentedon Sep 24, 2024
Back to this. I got sanitizer errors with ROOT master, like for example:
Now I don't know how to fix those errors, but at least they look like real sanitizer output...
pcanal commentedon Sep 24, 2024
The
read after deleteinROOT::Internal::DeleteChangesMemoryImplis intentional :( ... We are literally probing what is the consequence of calling delete on the deleted memory.bellenot commentedon Sep 25, 2024
@pcanal cool, thanks for the info! Now I have to find how to prevent the build to fail because of this...
pcanal commentedon Sep 26, 2024
Maybe Visual Studio has something like https://clang.llvm.org/docs/SanitizerSpecialCaseList.html
bellenot commentedon Sep 27, 2024
I found how to disable the sanitizer with
__declspec(no_sanitize_address),but it doesn't preventheap-use-after-freeat run-time. So my solution (hack) for the time being is the following:pcanal commentedon Sep 27, 2024
I think the 'hack' is fine and appropriate since one of the thing we can do after this testing is check for double deletes! So when the sanitizer is on, it does not really hurt to mark this feature as disabled.
[win][ASAN] Fix ASAN build on Windows
[win][ASAN] Fix ASAN build on Windows (#16586)
bellenot commentedon Oct 11, 2024
@wmyyy BTW, see also this commit
[win][ASAN] Fix ASAN build on Windows (root-project#16586)