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

RDataFrame segfaults when processing TChain with zombie entries

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Medium
    • Resolution: Fixed
    • None
    • 6.16/00
    • None
    • None
    • lxplus7-like environment, centos7-gcc7

    Description

      RDataFrame seems to be less fault-tolerant than TChain when it encounters bad files.

      Here is a simple example that demonstrates the problem:

      #include <TChain.h>
      #define NEW 1
      #ifdef NEW
      #include <ROOT/RDataFrame.hxx>
      #else
      #include <ROOT/TDataFrame.hxx>
      #endif
      void foo()
      {
        TChain input_chain( "MCDecayTree" );
        for ( const auto& path : { "input1.root", "input2.root" } ) {
          input_chain.Add( path );
        }
       
        bool crash{true};
        if ( crash ) {
          // If you uncomment this line the crash goes away:
          // std::cout << "Chain reports " << input_chain.GetEntries() << " entries" << std::endl;
      #ifdef NEW
          ROOT::RDataFrame
      #else
          ROOT::Experimental::TDataFrame
      #endif
            d_input( input_chain );
          auto d_new = d_input.Define( "x", [](Float_t p) { return p*p; }, { "mup_PHI" });
          d_new.Snapshot( "WeightTree", "foo.root", {"mup_PHI", "x"} );
        } else {
          // This code successfully reads the same branch without crashing
          Float_t mup_PHI{0.0};
          input_chain.SetBranchAddress( "mup_PHI", &mup_PHI );
          for ( auto i = 0u; i < input_chain.GetEntries(); ++i ) {
            input_chain.GetEntry( i );
            std::cout << mup_PHI << std::endl;
          }
        }
      }

      I have tried this both with ROOT 6.12/06 (LCG_93) and ROOT 6.14/03 (LCG dev4/latest nightly), the #ifdef magic is just for switching between the two.

      I get the warnings:

      Warning in <TFile::Init>: file input2.root probably not closed, trying to recover
      Warning in <TFile::Init>: no keys recovered, file has been made a Zombie
      

      in all cases – I know this is a bad file – but with RDataFrame I also get:

      Error in <TBranchProxy::Read>: Unable to initialize mup_PHI

      followed by a segfault. As commented in the code, calling GetEntries() on the chain before using RDataFrame seems to prevent the crash, and using TChain directly to access the same branch of the same input files also doesn't crash.

      The input files I used can be found here: https://cernbox.cern.ch/index.php/s/GfHgou1AJPFT6eF

      Attachments

        Activity

          People

            dpiparo Danilo Piparo
            olupton Olli Lupton (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

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