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

Segmentation fault upon interpretation of TDF macro

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Other
    • Labels:
      None
    • Environment:

      all

    • Development:

      Description

      This item is related to ROOT-9116.
      This program works when compiled:

      #include <ROOT/TDataFrame.hxx>
      #include <TFile.h>
       
      using namespace ROOT::Experimental;
       
      void writeHistNoInputFile()
      {
         std::cout << "write hist no input file" << std::endl;
         TDataFrame d(1);
         auto counter = 0;
         auto dd = d.Define("x", [&counter]() { return counter++; });
         auto h = dd.Histo1D("x");
       
         TFile f("gdirectoryRestore1.root", "RECREATE");
         h->SetDirectory(&f);
         h->Write();
      }
       
      void makeDataSet()
      {
         std::cout << "make dataset" << std::endl;
         TDataFrame d(1);
         auto counter = 0;
         auto dd = d.Define("x", [&counter]() { return counter++; });
         dd.Snapshot<int>("t", "f.root", {"x"});
      }
       
      int writeHistWithInputFile()
      {
         std::cout << "write hist with input file" << std::endl;
         TDataFrame d("t", "f.root");
         auto h = d.Histo1D("x");
         TFile f("f2.root", "RECREATE");
         h->SetDirectory(&f);
         h->Write();
         return nullptr == gDirectory;
      }
       
      int gdirectoryRestore()
      {
         ROOT::EnableImplicitMT();
         writeHistNoInputFile();
         makeDataSet();
         return writeHistWithInputFile();
      }
       
      int main()
      {
         return gdirectoryRestore();
      }

      but gives raise to a segfault when interpreted as a macro.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dpiparo Danilo Piparo
                Reporter:
                dpiparo Danilo Piparo
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: