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

Hit errors when build ROOT with msvc on AddressSanitizer mode #9445

Open
wmyyy opened this issue Dec 16, 2021 · 13 comments
Open

Hit errors when build ROOT with msvc on AddressSanitizer mode #9445

wmyyy opened this issue Dec 16, 2021 · 13 comments
Assignees
Labels

Comments

@wmyyy
Copy link

wmyyy commented Dec 16, 2021

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

  1. Open a x86 Native Tools Command Prompt for VS 2019
  2. git clone https://github.com/root-project/root.git root_src
  3. mkdir root_build && cd root_build
  4. cmake -G"Visual Studio 16 2019" -A Win32 -Dtesting=ON -Droottest=ON ../root_src
  5. set _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 )
  6. set ASAN_OPTIONS=detect_odr_violation=0
  7. cmake --build . --config Release

Setup

@bellenot
Copy link
Member

Here are the errors I got when following your receipe:

...
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangAttrEmitter.cpp) [C:\Users\bel
lenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangASTNodesEmitter.cpp) [C:\Users
\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangSACheckersEmitter.cpp) [C:\Use
rs\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangCommentCommandInfoEmitter.cpp)
 [C:\Users\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxp
roj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\NeonEmitter.cpp) [C:\Users\bellenot
\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangDiagnosticsEmitter.cpp) [C:\Us
ers\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangOpenCLBuiltinEmitter.cpp) [C:\
Users\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangOptionDocEmitter.cpp) [C:\User
s\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangDataCollectorsEmitter.cpp) [C:
\Users\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangCommentHTMLNamedCharacterRefer
enceEmitter.cpp) [C:\Users\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.c
lang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\TableGen.cpp) [C:\Users\bellenot\bu
ild\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj]
C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory (compiling source file C:\
Users\bellenot\git\master\interpreter\llvm\src\tools\clang\utils\TableGen\ClangCommentHTMLTagsEmitter.cpp) [C
:\Users\bellenot\build\x86\sanitizer\interpreter\llvm\src\tools\clang\utils\TableGen\obj.clang-tblgen.vcxproj
... 

@bellenot
Copy link
Member

@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
Copy link
Author

wmyyy commented Jan 21, 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

Hi @bellenot,
Very sorry for the late response, could you please check if you install "C++ Address Sanitizer" components in Visual studio?
image

Thanks

@bellenot
Copy link
Member

bellenot commented Jan 21, 2022

@wmyyy Good point. I'll try and let you know

@bellenot
Copy link
Member

bellenot commented Jan 21, 2022

@wmyyy I just checked and I have the "C++ Address Sanitizer" component in Visual studio.

@wmyyy
Copy link
Author

wmyyy commented Jan 25, 2022

Hi @bellenot,
Can you check if you installed these two components as well?
image
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
Copy link
Member

Still no luck, even when adding

set INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\lib\clang\12.0.0\include";%INCLUDE%

I still have the following error:

C:\Users\bellenot\git\master\interpreter\llvm\src\include\llvm/Support/Compiler.h(408,11): fatal error C1083:
 Cannot open include file: 'sanitizer/asan_interface.h': No such file or directory

I'll investigate more. And BTW, I see that:

set _LINK_= /InferASanLibs /incremental:no /debug

and then

cmake --build . --config Release

So you compile in release mode and link in debug mode? Really?

@wmyyy
Copy link
Author

wmyyy commented 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
Copy link
Member

bellenot commented Jul 22, 2022

OK, back to this. For the record, the working syntax (for me) is:

set _CL_= /fsanitize=address /wd5072 /I"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\crt\src" & set _LINK_= /InferASanLibs /incremental:no /debug
set ASAN_OPTIONS=detect_odr_violation=0

And at the end of the build I got:

  Generating tutorials/hsimple.root
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets
(245,5): error MSB8066: Custom build for 'C:\Users\sftnight\build\x64\ASAN\CMakeFiles\c6c09d13817678206ffac31
1bf59f66e\hsimple.root.rule;C:\Users\sftnight\build\x64\ASAN\CMakeFiles\9f4ed4473669458dfc17172b1f87108d\hsim
ple.rule' exited with code -1073741515. [C:\Users\sftnight\build\x64\ASAN\hsimple.vcxproj]
Done Building Project "C:\Users\sftnight\build\x64\ASAN\hsimple.vcxproj" (default targets) -- FAILED.

Done Building Project "C:\Users\sftnight\build\x64\ASAN\ALL_BUILD.vcxproj" (default targets) -- FAILED.

Build FAILED.

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
Copy link
Member

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
Copy link
Member

dpiparo commented Apr 25, 2024

Hi @bellenot . LLVM is now at version 16: is this still an issue? Can it be closed?

@bellenot
Copy link
Member

Hi @bellenot . LLVM is now at version 16: is this still an issue? Can it be closed?

I'll try

@bellenot
Copy link
Member

So it still fails with LLVM 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants