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

Develop and test enum #2

Closed

Conversation

CristinaCristescu
Copy link
Contributor

So here are the changes that I needed to make from the comments of the last pull request and some other changes:

  1. I've added the name for a enum constant because I realised when declaring kMyConstant = 42 that I didn't save the name.

  2. I've added some checks in the TCling to see if the TEnum and TEnumConstants are actually created, because when I run the test:
    // MyEnumComment
    enum EMyEnum {
    kMyEnumConstant = 42 // enumConstantComment
    };

    int assertTEnum()
    {

  if (!(TEnum*)gROOT->GetListOfEnums()->FindObject("EMyEnum")) {
     Error ("TEnum", "Constructor of TEnum failure.");
     return -1;

}
It does return and Error. I tried that on the root[0] promp as well and the address of GetListOfEnum is not NULL(because the HashTable is created), but the address of FindObject is 0x0.
Now I don't get the Errors of TEnum and TEnumConstant are not created..I wanted to check whether they are added to the fEnums and fGlobals, but Add() for TCollection is a void function. My best guess is that they are not added to the lists, maybe you can see why...

CristinaCristescu and others added 27 commits August 8, 2013 17:09
…of the load instruction.

Currently, there are four kinds of instruction that may use a load instruction as its argument:
load, store, GEP and call instruction. We instrument these four kinds instruction to check there
may be a null pointer dereference.
This will make sure that the build is 'consistent' and
the source version of the cling include files is not
superseeded by the (possible stale) copy that might
be in interpreter/llvm/inst.
In the value printer synthesis we have real source location of the expression
that we are replacing. Use its begin and end location.
This will allow us to remove the XFAIL-ed test that now passes.
pcanal added a commit that referenced this pull request Sep 11, 2014
With the unique_ptr, we were crash due to the held over reference described
below.  Trying to move the m_ExternalSemaSource deletion after the m_IncrParser
deletion also leads to crash due to the double deletion (once by the ASTContext,
once by m_ExternalSemaSource) of the ExternalSemaSource.

If m_Callbacks is declared after m_IncrParser, it will be deleted first
and if m_ExternalSemaSource is a unique_ptr, it willbe deleted before
m_IncrParser is delete.

During the Incremental parser deletion, there is a call to
CodeGenModule::Release, then EmitTargetMetdata is called and it tries to
get the most recent decl which calls
     clang::LazyGenerationalUpdatePtr<...>::get
which has a LazyVal which has a cached pointer to the AST external
source.  So this placement is necessary to solve a tear down crash.

#0  clang::LazyGenerationalUpdatePtr<clang::Decl const*, clang::Decl*, &(clang::ExternalASTSource::CompleteRedeclChain(clang::Decl const*))>::get (this=0x7fff5fbfe0e0, O=0x1069c3f90) at ExternalASTSource.h:428
428	        (LazyVal->ExternalSource->*Update)(O);
(gdb) l
423	  /// Get the value of this pointer, updating its owner if necessary.
424	  T get(Owner O) {
425	    if (LazyData *LazyVal = Value.template dyn_cast<LazyData*>()) {
426	      if (LazyVal->LastGeneration != LazyVal->ExternalSource->getGeneration()) {
427	        LazyVal->LastGeneration = LazyVal->ExternalSource->getGeneration();
428	        (LazyVal->ExternalSource->*Update)(O);
429	      }
430	      return LazyVal->LastValue;
431	    }
432	    return Value.template get<T>();

#0  clang::LazyGenerationalUpdatePtr<clang::Decl const*, clang::Decl*, &(clang::ExternalASTSource::CompleteRedeclChain(clang::Decl const*))>::get (this=0x7fff5fbfe0e0, O=0x1069c3f90) at ExternalASTSource.h:428
#1  0x000000010005ce38 in clang::Redeclarable<clang::FunctionDecl>::DeclLink::getNext (this=0x1069c3ff0, D=0x1069c3f90) at Redeclarable.h:74
#2  0x000000010005cd81 in clang::Redeclarable<clang::FunctionDecl>::getNextRedeclaration (this=0x1069c3ff0) at Redeclarable.h:119
#3  0x000000010005d0b3 in clang::Redeclarable<clang::FunctionDecl>::getMostRecentDecl (this=0x1069c3ff0) at Redeclarable.h:161
#4  0x000000010137bfdc in clang::FunctionDecl::getMostRecentDeclImpl (this=0x1069c3f90) at Decl.h:1568
#5  0x00000001004b5346 in clang::Decl::getMostRecentDecl (this=0x1069c3f90) at DeclBase.h:806
#6  0x0000000100897128 in clang::CodeGen::CodeGenModule::EmitTargetMetadata (this=0x10689aa00) at /Users/pcanal/root_working/code/rootcling/interpreter/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:3271
#7  0x0000000100895237 in clang::CodeGen::CodeGenModule::Release (this=0x10689aa00) at /Users/pcanal/root_working/code/rootcling/interpreter/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:395
#8  0x0000000100981b3c in clang::CodeGeneratorImpl::ReleaseModule (this=0x106506d70) at /Users/pcanal/root_working/code/rootcling/interpreter/llvm/src/tools/clang/lib/CodeGen/ModuleBuilder.cpp:82
#9  0x00000001001c3f88 in ~IncrementalParser (this=0x1065047e0) at /Users/pcanal/root_working/code/rootcling/interpreter/cling/lib/Interpreter/IncrementalParser.cpp:168
#10 0x00000001001c3f25 in ~IncrementalParser (this=0x1065047e0) at /Users/pcanal/root_working/code/rootcling/interpreter/cling/lib/Interpreter/IncrementalParser.cpp:166
#11 0x00000001001d8905 in std::__1::default_delete<cling::IncrementalParser>::operator() () at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/memory:2426
#12 0x00000001001d8905 in ~unique_ptr [inlined] () at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/memory:2625
#13 0x00000001001d8905 in ~Interpreter (this=0x7fff5fbff020) at memory:2593
#14 0x00000001001d8355 in ~Interpreter (this=0x7fff5fbff020) at /Users/pcanal/root_working/code/rootcling/interpreter/cling/lib/Interpreter/Interpreter.cpp:229
#15 0x00000001002b0318 in main (argc=1, argv=0x7fff5fbff740) at /Users/pcanal/root_working/code/rootcling/interpreter/cling/tools/driver/cling.cpp:97
FonsRademakers pushed a commit that referenced this pull request Nov 14, 2015
ROOT needs reflection information about classes. One way to incorporate this
information is to use a ClassDef macro, which adds a few members to the
classes. For example, how to read/write the class on disk (aka streamer).
The ClassDef adds forward declaration of a streamer function (and a few others)
in the body of the class. Later on a special tool (aka rootcling) defines the
forward declarations unless told otherwise by the dictionary generation driver
(aka Linkdef file). Simply explained, the ROOT IO-aware class *declare* a few
functions, whoose definitions will come from a dictionary.

As always the interesting part comes when C++ templates come around. Depending
on the order of the header files, which appear in the dictionaries the template
class can be instantiated. For example:
A.h: template<class T> struct TMyClassT { ...; ClassDef(MyClassT, 1); };
B.h: struct S { TMyClassT<int> var; };
G__: #include "A.h" // #1
     #include "B.h" // #2
    // Definitions of the contents of the ClassDef.
B.h forces an implicit instantiation of TMyClassT *before* the compiler can see
the definitions of the ClassDef. Namely,
template <> TClass *TMyClassT<int>::Class(){} is seen after #2 when the compiler
has instantiated it. C++ 14.7.3/6 explains it as:
"If a template, a member template or a member of a class template is explicitly
specialized then that specialization shall be declared before the first use of
that specialization that would cause an implicit instantiation to take place, in
every translation unit in which such a use occurs; no diagnostic is required."
Saying that what we do makes the TU ill-formed but no diagnostic is required.

Modules are more strict in that respect and issue diagnostics. This commit
introduces a workaround while the actual solution to the problem is being
developed. As Axel and I discussed a real solution would be to implement a
ClassDef macro which inlines the contents, disallowing custom streamers
covering 99.9% of the cases.
scott-snyder pushed a commit to scott-snyder/root that referenced this pull request Apr 3, 2022
With gcc12 headers, i see a cling failure.  In dbg:


[sss@karma dvtest]$ genreflex x.h --selection_file=sel.xml -o x_gen.cxx -Ixheaders 2>&1|tee log

genreflex: /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257: clang::QualType clang::TemplateArgument::getAsType() const: Assertion `getKind() == Type && "Unexpected kind"' failed.
 #0 0x00007f4124e1bac2 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:533:22
 root-project#1 0x00007f4124e1bb5e PrintStackTraceSignalHandler(void*) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:594:1
 root-project#2 0x00007f4124e19bd7 llvm::sys::RunSignalHandlers() /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Signals.cpp:68:20
 root-project#3 0x00007f4124e1b53c SignalHandler(int) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:385:1
 root-project#4 0x00007f411fc77a20 __restore_rt (/lib64/libpthread.so.0+0x13a20)
 root-project#5 0x00007f411f7502a2 raise (/lib64/libc.so.6+0x3d2a2)
 root-project#6 0x00007f411f7398a4 abort (/lib64/libc.so.6+0x268a4)
 root-project#7 0x00007f411f739789 _nl_load_domain.cold (/lib64/libc.so.6+0x26789)
 root-project#8 0x00007f411f748a16 (/lib64/libc.so.6+0x35a16)
 root-project#9 0x00007f4120a43c9d clang::TemplateArgument::getAsType() const /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257:5
root-project#10 0x00007f4120a57b3f ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType, clang::Type const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/clingutils/src/TClingUtils.cxx:4752:49
root-project#11 0x00007f4120a57c5b ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType, clang::Type const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/clingutils/src/TClingUtils.cxx:4775:58
root-project#12 0x00007f4120d05fd7 TClingBaseClassInfo::InternalNext(int) /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:341:67
root-project#13 0x00007f4120d06098 TClingBaseClassInfo::Next(int) /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:351:1
root-project#14 0x00007f4120d060b7 TClingBaseClassInfo::Next() /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:356:1
root-project#15 0x00007f4120bc82c1 TCling::CreateListOfBaseClasses(TClass*) const /home/sss/root/root-6.24.06/src/root/core/metacling/src/TCling.cxx:4267:17
root-project#16 0x00007f41200c4aa1 TClass::GetListOfBases() /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:3649:4
root-project#17 0x00007f41200c166a TClass::GetBaseClass(TClass const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:2659:37
root-project#18 0x00007f41200c16f2 TClass::GetBaseClass(TClass const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:2668:30
root-project#19 0x00007f41200c8cfe TClass::InheritsFrom(TClass const*) const /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:4889:38
root-project#20 0x00007f41200ccc8b TClass::Property() const /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:6054:4
root-project#21 0x00007f41200d0a69 TClass::IsClassStructOrUnion() const /home/sss/root/root-6.24.06/src/root/core/meta/inc/TClass.h:352:58
root-project#22 0x00007f41200c5141 TClass::GetListOfDataMembers(bool) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:3757:4
root-project#23 0x00007f412927255a CloseStreamerInfoROOTFile /home/sss/root/root-6.24.06/src/root/io/rootpcm/src/rootclingIO.cxx:162:42
root-project#24 0x00007f4120b2fc66 FinalizeStreamerInfoWriting(cling::Interpreter&, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:2627:8
root-project#25 0x00007f4120b3054e GenerateFullDict(std::ostream&, cling::Interpreter&, RScanner&, std::__cxx11::list<ROOT::TMetaUtils::RConstructorType, std::allocator<ROOT::TMetaUtils::RConstructorType> > const&, bool, bool, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:2769:51
root-project#26 0x00007f4120b3cec9 RootClingMain(int, char**, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:4861:43
root-project#27 0x00007f4120b40825 genreflex::invokeRootCling(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool, bool, bool, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:5326:46
root-project#28 0x00007f4120b426f6 GenReflexMain(int, char**) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:6026:36
root-project#29 0x00007f4120b42b8d ROOT_rootcling_Driver /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:6097:29
root-project#30 0x0000000000401259 main /home/sss/root/root-6.24.06/src/root/main/src/rootcling.cxx:43:51
root-project#31 0x00007f411f73ab75 __libc_start_main (/lib64/libc.so.6+0x27b75)
root-project#32 0x000000000040110e _start (/home/sss/root/root-6.24.06/rootsys/bin/genreflex+0x40110e)
Stack dump:
0.	Program arguments: rootcling -v2 -f x_gen.cxx -inlineInputHeader -Ixheaders x.h sel.xml 




sel.xml:
<lcgdict>
  <class pattern="*iterator<*pair<const*,const*"/>
</lcgdict>



x.h:
#include <string>
#include <map>
void foo (std::map<unsigned, std::string>& m, const std::string& s)
{
  m.emplace (0, s);
}


or:
#include <string>

template <class T>
struct tree_iterator {};

using value_type = std::pair<const unsigned, std::string>;
using xiterator = tree_iterator<value_type>;

class xtree
{
public:
  std::pair<xiterator, bool> emplace()
  {
    return  std::pair<xiterator, bool>(xiterator(), false);
  }
};


Difficult to reduce it further due to how rootcling implicitly
reads headers.
scott-snyder pushed a commit to scott-snyder/root that referenced this pull request Jun 2, 2022
With gcc12 headers, i see a cling failure.  In dbg:


[sss@karma dvtest]$ genreflex x.h --selection_file=sel.xml -o x_gen.cxx -Ixheaders 2>&1|tee log

genreflex: /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257: clang::QualType clang::TemplateArgument::getAsType() const: Assertion `getKind() == Type && "Unexpected kind"' failed.
 #0 0x00007f4124e1bac2 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:533:22
 root-project#1 0x00007f4124e1bb5e PrintStackTraceSignalHandler(void*) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:594:1
 root-project#2 0x00007f4124e19bd7 llvm::sys::RunSignalHandlers() /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Signals.cpp:68:20
 root-project#3 0x00007f4124e1b53c SignalHandler(int) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:385:1
 root-project#4 0x00007f411fc77a20 __restore_rt (/lib64/libpthread.so.0+0x13a20)
 root-project#5 0x00007f411f7502a2 raise (/lib64/libc.so.6+0x3d2a2)
 root-project#6 0x00007f411f7398a4 abort (/lib64/libc.so.6+0x268a4)
 root-project#7 0x00007f411f739789 _nl_load_domain.cold (/lib64/libc.so.6+0x26789)
 root-project#8 0x00007f411f748a16 (/lib64/libc.so.6+0x35a16)
 root-project#9 0x00007f4120a43c9d clang::TemplateArgument::getAsType() const /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257:5
root-project#10 0x00007f4120a57b3f ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType, clang::Type const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/clingutils/src/TClingUtils.cxx:4752:49
root-project#11 0x00007f4120a57c5b ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType, clang::Type const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/clingutils/src/TClingUtils.cxx:4775:58
root-project#12 0x00007f4120d05fd7 TClingBaseClassInfo::InternalNext(int) /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:341:67
root-project#13 0x00007f4120d06098 TClingBaseClassInfo::Next(int) /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:351:1
root-project#14 0x00007f4120d060b7 TClingBaseClassInfo::Next() /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:356:1
root-project#15 0x00007f4120bc82c1 TCling::CreateListOfBaseClasses(TClass*) const /home/sss/root/root-6.24.06/src/root/core/metacling/src/TCling.cxx:4267:17
root-project#16 0x00007f41200c4aa1 TClass::GetListOfBases() /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:3649:4
root-project#17 0x00007f41200c166a TClass::GetBaseClass(TClass const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:2659:37
root-project#18 0x00007f41200c16f2 TClass::GetBaseClass(TClass const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:2668:30
root-project#19 0x00007f41200c8cfe TClass::InheritsFrom(TClass const*) const /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:4889:38
root-project#20 0x00007f41200ccc8b TClass::Property() const /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:6054:4
root-project#21 0x00007f41200d0a69 TClass::IsClassStructOrUnion() const /home/sss/root/root-6.24.06/src/root/core/meta/inc/TClass.h:352:58
root-project#22 0x00007f41200c5141 TClass::GetListOfDataMembers(bool) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:3757:4
root-project#23 0x00007f412927255a CloseStreamerInfoROOTFile /home/sss/root/root-6.24.06/src/root/io/rootpcm/src/rootclingIO.cxx:162:42
root-project#24 0x00007f4120b2fc66 FinalizeStreamerInfoWriting(cling::Interpreter&, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:2627:8
root-project#25 0x00007f4120b3054e GenerateFullDict(std::ostream&, cling::Interpreter&, RScanner&, std::__cxx11::list<ROOT::TMetaUtils::RConstructorType, std::allocator<ROOT::TMetaUtils::RConstructorType> > const&, bool, bool, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:2769:51
root-project#26 0x00007f4120b3cec9 RootClingMain(int, char**, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:4861:43
root-project#27 0x00007f4120b40825 genreflex::invokeRootCling(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool, bool, bool, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:5326:46
root-project#28 0x00007f4120b426f6 GenReflexMain(int, char**) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:6026:36
root-project#29 0x00007f4120b42b8d ROOT_rootcling_Driver /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:6097:29
root-project#30 0x0000000000401259 main /home/sss/root/root-6.24.06/src/root/main/src/rootcling.cxx:43:51
root-project#31 0x00007f411f73ab75 __libc_start_main (/lib64/libc.so.6+0x27b75)
root-project#32 0x000000000040110e _start (/home/sss/root/root-6.24.06/rootsys/bin/genreflex+0x40110e)
Stack dump:
0.	Program arguments: rootcling -v2 -f x_gen.cxx -inlineInputHeader -Ixheaders x.h sel.xml 




sel.xml:
<lcgdict>
  <class pattern="*iterator<*pair<const*,const*"/>
</lcgdict>



x.h:
#include <string>
#include <map>
void foo (std::map<unsigned, std::string>& m, const std::string& s)
{
  m.emplace (0, s);
}


or:
#include <string>

template <class T>
struct tree_iterator {};

using value_type = std::pair<const unsigned, std::string>;
using xiterator = tree_iterator<value_type>;

class xtree
{
public:
  std::pair<xiterator, bool> emplace()
  {
    return  std::pair<xiterator, bool>(xiterator(), false);
  }
};


Difficult to reduce it further due to how rootcling implicitly
reads headers.
scott-snyder pushed a commit to scott-snyder/root that referenced this pull request Jun 3, 2022
With gcc12 headers, i see a cling failure.  In dbg:


[sss@karma dvtest]$ genreflex x.h --selection_file=sel.xml -o x_gen.cxx -Ixheaders 2>&1|tee log

genreflex: /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257: clang::QualType clang::TemplateArgument::getAsType() const: Assertion `getKind() == Type && "Unexpected kind"' failed.
 #0 0x00007f4124e1bac2 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:533:22
 root-project#1 0x00007f4124e1bb5e PrintStackTraceSignalHandler(void*) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:594:1
 root-project#2 0x00007f4124e19bd7 llvm::sys::RunSignalHandlers() /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Signals.cpp:68:20
 root-project#3 0x00007f4124e1b53c SignalHandler(int) /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/lib/Support/Unix/Signals.inc:385:1
 root-project#4 0x00007f411fc77a20 __restore_rt (/lib64/libpthread.so.0+0x13a20)
 root-project#5 0x00007f411f7502a2 raise (/lib64/libc.so.6+0x3d2a2)
 root-project#6 0x00007f411f7398a4 abort (/lib64/libc.so.6+0x268a4)
 root-project#7 0x00007f411f739789 _nl_load_domain.cold (/lib64/libc.so.6+0x26789)
 root-project#8 0x00007f411f748a16 (/lib64/libc.so.6+0x35a16)
 root-project#9 0x00007f4120a43c9d clang::TemplateArgument::getAsType() const /home/sss/root/root-6.24.06/src/root/interpreter/llvm/src/tools/clang/include/clang/AST/TemplateBase.h:257:5
root-project#10 0x00007f4120a57b3f ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType, clang::Type const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/clingutils/src/TClingUtils.cxx:4752:49
root-project#11 0x00007f4120a57c5b ROOT::TMetaUtils::ReSubstTemplateArg(clang::QualType, clang::Type const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/clingutils/src/TClingUtils.cxx:4775:58
root-project#12 0x00007f4120d05fd7 TClingBaseClassInfo::InternalNext(int) /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:341:67
root-project#13 0x00007f4120d06098 TClingBaseClassInfo::Next(int) /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:351:1
root-project#14 0x00007f4120d060b7 TClingBaseClassInfo::Next() /home/sss/root/root-6.24.06/src/root/core/metacling/src/TClingBaseClassInfo.cxx:356:1
root-project#15 0x00007f4120bc82c1 TCling::CreateListOfBaseClasses(TClass*) const /home/sss/root/root-6.24.06/src/root/core/metacling/src/TCling.cxx:4267:17
root-project#16 0x00007f41200c4aa1 TClass::GetListOfBases() /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:3649:4
root-project#17 0x00007f41200c166a TClass::GetBaseClass(TClass const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:2659:37
root-project#18 0x00007f41200c16f2 TClass::GetBaseClass(TClass const*) (.localalias) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:2668:30
root-project#19 0x00007f41200c8cfe TClass::InheritsFrom(TClass const*) const /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:4889:38
root-project#20 0x00007f41200ccc8b TClass::Property() const /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:6054:4
root-project#21 0x00007f41200d0a69 TClass::IsClassStructOrUnion() const /home/sss/root/root-6.24.06/src/root/core/meta/inc/TClass.h:352:58
root-project#22 0x00007f41200c5141 TClass::GetListOfDataMembers(bool) /home/sss/root/root-6.24.06/src/root/core/meta/src/TClass.cxx:3757:4
root-project#23 0x00007f412927255a CloseStreamerInfoROOTFile /home/sss/root/root-6.24.06/src/root/io/rootpcm/src/rootclingIO.cxx:162:42
root-project#24 0x00007f4120b2fc66 FinalizeStreamerInfoWriting(cling::Interpreter&, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:2627:8
root-project#25 0x00007f4120b3054e GenerateFullDict(std::ostream&, cling::Interpreter&, RScanner&, std::__cxx11::list<ROOT::TMetaUtils::RConstructorType, std::allocator<ROOT::TMetaUtils::RConstructorType> > const&, bool, bool, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:2769:51
root-project#26 0x00007f4120b3cec9 RootClingMain(int, char**, bool) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:4861:43
root-project#27 0x00007f4120b40825 genreflex::invokeRootCling(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool, bool, bool, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:5326:46
root-project#28 0x00007f4120b426f6 GenReflexMain(int, char**) /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:6026:36
root-project#29 0x00007f4120b42b8d ROOT_rootcling_Driver /home/sss/root/root-6.24.06/src/root/core/dictgen/src/rootcling_impl.cxx:6097:29
root-project#30 0x0000000000401259 main /home/sss/root/root-6.24.06/src/root/main/src/rootcling.cxx:43:51
root-project#31 0x00007f411f73ab75 __libc_start_main (/lib64/libc.so.6+0x27b75)
root-project#32 0x000000000040110e _start (/home/sss/root/root-6.24.06/rootsys/bin/genreflex+0x40110e)
Stack dump:
0.	Program arguments: rootcling -v2 -f x_gen.cxx -inlineInputHeader -Ixheaders x.h sel.xml 




sel.xml:
<lcgdict>
  <class pattern="*iterator<*pair<const*,const*"/>
</lcgdict>



x.h:
#include <string>
#include <map>
void foo (std::map<unsigned, std::string>& m, const std::string& s)
{
  m.emplace (0, s);
}


or:
#include <string>

template <class T>
struct tree_iterator {};

using value_type = std::pair<const unsigned, std::string>;
using xiterator = tree_iterator<value_type>;

class xtree
{
public:
  std::pair<xiterator, bool> emplace()
  {
    return  std::pair<xiterator, bool>(xiterator(), false);
  }
};


Difficult to reduce it further due to how rootcling implicitly
reads headers.
guitargeek added a commit that referenced this pull request Oct 11, 2022
In the logging for out-of-range values in `RooTreeDataStore::loadValues`,
there was `static_cast<RooAbsReal*>(arg)->getVal()` called also for
categories, which is invalid.

This led to garbage numbers as here in the tutorial outputs:
https://root.cern/doc/v624/rf401__importttreethx_8C.html
(see the lines with `Skipping event #2 because i cannot accommodate the value`)
guitargeek added a commit that referenced this pull request Oct 11, 2022
In the logging for out-of-range values in `RooTreeDataStore::loadValues`,
there was `static_cast<RooAbsReal*>(arg)->getVal()` called also for
categories, which is invalid.

This led to garbage numbers as here in the tutorial outputs:
https://root.cern/doc/v624/rf401__importttreethx_8C.html
(see the lines with `Skipping event #2 because i cannot accommodate the value`)
SamuelChegeMburu referenced this pull request May 12, 2023
At each step draw newly created graph with reasonable content
Avoid writing value to vector out of bounds
@huagenxu huagenxu mentioned this pull request Aug 25, 2023
1 task
vepadulano added a commit that referenced this pull request May 15, 2024
In the jitted version of the `Vary` transformation a node is allocated on the heap and its address is passed down to the function `JitVariationHelper`, which is also responsible for deleting the allocated memory. In case a mismatch in the return type of the jitted function given to the Vary call is detected, we throw an error to inform the user they should return an RVec for the Vary to properly work. This means that the call to JitVariationHelper does not happen, thus the memory of the node is not deallocated. This commit corrects that behaviour by properly deleting the pointer before throwing the exception.

Thanks to the address sanitizer:
```
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7f28c78d9e28 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e28) (BuildId: 2b657470ea196ba4342e3bd8a3cc138b1e200599)
    #1 0xb711e0 in std::shared_ptr<ROOT::Detail::RDF::RNodeBase>* ROOT::Internal::RDF::MakeSharedOnHeap<ROOT::Detail::RDF::RNodeBase>(std::shared_ptr<ROOT::Detail::RDF::RNodeBase> const&) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/InterfaceUtils.hxx:370
    #2 0xb843a8 in ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager, void>::JittedVaryImpl(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, bool) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/RInterface.hxx:3108
```
dpiparo pushed a commit that referenced this pull request May 24, 2024
In the jitted version of the `Vary` transformation a node is allocated on the heap and its address is passed down to the function `JitVariationHelper`, which is also responsible for deleting the allocated memory. In case a mismatch in the return type of the jitted function given to the Vary call is detected, we throw an error to inform the user they should return an RVec for the Vary to properly work. This means that the call to JitVariationHelper does not happen, thus the memory of the node is not deallocated. This commit corrects that behaviour by properly deleting the pointer before throwing the exception.

Thanks to the address sanitizer:
```
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7f28c78d9e28 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e28) (BuildId: 2b657470ea196ba4342e3bd8a3cc138b1e200599)
    #1 0xb711e0 in std::shared_ptr<ROOT::Detail::RDF::RNodeBase>* ROOT::Internal::RDF::MakeSharedOnHeap<ROOT::Detail::RDF::RNodeBase>(std::shared_ptr<ROOT::Detail::RDF::RNodeBase> const&) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/InterfaceUtils.hxx:370
    #2 0xb843a8 in ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager, void>::JittedVaryImpl(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, bool) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/RInterface.hxx:3108
```
PPaye pushed a commit to PPaye/root that referenced this pull request Jun 3, 2024
In the jitted version of the `Vary` transformation a node is allocated on the heap and its address is passed down to the function `JitVariationHelper`, which is also responsible for deleting the allocated memory. In case a mismatch in the return type of the jitted function given to the Vary call is detected, we throw an error to inform the user they should return an RVec for the Vary to properly work. This means that the call to JitVariationHelper does not happen, thus the memory of the node is not deallocated. This commit corrects that behaviour by properly deleting the pointer before throwing the exception.

Thanks to the address sanitizer:
```
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7f28c78d9e28 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e28) (BuildId: 2b657470ea196ba4342e3bd8a3cc138b1e200599)
    root-project#1 0xb711e0 in std::shared_ptr<ROOT::Detail::RDF::RNodeBase>* ROOT::Internal::RDF::MakeSharedOnHeap<ROOT::Detail::RDF::RNodeBase>(std::shared_ptr<ROOT::Detail::RDF::RNodeBase> const&) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/InterfaceUtils.hxx:370
    root-project#2 0xb843a8 in ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager, void>::JittedVaryImpl(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, bool) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/RInterface.hxx:3108
```
vepadulano added a commit that referenced this pull request Jun 12, 2024
The destructor of TTreeReader was making use of the TFile after its destruction.

```
480: ==2560128==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000011648 at pc 0x7fb9d1ae089e bp 0x7ffd8e35b0a0 sp 0x7ffd8e35b098
480: READ of size 8 at 0x617000011648 thread T0
480:     #0 0x7fb9d1ae089d in TTree::GetNotify() const /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503
480:     #1 0x7fb9d1ae089d in void TNotifyLinkBase::RemoveLink<TTree>(TTree&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TNotifyLin
k.h:104
480:     #2 0x7fb9d1ae089d in TTreeReader::~TTreeReader() /home/vpadulan/Programs/rootproject/rootsrc/tree/treeplayer/src/TTreeReader.cxx:252
480:     #3 0x433968 in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bulk
ApiSillyStruct.cxx:104
480:     #4 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)()
, char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x4
70bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #5 0x45a5f3 in testing::Test::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-
asan/tree/tree/test/testBulkApiSillyStruct+0x45a5f3) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #6 0x45a969 in testing::TestInfo::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiSillyStruct+0x45a969) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #7 0x45ab10 in testing::TestSuite::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/tree/tree/test/testBulkApiSillyStruct+0x45ab10) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #8 0x4675be in testing::internal::UnitTestImpl::RunAllTests() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-fre
e-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x4675be) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #9 0x45af6c in testing::UnitTest::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiSillyStruct+0x45af6c) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #10 0x425456 in main (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApi
SillyStruct+0x425456) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #11 0x7fb9cd446149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2)
480:     #12 0x7fb9cd44620a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2)
480:     #13 0x4257b4 in _start (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkA
piSillyStruct+0x4257b4) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)

480: 0x617000011648 is located 328 bytes inside of 712-byte region [0x617000011500,0x6170000117c8)
480: freed by thread T0 here:
480:     #0 0x7fb9d1eda878 in operator delete(void*) (/lib64/libasan.so.8+0xda878) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
480:     #1 0x7fb9cdfb4f25 in TCollection::GarbageCollect(TObject*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TCollection.cxx:736
480:     #2 0x7fb9cdfe8a27 in TList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TList.cxx:535
480:     #3 0x7fb9cdfc53d7 in THashList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/THashList.cxx:215
480:     #4 0x7fb9ce8d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:585
480:     #5 0x7fb9ce8d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:561
480:     #6 0x7fb9ce9468e4 in TFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:989
480:     #7 0x7fb9ce9481fd in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:566
480:     #8 0x7fb9ce948fd0 in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:603
480:     #9 0x4338cd in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bulk
ApiSillyStruct.cxx:103
480:     #10 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x
470bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)

480: previously allocated by thread T0 here:
480:     #0 0x7fb9d1ed9e38 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e38) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
480:     #1 0x7fb9cdebbfd0 in TStorage::ObjectAlloc(unsigned long) /home/vpadulan/Programs/rootproject/rootsrc/core/base/src/TStorage.cxx:293
480:     #2 0x7fb9d12cc209 in TObject::operator new(unsigned long) /home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/include/TObject.h:181
480:     #3 0x7fb9d12cc209 in new_TTree /home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/G__Tree
.cxx:4363
480:     #4 0x7fb9ce10a49c in TClass::NewObject(TClass::ENewType, bool) const /home/vpadulan/Programs/rootproject/rootsrc/core/meta/src/TClass.cxx
:5003
480:     #5 0x7fb9ce113c7d in TClass::New(TClass::ENewType, bool) const /home/vpadulan/Programs/rootproject/rootsrc/core/meta/src/TClass.cxx:4980
480:     #6 0x7fb9ce9cda38 in TKey::ReadObjectAny(TClass const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TKey.cxx:1086
480:     #7 0x7fb9ce8d10a7 in TDirectoryFile::GetObjectChecked(char const*, TClass const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/T
DirectoryFile.cxx:1111
480:     #8 0x7fb9d1ade1d1 in void TDirectory::GetObject<TTree>(char const*, TTree*&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TD
irectory.h:214
480:     #9 0x7fb9d1ade1d1 in TTreeReader::TTreeReader(char const*, TDirectory*, TEntryList*) /home/vpadulan/Programs/rootproject/rootsrc/tree/tre
eplayer/src/TTreeReader.cxx:232
480:     #10 0x433332 in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bu$
kApiSillyStruct.cxx:87
480:     #11 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x
470bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:
480: SUMMARY: AddressSanitizer: heap-use-after-free /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503 in TTree::GetNotify() co
nst
```
vepadulano added a commit that referenced this pull request Jun 12, 2024
Ensure proper TFile memory management and avoid TTreeReader accessing the TFile after its destruction.

```
479: ==2573107==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000051b48 at pc 0x7f0fcf4e089e bp 0x7fff6e7e1fe0 sp 0x7fff6e7e1fd8
479: READ of size 8 at 0x617000051b48 thread T0
479:     #0 0x7f0fcf4e089d in TTree::GetNotify() const /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503
479:     #1 0x7f0fcf4e089d in void TNotifyLinkBase::RemoveLink<TTree>(TTree&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TNotifyLin
k.h:104
479:     #2 0x7f0fcf4e089d in TTreeReader::~TTreeReader() /home/vpadulan/Programs/rootproject/rootsrc/tree/treeplayer/src/TTreeReader.cxx:252
479:     #3 0x4321ca in BulkApiVariableTest_stdRead_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/BulkApiVarLength.c
xx:135
479:     #4 0x470c8c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)()
, char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiVarLength+0x470
c8c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #5 0x45a6d3 in testing::Test::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-
asan/tree/tree/test/testBulkApiVarLength+0x45a6d3) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #6 0x45aa49 in testing::TestInfo::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiVarLength+0x45aa49) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #7 0x45abf0 in testing::TestSuite::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/tree/tree/test/testBulkApiVarLength+0x45abf0) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #8 0x46769e in testing::internal::UnitTestImpl::RunAllTests() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-fre
e-testing-asan/tree/tree/test/testBulkApiVarLength+0x46769e) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #9 0x45b04c in testing::UnitTest::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiVarLength+0x45b04c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #10 0x424606 in main (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApi
VarLength+0x424606) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479: 0x617000051b48 is located 328 bytes inside of 712-byte region [0x617000051a00,0x617000051cc8)

479: freed by thread T0 here:
479:     #0 0x7f0fcf8da878 in operator delete(void*) (/lib64/libasan.so.8+0xda878) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
479:     #1 0x7f0fcb9b4f25 in TCollection::GarbageCollect(TObject*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TCollection.cxx:736
479:     #2 0x7f0fcb9e8a27 in TList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TList.cxx:535
479:     #3 0x7f0fcb9c53d7 in THashList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/THashList.cxx:215
479:     #4 0x7f0fcc2d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:585
479:     #5 0x7f0fcc2d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:561
479:     #6 0x7f0fcc3468e4 in TFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:989
479:     #7 0x7f0fcc3481fd in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:566
479:     #8 0x7f0fcc348fd0 in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:603
479:     #9 0x432ebf in BulkApiVariableTest_stdRead_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/BulkApiVarLength.c
xx:130
479:     #10 0x470c8c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiVarLength+0x47
0c8c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
```
guitargeek pushed a commit that referenced this pull request Jun 13, 2024
The destructor of TTreeReader was making use of the TFile after its destruction.

```
480: ==2560128==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000011648 at pc 0x7fb9d1ae089e bp 0x7ffd8e35b0a0 sp 0x7ffd8e35b098
480: READ of size 8 at 0x617000011648 thread T0
480:     #0 0x7fb9d1ae089d in TTree::GetNotify() const /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503
480:     #1 0x7fb9d1ae089d in void TNotifyLinkBase::RemoveLink<TTree>(TTree&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TNotifyLin
k.h:104
480:     #2 0x7fb9d1ae089d in TTreeReader::~TTreeReader() /home/vpadulan/Programs/rootproject/rootsrc/tree/treeplayer/src/TTreeReader.cxx:252
480:     #3 0x433968 in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bulk
ApiSillyStruct.cxx:104
480:     #4 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)()
, char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x4
70bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #5 0x45a5f3 in testing::Test::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-
asan/tree/tree/test/testBulkApiSillyStruct+0x45a5f3) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #6 0x45a969 in testing::TestInfo::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiSillyStruct+0x45a969) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #7 0x45ab10 in testing::TestSuite::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/tree/tree/test/testBulkApiSillyStruct+0x45ab10) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #8 0x4675be in testing::internal::UnitTestImpl::RunAllTests() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-fre
e-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x4675be) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #9 0x45af6c in testing::UnitTest::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiSillyStruct+0x45af6c) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #10 0x425456 in main (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApi
SillyStruct+0x425456) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     #11 0x7fb9cd446149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2)
480:     #12 0x7fb9cd44620a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2)
480:     #13 0x4257b4 in _start (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkA
piSillyStruct+0x4257b4) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)

480: 0x617000011648 is located 328 bytes inside of 712-byte region [0x617000011500,0x6170000117c8)
480: freed by thread T0 here:
480:     #0 0x7fb9d1eda878 in operator delete(void*) (/lib64/libasan.so.8+0xda878) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
480:     #1 0x7fb9cdfb4f25 in TCollection::GarbageCollect(TObject*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TCollection.cxx:736
480:     #2 0x7fb9cdfe8a27 in TList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TList.cxx:535
480:     #3 0x7fb9cdfc53d7 in THashList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/THashList.cxx:215
480:     #4 0x7fb9ce8d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:585
480:     #5 0x7fb9ce8d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:561
480:     #6 0x7fb9ce9468e4 in TFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:989
480:     #7 0x7fb9ce9481fd in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:566
480:     #8 0x7fb9ce948fd0 in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:603
480:     #9 0x4338cd in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bulk
ApiSillyStruct.cxx:103
480:     #10 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x
470bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)

480: previously allocated by thread T0 here:
480:     #0 0x7fb9d1ed9e38 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e38) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
480:     #1 0x7fb9cdebbfd0 in TStorage::ObjectAlloc(unsigned long) /home/vpadulan/Programs/rootproject/rootsrc/core/base/src/TStorage.cxx:293
480:     #2 0x7fb9d12cc209 in TObject::operator new(unsigned long) /home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/include/TObject.h:181
480:     #3 0x7fb9d12cc209 in new_TTree /home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/G__Tree
.cxx:4363
480:     #4 0x7fb9ce10a49c in TClass::NewObject(TClass::ENewType, bool) const /home/vpadulan/Programs/rootproject/rootsrc/core/meta/src/TClass.cxx
:5003
480:     #5 0x7fb9ce113c7d in TClass::New(TClass::ENewType, bool) const /home/vpadulan/Programs/rootproject/rootsrc/core/meta/src/TClass.cxx:4980
480:     #6 0x7fb9ce9cda38 in TKey::ReadObjectAny(TClass const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TKey.cxx:1086
480:     #7 0x7fb9ce8d10a7 in TDirectoryFile::GetObjectChecked(char const*, TClass const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/T
DirectoryFile.cxx:1111
480:     #8 0x7fb9d1ade1d1 in void TDirectory::GetObject<TTree>(char const*, TTree*&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TD
irectory.h:214
480:     #9 0x7fb9d1ade1d1 in TTreeReader::TTreeReader(char const*, TDirectory*, TEntryList*) /home/vpadulan/Programs/rootproject/rootsrc/tree/tre
eplayer/src/TTreeReader.cxx:232
480:     #10 0x433332 in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bu$
kApiSillyStruct.cxx:87
480:     #11 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x
470bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:
480: SUMMARY: AddressSanitizer: heap-use-after-free /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503 in TTree::GetNotify() co
nst
```
guitargeek pushed a commit that referenced this pull request Jun 13, 2024
Ensure proper TFile memory management and avoid TTreeReader accessing the TFile after its destruction.

```
479: ==2573107==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000051b48 at pc 0x7f0fcf4e089e bp 0x7fff6e7e1fe0 sp 0x7fff6e7e1fd8
479: READ of size 8 at 0x617000051b48 thread T0
479:     #0 0x7f0fcf4e089d in TTree::GetNotify() const /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503
479:     #1 0x7f0fcf4e089d in void TNotifyLinkBase::RemoveLink<TTree>(TTree&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TNotifyLin
k.h:104
479:     #2 0x7f0fcf4e089d in TTreeReader::~TTreeReader() /home/vpadulan/Programs/rootproject/rootsrc/tree/treeplayer/src/TTreeReader.cxx:252
479:     #3 0x4321ca in BulkApiVariableTest_stdRead_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/BulkApiVarLength.c
xx:135
479:     #4 0x470c8c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)()
, char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiVarLength+0x470
c8c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #5 0x45a6d3 in testing::Test::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-
asan/tree/tree/test/testBulkApiVarLength+0x45a6d3) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #6 0x45aa49 in testing::TestInfo::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiVarLength+0x45aa49) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #7 0x45abf0 in testing::TestSuite::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/tree/tree/test/testBulkApiVarLength+0x45abf0) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #8 0x46769e in testing::internal::UnitTestImpl::RunAllTests() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-fre
e-testing-asan/tree/tree/test/testBulkApiVarLength+0x46769e) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #9 0x45b04c in testing::UnitTest::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiVarLength+0x45b04c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     #10 0x424606 in main (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApi
VarLength+0x424606) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479: 0x617000051b48 is located 328 bytes inside of 712-byte region [0x617000051a00,0x617000051cc8)

479: freed by thread T0 here:
479:     #0 0x7f0fcf8da878 in operator delete(void*) (/lib64/libasan.so.8+0xda878) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
479:     #1 0x7f0fcb9b4f25 in TCollection::GarbageCollect(TObject*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TCollection.cxx:736
479:     #2 0x7f0fcb9e8a27 in TList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TList.cxx:535
479:     #3 0x7f0fcb9c53d7 in THashList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/THashList.cxx:215
479:     #4 0x7f0fcc2d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:585
479:     #5 0x7f0fcc2d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:561
479:     #6 0x7f0fcc3468e4 in TFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:989
479:     #7 0x7f0fcc3481fd in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:566
479:     #8 0x7f0fcc348fd0 in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:603
479:     #9 0x432ebf in BulkApiVariableTest_stdRead_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/BulkApiVarLength.c
xx:130
479:     #10 0x470c8c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiVarLength+0x47
0c8c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
```
silverweed pushed a commit to silverweed/root that referenced this pull request Aug 19, 2024
In the jitted version of the `Vary` transformation a node is allocated on the heap and its address is passed down to the function `JitVariationHelper`, which is also responsible for deleting the allocated memory. In case a mismatch in the return type of the jitted function given to the Vary call is detected, we throw an error to inform the user they should return an RVec for the Vary to properly work. This means that the call to JitVariationHelper does not happen, thus the memory of the node is not deallocated. This commit corrects that behaviour by properly deleting the pointer before throwing the exception.

Thanks to the address sanitizer:
```
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7f28c78d9e28 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e28) (BuildId: 2b657470ea196ba4342e3bd8a3cc138b1e200599)
    root-project#1 0xb711e0 in std::shared_ptr<ROOT::Detail::RDF::RNodeBase>* ROOT::Internal::RDF::MakeSharedOnHeap<ROOT::Detail::RDF::RNodeBase>(std::shared_ptr<ROOT::Detail::RDF::RNodeBase> const&) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/InterfaceUtils.hxx:370
    root-project#2 0xb843a8 in ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager, void>::JittedVaryImpl(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, bool) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/RInterface.hxx:3108
```
silverweed pushed a commit to silverweed/root that referenced this pull request Aug 19, 2024
The destructor of TTreeReader was making use of the TFile after its destruction.

```
480: ==2560128==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000011648 at pc 0x7fb9d1ae089e bp 0x7ffd8e35b0a0 sp 0x7ffd8e35b098
480: READ of size 8 at 0x617000011648 thread T0
480:     #0 0x7fb9d1ae089d in TTree::GetNotify() const /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503
480:     root-project#1 0x7fb9d1ae089d in void TNotifyLinkBase::RemoveLink<TTree>(TTree&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TNotifyLin
k.h:104
480:     root-project#2 0x7fb9d1ae089d in TTreeReader::~TTreeReader() /home/vpadulan/Programs/rootproject/rootsrc/tree/treeplayer/src/TTreeReader.cxx:252
480:     root-project#3 0x433968 in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bulk
ApiSillyStruct.cxx:104
480:     root-project#4 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)()
, char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x4
70bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#5 0x45a5f3 in testing::Test::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-
asan/tree/tree/test/testBulkApiSillyStruct+0x45a5f3) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#6 0x45a969 in testing::TestInfo::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiSillyStruct+0x45a969) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#7 0x45ab10 in testing::TestSuite::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/tree/tree/test/testBulkApiSillyStruct+0x45ab10) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#8 0x4675be in testing::internal::UnitTestImpl::RunAllTests() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-fre
e-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x4675be) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#9 0x45af6c in testing::UnitTest::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiSillyStruct+0x45af6c) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#10 0x425456 in main (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApi
SillyStruct+0x425456) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:     root-project#11 0x7fb9cd446149 in __libc_start_call_main (/lib64/libc.so.6+0x28149) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2)
480:     root-project#12 0x7fb9cd44620a in __libc_start_main_impl (/lib64/libc.so.6+0x2820a) (BuildId: 0d710e9d9dc10c500b8119c85da75004183618e2)
480:     root-project#13 0x4257b4 in _start (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkA
piSillyStruct+0x4257b4) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)

480: 0x617000011648 is located 328 bytes inside of 712-byte region [0x617000011500,0x6170000117c8)
480: freed by thread T0 here:
480:     #0 0x7fb9d1eda878 in operator delete(void*) (/lib64/libasan.so.8+0xda878) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
480:     root-project#1 0x7fb9cdfb4f25 in TCollection::GarbageCollect(TObject*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TCollection.cxx:736
480:     root-project#2 0x7fb9cdfe8a27 in TList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TList.cxx:535
480:     root-project#3 0x7fb9cdfc53d7 in THashList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/THashList.cxx:215
480:     root-project#4 0x7fb9ce8d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:585
480:     root-project#5 0x7fb9ce8d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:561
480:     root-project#6 0x7fb9ce9468e4 in TFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:989
480:     root-project#7 0x7fb9ce9481fd in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:566
480:     root-project#8 0x7fb9ce948fd0 in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:603
480:     root-project#9 0x4338cd in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bulk
ApiSillyStruct.cxx:103
480:     root-project#10 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x
470bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)

480: previously allocated by thread T0 here:
480:     #0 0x7fb9d1ed9e38 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e38) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
480:     root-project#1 0x7fb9cdebbfd0 in TStorage::ObjectAlloc(unsigned long) /home/vpadulan/Programs/rootproject/rootsrc/core/base/src/TStorage.cxx:293
480:     root-project#2 0x7fb9d12cc209 in TObject::operator new(unsigned long) /home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/include/TObject.h:181
480:     root-project#3 0x7fb9d12cc209 in new_TTree /home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/G__Tree
.cxx:4363
480:     root-project#4 0x7fb9ce10a49c in TClass::NewObject(TClass::ENewType, bool) const /home/vpadulan/Programs/rootproject/rootsrc/core/meta/src/TClass.cxx
:5003
480:     root-project#5 0x7fb9ce113c7d in TClass::New(TClass::ENewType, bool) const /home/vpadulan/Programs/rootproject/rootsrc/core/meta/src/TClass.cxx:4980
480:     root-project#6 0x7fb9ce9cda38 in TKey::ReadObjectAny(TClass const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TKey.cxx:1086
480:     root-project#7 0x7fb9ce8d10a7 in TDirectoryFile::GetObjectChecked(char const*, TClass const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/T
DirectoryFile.cxx:1111
480:     root-project#8 0x7fb9d1ade1d1 in void TDirectory::GetObject<TTree>(char const*, TTree*&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TD
irectory.h:214
480:     root-project#9 0x7fb9d1ade1d1 in TTreeReader::TTreeReader(char const*, TDirectory*, TEntryList*) /home/vpadulan/Programs/rootproject/rootsrc/tree/tre
eplayer/src/TTreeReader.cxx:232
480:     root-project#10 0x433332 in BulkApiSillyStructTest_stdReadSplitBranch_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/Bu$
kApiSillyStruct.cxx:87
480:     root-project#11 0x470bac in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiSillyStruct+0x
470bac) (BuildId: 45d8d15c24ba2aae252398ec00943aba7665b034)
480:
480: SUMMARY: AddressSanitizer: heap-use-after-free /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503 in TTree::GetNotify() co
nst
```
silverweed pushed a commit to silverweed/root that referenced this pull request Aug 19, 2024
Ensure proper TFile memory management and avoid TTreeReader accessing the TFile after its destruction.

```
479: ==2573107==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000051b48 at pc 0x7f0fcf4e089e bp 0x7fff6e7e1fe0 sp 0x7fff6e7e1fd8
479: READ of size 8 at 0x617000051b48 thread T0
479:     #0 0x7f0fcf4e089d in TTree::GetNotify() const /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/inc/TTree.h:503
479:     root-project#1 0x7f0fcf4e089d in void TNotifyLinkBase::RemoveLink<TTree>(TTree&) /home/vpadulan/Programs/rootproject/rootsrc/core/base/inc/TNotifyLin
k.h:104
479:     root-project#2 0x7f0fcf4e089d in TTreeReader::~TTreeReader() /home/vpadulan/Programs/rootproject/rootsrc/tree/treeplayer/src/TTreeReader.cxx:252
479:     root-project#3 0x4321ca in BulkApiVariableTest_stdRead_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/BulkApiVarLength.c
xx:135
479:     root-project#4 0x470c8c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)()
, char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiVarLength+0x470
c8c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     root-project#5 0x45a6d3 in testing::Test::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-
asan/tree/tree/test/testBulkApiVarLength+0x45a6d3) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     root-project#6 0x45aa49 in testing::TestInfo::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiVarLength+0x45aa49) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     root-project#7 0x45abf0 in testing::TestSuite::Run() [clone .part.0] (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-tes
ting-asan/tree/tree/test/testBulkApiVarLength+0x45abf0) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     root-project#8 0x46769e in testing::internal::UnitTestImpl::RunAllTests() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-fre
e-testing-asan/tree/tree/test/testBulkApiVarLength+0x46769e) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     root-project#9 0x45b04c in testing::UnitTest::Run() (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tr
ee/test/testBulkApiVarLength+0x45b04c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479:     root-project#10 0x424606 in main (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApi
VarLength+0x424606) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
479: 0x617000051b48 is located 328 bytes inside of 712-byte region [0x617000051a00,0x617000051cc8)

479: freed by thread T0 here:
479:     #0 0x7f0fcf8da878 in operator delete(void*) (/lib64/libasan.so.8+0xda878) (BuildId: 2e1c50524ff1a2e7e73c4565b46f3f51892353ea)
479:     root-project#1 0x7f0fcb9b4f25 in TCollection::GarbageCollect(TObject*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TCollection.cxx:736
479:     root-project#2 0x7f0fcb9e8a27 in TList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/TList.cxx:535
479:     root-project#3 0x7f0fcb9c53d7 in THashList::Delete(char const*) /home/vpadulan/Programs/rootproject/rootsrc/core/cont/src/THashList.cxx:215
479:     root-project#4 0x7f0fcc2d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:585
479:     root-project#5 0x7f0fcc2d285d in TDirectoryFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TDirectoryFile.cxx:561
479:     root-project#6 0x7f0fcc3468e4 in TFile::Close(char const*) /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:989
479:     root-project#7 0x7f0fcc3481fd in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:566
479:     root-project#8 0x7f0fcc348fd0 in TFile::~TFile() /home/vpadulan/Programs/rootproject/rootsrc/io/io/src/TFile.cxx:603
479:     root-project#9 0x432ebf in BulkApiVariableTest_stdRead_Test::TestBody() /home/vpadulan/Programs/rootproject/rootsrc/tree/tree/test/BulkApiVarLength.c
xx:130
479:     root-project#10 0x470c8c in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(
), char const*) (/home/vpadulan/Programs/rootproject/rootbuild/bulksilly-heap-use-after-free-testing-asan/tree/tree/test/testBulkApiVarLength+0x47
0c8c) (BuildId: aac947b72f02e5567382f0dadfefd1e97d058a56)
```
vepadulano added a commit that referenced this pull request Sep 24, 2024
The test was dynamically allocating the array data members of the `Data` struct, but never deallocating them. This commit polishes the `Data` struct definition and ensures proper management of the data members.

The previous way of writing data to the TTree was leading to a bad memory access in the ReadBasicPointer inlined function in TStreamerInfoReadBuffer.cxx while reading the `double*` array. In particular, the issue arises when accessing and then deallocating the array at the current index provided by the `TCompInfo` object.

```
Target 0: (repro.out) stopped.
(lldb)
Process 13498 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x00000001044cf140 libRIO.so`int TStreamerInfo::ReadBuffer<char**>(this=<unavailable>, b=<unavailable>, arr=<unavailable>, compinfo=<unavailable>, first=<unavailable>, last=<unavailable>, narr=<unavailable>, eoffset=<unavailable>, arrayMode=0) at TStreamerInfoReadBuffer.cxx:923:65 [opt]
   920 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kLong:   ReadBasicPointer(Long_t);  continue;
   921 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kLong64: ReadBasicPointer(Long64_t);  continue;
   922 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kFloat:  ReadBasicPointer(Float_t);  continue;
-> 923 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kDouble: ReadBasicPointer(Double_t);  continue;
   924 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kUChar:  ReadBasicPointer(UChar_t);  continue;
   925 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kUShort: ReadBasicPointer(UShort_t);  continue;
   926 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kUInt:   ReadBasicPointer(UInt_t);  continue;
Target 0: (repro.out) stopped.
(lldb)
Process 13498 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x00000001044cf184 libRIO.so`int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char** const&, TStreamerInfo::TCompInfo* const*, int, int, int, int, int) [inlined] TBuffer::BufferSize(this=0x000060e00010ef00) const at TBuffer.h:98:41 [opt]
   95  	   TObject *GetParent()  const;
   96  	   char    *Buffer()     const { return fBuffer; }
   97  	   char    *GetCurrent() const { return fBufCur; }
-> 98  	   Int_t    BufferSize() const { return fBufSize; }
   99  	   void     DetachBuffer() { fBuffer = nullptr; }
   100 	   Int_t    Length()     const { return (Int_t)(fBufCur - fBuffer); }
   101 	   void     Expand(Int_t newsize, Bool_t copy = kTRUE);  // expand buffer to newsize
Target 0: (repro.out) stopped.
(lldb) p fBufSize
(Int_t) 32008
(lldb) s
Process 13498 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x00000001044cf194 libRIO.so`int TStreamerInfo::ReadBuffer<char**>(this=<unavailable>, b=<unavailable>, arr=<unavailable>, compinfo=<unavailable>, first=<unavailable>, last=<unavailable>, narr=<unavailable>, eoffset=<unavailable>, arrayMode=0) at TStreamerInfoReadBuffer.cxx:923:65 [opt]
   920 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kLong:   ReadBasicPointer(Long_t);  continue;
   921 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kLong64: ReadBasicPointer(Long64_t);  continue;
   922 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kFloat:  ReadBasicPointer(Float_t);  continue;
-> 923 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kDouble: ReadBasicPointer(Double_t);  continue;
   924 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kUChar:  ReadBasicPointer(UChar_t);  continue;
   925 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kUShort: ReadBasicPointer(UShort_t);  continue;
   926 	         case TStreamerInfo::kOffsetP + TStreamerInfo::kUInt:   ReadBasicPointer(UInt_t);  continue;
Target 0: (repro.out) stopped.
(lldb) s
Process 13498 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xbebebebebebebeae)
    frame #0: 0x0000000107bac674 libclang_rt.asan_osx_dynamic.dylib`__asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) + 76
libclang_rt.asan_osx_dynamic.dylib`__asan::Allocator::Deallocate:
->  0x107bac674 <+76>: casalb w8, w9, [x22]
    0x107bac678 <+80>: cmp    w8, #0x2
    0x107bac67c <+84>: b.ne   0x107bac6f4    ; <+204>
    0x107bac680 <+88>: mov    x8, #-0x100000000 ; =-4294967296
Target 0: (repro.out) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xbebebebebebebeae)
  * frame #0: 0x0000000107bac674 libclang_rt.asan_osx_dynamic.dylib`__asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) + 76
    frame #1: 0x0000000107c0c444 libclang_rt.asan_osx_dynamic.dylib`wrap__ZdaPv + 232
    frame #2: 0x00000001044d4a60 libRIO.so`int TStreamerInfo::ReadBuffer<char**>(this=<unavailable>, b=<unavailable>, arr=<unavailable>, compinfo=<unavailable>, first=<unavailable>, last=<unavailable>, narr=<unavailable>, eoffset=<unavailable>, arrayMode=0) at TStreamerInfoReadBuffer.cxx:923:65 [opt]
    frame #3: 0x0000000103ffc888 libRIO.so`TStreamerInfoActions::GenericReadAction(buf=0x000060e00010ef00, addr=0x0000602000056bd0, config=0x0000604000149910) at TStreamerInfoActions.cxx:195:45
    frame #4: 0x0000000103caa5ec libRIO.so`TStreamerInfoActions::TConfiguredAction::operator()(this=0x00006030001693f0, buffer=0x000060e00010ef00, object=0x0000602000056bd0) const at TStreamerInfoActions.h:123:17
    frame #5: 0x0000000103ca9ef8 libRIO.so`TBufferFile::ApplySequence(this=0x000060e00010ef00, sequence=0x000060600011ac20, obj=0x0000602000056bd0) at TBufferFile.cxx:3702:10
    frame #6: 0x00000001064bc570 libTree.so`TBranchElement::ReadLeavesMemberBranchCount(this=0x0000619000566380, b=0x000060e00010ef00) at TBranchElement.cxx:4603:6
    frame #7: 0x0000000106455ce4 libTree.so`TBranch::GetEntry(this=0x0000619000566380, entry=0, getall=0) at TBranch.cxx:1753:4
    frame #8: 0x00000001064a1764 libTree.so`TBranchElement::GetEntry(this=0x0000619000566380, entry=0, getall=0) at TBranchElement.cxx:2783:27
    frame #9: 0x000000010739915c libTreePlayer.so`ROOT::Detail::TBranchProxy::Read(this=0x00006110000c9580) at TBranchProxy.h:163:42
    frame #10: 0x0000000107649ba8 libTreePlayer.so`(anonymous namespace)::TObjectArrayReader::At(this=0x0000603000169900, proxy=0x00006110000c9580, idx=1) at TTreeReaderArray.cxx:176:22
    frame #11: 0x000000010000c2e4 repro.out`ROOT::Internal::TTreeReaderArrayBase::UntypedAt(this=0x000000016fdfe740, idx=1) const at TTreeReaderArray.h:41:62
    frame #12: 0x000000010000c200 repro.out`TTreeReaderArray<double>::At(this=0x000000016fdfe740, idx=1) at TTreeReaderArray.h:205:54
    frame #13: 0x00000001000065e0 repro.out`TTreeReaderArray<double>::operator[](this=0x000000016fdfe740, idx=1) at TTreeReaderArray.h:207:44
    frame #14: 0x0000000100007b48 repro.out`simpleTest() at repro.cpp:123:26
    frame #15: 0x0000000100007e10 repro.out`main at repro.cpp:128:5
    frame #16: 0x000000018c718274 dyld`start + 2840
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants