Skip to content

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

Closed

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

Activity

  1. bellenot commented on Jan 10, 2022

    @bellenot
    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
    ... 
    
  2. bellenot commented on Jan 12, 2022

    @bellenot
    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

  3. wmyyy commented on Jan 21, 2022

    @wmyyy
    Author

    @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

  4. bellenot commented on Jan 21, 2022

    @bellenot
    Member

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

  5. bellenot commented on Jan 21, 2022

    @bellenot
    Member

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

  6. wmyyy commented on Jan 25, 2022

    @wmyyy
    Author

    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

  7. bellenot commented on Jan 25, 2022

    @bellenot
    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?

  8. wmyyy commented on Jan 26, 2022

    @wmyyy
    Author

    Hi bellenot, link option /debug creates debugging information for the executable. And this option is not really required, you can ignore it.

  9. bellenot commented on Jul 22, 2022

    @bellenot
    Member

    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.

  10. bellenot commented on Jul 28, 2022

    @bellenot
    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.

  11. dpiparo commented on Apr 25, 2024

    @dpiparo
    Member

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

  12. bellenot commented on Apr 25, 2024

    @bellenot
    Member

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

    I'll try

  13. bellenot commented on Apr 25, 2024

    @bellenot
    Member

    So it still fails with LLVM 16

  14. bellenot commented on Sep 24, 2024

    @bellenot
    Member

    Back to this. I got sanitizer errors with ROOT master, like for example:

      Generating G__ROOTVecOps.cxx, ../../bin/libROOTVecOps_rdict.pcm, ../../bin/libROOTVecOps.rootmap
      =================================================================
      ==13496==ERROR: AddressSanitizer: heap-use-after-free on address 0x1262507beddc at pc 0x7ffdb6b7a85c bp 0x008d589d7da0 sp 0x008d589d7da8
      READ of size 4 at 0x1262507beddc thread T0
          #0 0x7ffdb6b7a85b in ROOT::Internal::DeleteChangesMemoryImpl(void) C:\root-dev\git\master\core\base\src\TObject.cxx:120
          #1 0x7ffdb6b7a543 in ROOT::Internal::DeleteChangesMemory(void) C:\root-dev\git\master\core\base\src\TObject.cxx:129
          #2 0x7ffdb6c4f848 in ROOT::Detail::HasBeenDeleted C:\root-dev\git\master\core\base\inc\TObject.h:403
          #3 0x7ffdb6c4f848 in TList::FindLink(class TObject const *, int &) const C:\root-dev\git\master\core\cont\src\TList.cxx:644
          #4 0x7ffdb6c519d5 in TList::Remove(class TObject *) C:\root-dev\git\master\core\cont\src\TList.cxx:827
          #5 0x7ffdb6c44e76 in THashList::RecursiveRemove(class TObject *) C:\root-dev\git\master\core\cont\src\THashList.cxx:335
          #6 0x7ffdb6bb56a5 in TROOT::RecursiveRemove(class TObject *) C:\root-dev\git\master\core\base\src\TROOT.cxx:2502
          #7 0x7ffdb6b54712 in ROOT::CallRecursiveRemoveIfNeeded(class TObject &) C:\root-dev\git\master\core\base\inc\TROOT.h:400
          #8 0x7ffdb6b7993d in TObject::~TObject(void) C:\root-dev\git\master\core\base\src\TObject.cxx:163
          #9 0x7ffdb6cc03ae in ROOT::Internal::TCheckHashRecursiveRemoveConsistency::~TCheckHashRecursiveRemoveConsistency(void) C:\root-dev\git\master\core\meta\src\TCheckHashRecursiveRemoveConsistency.h
      :68
          #10 0x7ffdb6cd5c65 in TClass::HasConsistentHashMember(void) C:\root-dev\git\master\core\meta\inc\TClass.h:504
          #11 0x7ffdb6cd5838 in ROOT::Internal::HasConsistentHashMember(class TClass &) C:\root-dev\git\master\core\meta\src\TClass.cxx:7373
          #12 0x7ffdb6c54bc2 in TPair::CheckTObjectHashConsistency(void) const C:\root-dev\git\master\core\cont\inc\TMap.h:124
          #13 0x7ffdb6c48449 in THashTable::GetCheckedHashValue(class TObject *) const C:\root-dev\git\master\core\cont\inc\THashTable.h:95
          #14 0x7ffdb6c46bf3 in THashTable::Add(class TObject *) C:\root-dev\git\master\core\cont\src\THashTable.cxx:96
          #15 0x7ffdb6c5468d in TMap::Add(class TObject *, class TObject *) C:\root-dev\git\master\core\cont\src\TMap.cxx:66
          #16 0x7ffdb6c0921e in TUrl::ParseOptions(void) const C:\root-dev\git\master\core\base\src\TUrl.cxx:645
          #17 0x7ffdb6c08ce9 in TUrl::HasOption(char const *) const C:\root-dev\git\master\core\base\src\TUrl.cxx:686
          #18 0x7ffdcaa6f611 in TFile::TFile(char const *, char const *, char const *, int) C:\root-dev\git\master\io\io\src\TFile.cxx:388
          #19 0x7ffdcad8b4ab in CloseStreamerInfoROOTFile C:\root-dev\git\master\io\rootpcm\src\rootclingIO.cxx:143
          #20 0x7ffdb74e8b32 in FinalizeStreamerInfoWriting(class cling::Interpreter &, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:2644
          #21 0x7ffdb74ebcc2 in GenerateFullDict(class std::basic_ostream<char, struct std::char_traits<char>> &, class cling::Interpreter &, class RScanner &, class std::list<class ROOT::TMetaUtils::RCon
      structorType, class std::allocator<class ROOT::TMetaUtils::RConstructorType>> const &, bool, bool, bool, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:2803
          #22 0x7ffdb7505b1e in RootClingMain(int, char **, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:4962
          #23 0x7ffdb752c30d in ROOT_rootcling_Driver C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:6251
          #24 0x7ff7a76c12f5 in main C:\root-dev\git\master\main\src\rootcling.cxx:43
          #25 0x7ff7a76c2493 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
          #26 0x7ff7a76c2493 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
          #27 0x7ffe2028257c  (C:\Windows\System32\KERNEL32.DLL+0x18001257c)
          #28 0x7ffe20a4af27  (C:\Windows\SYSTEM32\ntdll.dll+0x18005af27)
    
      0x1262507beddc is located 12 bytes inside of 16-byte region [0x1262507bedd0,0x1262507bede0)
      freed by thread T0 here:
          #0 0x7ffdb6f705a5 in operator delete(void *) D:\a\_work\1\s\src\vctools\asan\llvm\compiler-rt\lib\asan\asan_win_delete_scalar_thunk.cpp:42
          #1 0x7ffdb6bbaa78 in TStorage::ObjectDealloc(void *) C:\root-dev\git\master\core\base\src\TStorage.cxx:325
          #2 0x7ffdb6b79a01 in TObject::operator delete(void *) C:\root-dev\git\master\core\base\src\TObject.cxx:1095
          #3 0x7ffdb6da535a in TObject::`vector deleting dtor'(unsigned int) (C:\root-dev\build\x64\relwithdebinfo\bin\libCore.dll+0x1802a535a)
          #4 0x7ffdb6b7a838 in ROOT::Internal::DeleteChangesMemoryImpl(void) C:\root-dev\git\master\core\base\src\TObject.cxx:113
          #5 0x7ffdb6b7a543 in ROOT::Internal::DeleteChangesMemory(void) C:\root-dev\git\master\core\base\src\TObject.cxx:129
          #6 0x7ffdb6c4f848 in ROOT::Detail::HasBeenDeleted C:\root-dev\git\master\core\base\inc\TObject.h:403
          #7 0x7ffdb6c4f848 in TList::FindLink(class TObject const *, int &) const C:\root-dev\git\master\core\cont\src\TList.cxx:644
          #8 0x7ffdb6c519d5 in TList::Remove(class TObject *) C:\root-dev\git\master\core\cont\src\TList.cxx:827
          #9 0x7ffdb6c44e76 in THashList::RecursiveRemove(class TObject *) C:\root-dev\git\master\core\cont\src\THashList.cxx:335
          #10 0x7ffdb6bb56a5 in TROOT::RecursiveRemove(class TObject *) C:\root-dev\git\master\core\base\src\TROOT.cxx:2502
          #11 0x7ffdb6b54712 in ROOT::CallRecursiveRemoveIfNeeded(class TObject &) C:\root-dev\git\master\core\base\inc\TROOT.h:400
          #12 0x7ffdb6b7993d in TObject::~TObject(void) C:\root-dev\git\master\core\base\src\TObject.cxx:163
          #13 0x7ffdb6cc03ae in ROOT::Internal::TCheckHashRecursiveRemoveConsistency::~TCheckHashRecursiveRemoveConsistency(void) C:\root-dev\git\master\core\meta\src\TCheckHashRecursiveRemoveConsistency.
      h:68
          #14 0x7ffdb6cd5c65 in TClass::HasConsistentHashMember(void) C:\root-dev\git\master\core\meta\inc\TClass.h:504
          #15 0x7ffdb6cd5838 in ROOT::Internal::HasConsistentHashMember(class TClass &) C:\root-dev\git\master\core\meta\src\TClass.cxx:7373
          #16 0x7ffdb6c54bc2 in TPair::CheckTObjectHashConsistency(void) const C:\root-dev\git\master\core\cont\inc\TMap.h:124
          #17 0x7ffdb6c48449 in THashTable::GetCheckedHashValue(class TObject *) const C:\root-dev\git\master\core\cont\inc\THashTable.h:95
          #18 0x7ffdb6c46bf3 in THashTable::Add(class TObject *) C:\root-dev\git\master\core\cont\src\THashTable.cxx:96
          #19 0x7ffdb6c5468d in TMap::Add(class TObject *, class TObject *) C:\root-dev\git\master\core\cont\src\TMap.cxx:66
          #20 0x7ffdb6c0921e in TUrl::ParseOptions(void) const C:\root-dev\git\master\core\base\src\TUrl.cxx:645
          #21 0x7ffdb6c08ce9 in TUrl::HasOption(char const *) const C:\root-dev\git\master\core\base\src\TUrl.cxx:686
          #22 0x7ffdcaa6f611 in TFile::TFile(char const *, char const *, char const *, int) C:\root-dev\git\master\io\io\src\TFile.cxx:388
          #23 0x7ffdcad8b4ab in CloseStreamerInfoROOTFile C:\root-dev\git\master\io\rootpcm\src\rootclingIO.cxx:143
          #24 0x7ffdb74e8b32 in FinalizeStreamerInfoWriting(class cling::Interpreter &, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:2644
          #25 0x7ffdb74ebcc2 in GenerateFullDict(class std::basic_ostream<char, struct std::char_traits<char>> &, class cling::Interpreter &, class RScanner &, class std::list<class ROOT::TMetaUtils::RCon
      structorType, class std::allocator<class ROOT::TMetaUtils::RConstructorType>> const &, bool, bool, bool, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:2803
          #26 0x7ffdb7505b1e in RootClingMain(int, char **, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:4962
          #27 0x7ffdb752c30d in ROOT_rootcling_Driver C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:6251
          #28 0x7ff7a76c12f5 in main C:\root-dev\git\master\main\src\rootcling.cxx:43
          #29 0x7ff7a76c2493 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
          #30 0x7ff7a76c2493 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    
      previously allocated by thread T0 here:
          #0 0x7ffdb6f701c5 in operator new(unsigned __int64) D:\a\_work\1\s\src\vctools\asan\llvm\compiler-rt\lib\asan\asan_win_new_scalar_thunk.cpp:40
          #1 0x7ffdb6bbaa11 in TStorage::ObjectAlloc(unsigned __int64) C:\root-dev\git\master\core\base\src\TStorage.cxx:293
          #2 0x7ffdb6b7a5db in TObject::operator new C:\root-dev\git\master\core\base\inc\TObject.h:181
          #3 0x7ffdb6b7a5db in ROOT::Internal::DeleteChangesMemoryImpl(void) C:\root-dev\git\master\core\base\src\TObject.cxx:81
          #4 0x7ffdb6b7a543 in ROOT::Internal::DeleteChangesMemory(void) C:\root-dev\git\master\core\base\src\TObject.cxx:129
          #5 0x7ffdb6c4f848 in ROOT::Detail::HasBeenDeleted C:\root-dev\git\master\core\base\inc\TObject.h:403
          #6 0x7ffdb6c4f848 in TList::FindLink(class TObject const *, int &) const C:\root-dev\git\master\core\cont\src\TList.cxx:644
          #7 0x7ffdb6c519d5 in TList::Remove(class TObject *) C:\root-dev\git\master\core\cont\src\TList.cxx:827
          #8 0x7ffdb6c44e76 in THashList::RecursiveRemove(class TObject *) C:\root-dev\git\master\core\cont\src\THashList.cxx:335
          #9 0x7ffdb6bb56a5 in TROOT::RecursiveRemove(class TObject *) C:\root-dev\git\master\core\base\src\TROOT.cxx:2502
          #10 0x7ffdb6b54712 in ROOT::CallRecursiveRemoveIfNeeded(class TObject &) C:\root-dev\git\master\core\base\inc\TROOT.h:400
          #11 0x7ffdb6b7993d in TObject::~TObject(void) C:\root-dev\git\master\core\base\src\TObject.cxx:163
          #12 0x7ffdb6cc03ae in ROOT::Internal::TCheckHashRecursiveRemoveConsistency::~TCheckHashRecursiveRemoveConsistency(void) C:\root-dev\git\master\core\meta\src\TCheckHashRecursiveRemoveConsistency.
      h:68
          #13 0x7ffdb6cd5c65 in TClass::HasConsistentHashMember(void) C:\root-dev\git\master\core\meta\inc\TClass.h:504
          #14 0x7ffdb6cd5838 in ROOT::Internal::HasConsistentHashMember(class TClass &) C:\root-dev\git\master\core\meta\src\TClass.cxx:7373
          #15 0x7ffdb6c54bc2 in TPair::CheckTObjectHashConsistency(void) const C:\root-dev\git\master\core\cont\inc\TMap.h:124
          #16 0x7ffdb6c48449 in THashTable::GetCheckedHashValue(class TObject *) const C:\root-dev\git\master\core\cont\inc\THashTable.h:95
          #17 0x7ffdb6c46bf3 in THashTable::Add(class TObject *) C:\root-dev\git\master\core\cont\src\THashTable.cxx:96
          #18 0x7ffdb6c5468d in TMap::Add(class TObject *, class TObject *) C:\root-dev\git\master\core\cont\src\TMap.cxx:66
          #19 0x7ffdb6c0921e in TUrl::ParseOptions(void) const C:\root-dev\git\master\core\base\src\TUrl.cxx:645
          #20 0x7ffdb6c08ce9 in TUrl::HasOption(char const *) const C:\root-dev\git\master\core\base\src\TUrl.cxx:686
          #21 0x7ffdcaa6f611 in TFile::TFile(char const *, char const *, char const *, int) C:\root-dev\git\master\io\io\src\TFile.cxx:388
          #22 0x7ffdcad8b4ab in CloseStreamerInfoROOTFile C:\root-dev\git\master\io\rootpcm\src\rootclingIO.cxx:143
          #23 0x7ffdb74e8b32 in FinalizeStreamerInfoWriting(class cling::Interpreter &, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:2644
          #24 0x7ffdb74ebcc2 in GenerateFullDict(class std::basic_ostream<char, struct std::char_traits<char>> &, class cling::Interpreter &, class RScanner &, class std::list<class ROOT::TMetaUtils::RCon
      structorType, class std::allocator<class ROOT::TMetaUtils::RConstructorType>> const &, bool, bool, bool, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:2803
          #25 0x7ffdb7505b1e in RootClingMain(int, char **, bool) C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:4962
          #26 0x7ffdb752c30d in ROOT_rootcling_Driver C:\root-dev\git\master\core\dictgen\src\rootcling_impl.cxx:6251
          #27 0x7ff7a76c12f5 in main C:\root-dev\git\master\main\src\rootcling.cxx:43
          #28 0x7ff7a76c2493 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
          #29 0x7ff7a76c2493 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
          #30 0x7ffe2028257c  (C:\Windows\System32\KERNEL32.DLL+0x18001257c)
          #31 0x7ffe20a4af27  (C:\Windows\SYSTEM32\ntdll.dll+0x18005af27)
    
      SUMMARY: AddressSanitizer: heap-use-after-free C:\root-dev\git\master\core\base\src\TObject.cxx:120 in ROOT::Internal::DeleteChangesMemoryImpl(void)
      Shadow bytes around the buggy address:
        0x1262507beb00: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
        0x1262507beb80: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
        0x1262507bec00: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
        0x1262507bec80: fa fa fd fd fa fa fd fd fa fa fd fd fa fa 00 00
        0x1262507bed00: fa fa fd fd fa fa 00 00 fa fa 00 00 fa fa 00 fa
      =>0x1262507bed80: fa fa 00 fa fa fa 00 fa fa fa fd[fd]fa fa fa fa
        0x1262507bee00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x1262507bee80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x1262507bef00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x1262507bef80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x1262507bf000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07
        Heap left redzone:       fa
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      ==13496==ABORTING
    C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'C:\root-dev\build\x64\relwithdebinfo\CMakeFiles\6d5
    58ca9313984d42dbbac9eac898107\G__ROOTVecOps.cxx.rule' exited with code 1. [C:\root-dev\build\x64\relwithdebinfo\math\vecops\G__ROOTVecOps.vcxproj]
    

    Now I don't know how to fix those errors, but at least they look like real sanitizer output...

  15. pcanal commented on Sep 24, 2024

    @pcanal
    Member

    The read after delete in ROOT::Internal::DeleteChangesMemoryImpl is intentional :( ... We are literally probing what is the consequence of calling delete on the deleted memory.

  16. bellenot commented on Sep 25, 2024

    @bellenot
    Member

    @pcanal cool, thanks for the info! Now I have to find how to prevent the build to fail because of this...

  17. pcanal commented on Sep 26, 2024

    @pcanal
    Member

    Maybe Visual Studio has something like https://clang.llvm.org/docs/SanitizerSpecialCaseList.html

  18. bellenot commented on Sep 27, 2024

    @bellenot
    Member

    I found how to disable the sanitizer with __declspec(no_sanitize_address), but it doesn't prevent heap-use-after-free at run-time. So my solution (hack) for the time being is the following:

    diff --git a/core/base/src/TObject.cxx b/core/base/src/TObject.cxx
    index 1fdabcc2fd..c5358d1f21 100644
    --- a/core/base/src/TObject.cxx
    +++ b/core/base/src/TObject.cxx
    @@ -117,11 +127,15 @@ bool DeleteChangesMemoryImpl()
        // can guess this is always the case and we can rely on the changes to fBits made
        // by ~TObject to detect use-after-delete error (and print a message rather than
        // stop the program with a segmentation fault)
    +#ifndef __SANITIZE_ADDRESS__
        if ( *o_fbits != 0x01000000 ) {
           // operator delete tainted the memory, we can not rely on TestBit(kNotDeleted)
           return true;
        }
        return false;
    +#else
    +   return true;
    +#endif
     }
    
  19. pcanal commented on Sep 27, 2024

    @pcanal
    Member

    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.

  20. added a commit that references this issue on Oct 3, 2024
  21. bellenot commented on Oct 11, 2024

    @bellenot
    Member

    @wmyyy BTW, see also this commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions