Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9860

[DF] Snapshot can write wrong values in some cases

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • master, 6.16/00
    • 6.16/00
    • None
    • None
    • any

    Description

      First reported on the forum here.

      A minimal reproducer:

      #include <ROOT/RDataFrame.hxx>
      #include <ROOT/RVec.hxx>
       
      int main()
      {
         ROOT::RDataFrame df("Events", "repro.root");
         auto m = df.Max<ROOT::RVec<float>>("Muon_eta");
         auto outRDF = df.Snapshot<unsigned int, ROOT::RVec<float>>("t", "out.root", {"nMuon", "Muon_eta"});
       
         std::cout << "max 1 " << *m << std::endl;
         std::cout << "max 2 " << outRDF->Max<ROOT::RVec<float>>("Muon_eta").GetValue() << std::endl;
       
         return 0;
      }
      

      On my machine this prints

      max 1 1.34888
      max 2 0
      

      Attached is the file for which this reproducer fails ("max 2" is bogus). With a different nanoAOD file (i.e. same data model, different dataset) the bug does not show up.

      Here is the output of valgrind --suppressions=$ROOTSYS/etc/valgrind-root.supp --track-origins=yes --log-file=valgrind.out ./simpletest:

      ==3850== Memcheck, a memory error detector
      ==3850== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
      ==3850== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
      ==3850== Command: ./simpletest
      ==3850== Parent PID: 29753
      ==3850== 
      ==3850== Invalid read of size 4
      ==3850==    at 0x502F4C0: TBufferFile::WriteFastArray(float const*, int) (TBufferFile.cxx:2103)
      ==3850==    by 0x5F2CE79: TLeafF::FillBasket(TBuffer&) (TLeafF.cxx:82)
      ==3850==    by 0x5ED5740: TBranch::FillLeavesImpl(TBuffer&) (TBranch.cxx:2083)
      ==3850==    by 0x5ED10B9: TBranch::FillImpl(ROOT::Internal::TBranchIMTHelper*) (TBranch.cxx:855)
      ==3850==    by 0x5F630F7: TTree::Fill() (TTree.cxx:4420)
      ==3850==    by 0x191BBB: ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >::Exec(unsigned int, unsigned int&, ROOT::VecOps::RVec<float>&) (ActionHelpers.hxx:1024)
      ==3850==    by 0x18FB32: void ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >, ROOT::Detail::RDF::RLoopManager, ROOT::TypeTraits::TypeList<unsigned int, ROOT::VecOps::RVec<float> > >::Exec<0ul, 1ul>(unsigned int, long long, std::integer_sequence<unsigned long, 0ul, 1ul>) (RAction.hxx:276)
      ==3850==    by 0x18E1BE: ROOT::Internal::RDF::RActionCRTP<ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >, ROOT::Detail::RDF::RLoopManager, ROOT::TypeTraits::TypeList<unsigned int, ROOT::VecOps::RVec<float> > > >::Run(unsigned int, long long) (RAction.hxx:137)
      ==3850==    by 0x6B5B624: ROOT::Detail::RDF::RLoopManager::RunAndCheckFilters(unsigned int, long long) (RLoopManager.cxx:346)
      ==3850==    by 0x6B5AEC8: ROOT::Detail::RDF::RLoopManager::RunTreeReader() (RLoopManager.cxx:280)
      ==3850==    by 0x6B5C229: ROOT::Detail::RDF::RLoopManager::Run() (RLoopManager.cxx:466)
      ==3850==    by 0x6B5040C: ROOT::RDF::RResultPtr<ROOT::RDataFrame>::TriggerRun() (RResultPtr.hxx:298)
      ==3850==  Address 0x15f0e3c4 is 0 bytes after a block of size 4 alloc'd
      ==3850==    at 0x483850F: operator new[](unsigned long) (vg_replace_malloc.c:423)
      ==3850==    by 0x5F2D596: TLeafF::SetAddress(void*) (TLeafF.cxx:193)
      ==3850==    by 0x5ECF5DC: TBranch::Init(char const*, char const*, int) (TBranch.cxx:394)
      ==3850==    by 0x5ECE760: TBranch::TBranch(TTree*, char const*, void*, char const*, int, int) (TBranch.cxx:226)
      ==3850==    by 0x5F5BC3F: TTree::Branch(char const*, void*, char const*, int) (TTree.cxx:1865)
      ==3850==    by 0x193E5E: void ROOT::Internal::RDF::SetBranchesHelper<float>(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, ROOT::Internal::RDF::BoolArray, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, ROOT::Internal::RDF::BoolArray> > >&, TTree*, TTree&, 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&, ROOT::VecOps::RVec<float>*) (ActionHelpers.hxx:959)
      ==3850==    by 0x193245: void ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >::SetBranches<0ul, 1ul>(unsigned int&, ROOT::VecOps::RVec<float>&, std::integer_sequence<unsigned long, 0ul, 1ul>) (ActionHelpers.hxx:1031)
      ==3850==    by 0x191B75: ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >::Exec(unsigned int, unsigned int&, ROOT::VecOps::RVec<float>&) (ActionHelpers.hxx:1020)
      ==3850==    by 0x18FB32: void ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >, ROOT::Detail::RDF::RLoopManager, ROOT::TypeTraits::TypeList<unsigned int, ROOT::VecOps::RVec<float> > >::Exec<0ul, 1ul>(unsigned int, long long, std::integer_sequence<unsigned long, 0ul, 1ul>) (RAction.hxx:276)
      ==3850==    by 0x18E1BE: ROOT::Internal::RDF::RActionCRTP<ROOT::Internal::RDF::RAction<ROOT::Internal::RDF::SnapshotHelper<unsigned int, ROOT::VecOps::RVec<float> >, ROOT::Detail::RDF::RLoopManager, ROOT::TypeTraits::TypeList<unsigned int, ROOT::VecOps::RVec<float> > > >::Run(unsigned int, long long) (RAction.hxx:137)
      ==3850==    by 0x6B5B624: ROOT::Detail::RDF::RLoopManager::RunAndCheckFilters(unsigned int, long long) (RLoopManager.cxx:346)
      ==3850==    by 0x6B5AEC8: ROOT::Detail::RDF::RLoopManager::RunTreeReader() (RLoopManager.cxx:280)
      ==3850== 
      ==3850== 
      ==3850== HEAP SUMMARY:
      ==3850==     in use at exit: 28,009,449 bytes in 62,905 blocks
      ==3850==   total heap usage: 251,618 allocs, 188,713 frees, 203,322,382 bytes allocated
      ==3850== 
      ==3850== LEAK SUMMARY:
      ==3850==    definitely lost: 0 bytes in 0 blocks
      ==3850==    indirectly lost: 0 bytes in 0 blocks
      ==3850==      possibly lost: 4,096 bytes in 33 blocks
      ==3850==    still reachable: 27,841,583 bytes in 61,104 blocks
      ==3850==                       of which reachable via heuristic:
      ==3850==                         newarray           : 24,352 bytes in 44 blocks
      ==3850==                         multipleinheritance: 928 bytes in 2 blocks
      ==3850==         suppressed: 163,770 bytes in 1,768 blocks
      ==3850== Rerun with --leak-check=full to see details of leaked memory
      ==3850== 
      ==3850== For counts of detected and suppressed errors, rerun with: -v
      ==3850== ERROR SUMMARY: 3 errors from 1 contexts (suppressed: 3538 from 78)
      

      Attachments

        Activity

          People

            dpiparo Danilo Piparo
            eguiraud Enrico Guiraud
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Actual Start:
              Actual End: