Skip to content

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

@wmyyy

Description

@wmyyy

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions