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

[TreeProcMT] Trees in subdirectories are not supported (and their usage lead to a crash)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 6.20/08, 6.22/02
    • Fix Version/s: 6.24/00, 6.22/04
    • Component/s: None
    • Labels:
      None
    • Environment:

      any

      Description

      Self-contained reproducer:

      #include <TFile.h>
      #include <TROOT.h>
      #include <TTree.h>
      #include <ROOT/TTreeProcessorMT.hxx>
       
      void make_file()
      {
         TFile f("test.root", "RECREATE");
         f.mkdir("dir");
         f.cd("dir");
         float x;
         TTree t("tree", "tree");
         t.Branch("x", &x, "x");
         for (auto i = 0; i < 10; i++) {
            x = (float)i;
            t.Fill();
         }
         t.Write();
         f.Write();
         f.Close();
      }
       
      void test()
      {
         make_file();
       
         ROOT::EnableThreadSafety();
         TFile f("test.root");
         auto t = (TTree *)f.Get("dir/tree");
         ROOT::TTreeProcessorMT tp(*t);
         tp.Process([](TTreeReader &r) { while (r.Next()); });
      }
       
      int main()
      {
         test();
         return 0;
      }
      

      Relevant part of the stacktrace:

      #8  0x00007fc730401c7e in ROOT::Internal::MakeClusters (treeName="tree", fileNames=std::vector of length 1, capacity 1 = {...}) at /home/eguiraud/ROOT/root/tree/treeplayer/src/TTreeProcessorMT.cxx:51
      #9  0x00007fc7304036ba in ROOT::TTreeProcessorMT::<lambda(std::size_t)>::operator()(std::size_t) const (__closure=0x7ffebb4c5a30, fileIdx=0) at /home/eguiraud/ROOT/root/tree/treeplayer/src/TTreeProcessorMT.cxx:280
      #10 0x00007fc730403d3a in ROOT::TThreadExecutor::<lambda(unsigned int)>::operator()(unsigned int) const (__closure=0x7ffebb4c59d0, i=0) at /home/eguiraud/ROOT/dbg/include/ROOT/TThreadExecutor.hxx:145
      #11 0x00007fc7304040fc in std::_Function_handler<void(unsigned int), ROOT::TThreadExecutor::Foreach(F, std::vector<T, std::allocator<_T2> >&) [with F = ROOT::TTreeProcessorMT::Process(std::function<void(TTreeReader&)>)::<lambda(std::size_t)>; T = long unsigned int]::<lambda(unsigned int)> >::_M_invoke(const std::_Any_data &, unsigned int &&) (__functor=..., __args#0=
      

      To-do list to resolve the issue:

      • TTreeProcessorMT should not rely on trees to be in the top-level directory, but retrieve their full path instead
      • in case a tree is not found in one of the files, the file should be skipped (with a warning message) and processing of other files should continue
      • we should document that TTreeProcessorMT (and RDataFrame) only support TChains passed to the constructor argument for which GetName returns the full path to the TTree (and all TTrees in the chain should have the same name and the same path)
      • we should document that if the tree name/path is not passed to TTreeProcessorMT then only the top-level directory is searched for a tree to process

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eguiraud Enrico Guiraud
              Reporter:
              eguiraud Enrico Guiraud
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

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