I’ve been experiencing some unusual behavior when using an RDataFrame (unfortunately, I cannot narrow the issue down further). Namely, no code after Foreach() runs. Cling doesn’t throw any errors, nor does gcc. The issue occurs on two machines, one running Ubuntu 20.04 with ROOT hosted in a Conda environment, and one running an older version of Debian with ROOT built from source. I’m stumped.
Here’s a small example (note that I can confirm there’s nothing wrong with the file.root file, it does have data, and it does have a column named myColumn). The program does not print “Success” and, in fact, nothing placed here or after executes. Very bizzarre:
{
ROOT::RDataFrame myFrame("D","./file.root");
int i = 0;
myFrame.Foreach([&](double entry){
++i;
},{"myColumn"});
printf("Success\n");
}
I’m certain it’s not an issue of lack of sufficient memory, and I’m not sure what the vector could possibly have to do with this, as I’ve written very similar code before (often working with much larger datasets) and never had an issue.
which I ran both as a compiled program and through root -l, with no problems.
can you step through with gdb --args root.exe -l macro.C (note the usage of root.exe instead of root) and see what the code is doing?
do you still see this behavior if the code is compiled rather than interpreted via root?
are you sure the printf is not executed, or could it be that it’s “just” never flushed to standard output? does std::cout << "Success" << std::endl work instead? (<< std::endl forces a flush to stdout, which \n in a printf call should also do, but )
Hmm. I too am unable to reproduce the error with your code, but continue to get the error with mine (letter for letter exactly as written here). Very strange.
To answer your questions: yes, I do see the error when the code is compiled (I used g++, with no compiler errors thrown), and I also see the error when using std::cout << "Success" << std::endl;. I’ll try your suggestion with gdb.