To Reproduce
The following code:
#include <iostream>
#include <utility>
#include <vector>
#include <ROOT/RDFHelpers.hxx>
auto foo() {
double f = 42.;
auto fn = [f](std::vector<int>) { std::cout << f << std::endl; };
fn({});
auto f2 = ROOT::RDF::PassAsVec<1, int>(fn);
f2(3);
return f2;
}
int main() {
auto fn = foo();
fn(1);
return 0;
}
prints
instead of
The problem is that the PassAsVecHelper type stores a reference to the the lambda function.
Valgrind does not see the problem (lambdas are stack-allocated), -fsanitize=address does.