Skip to content

Commit 80ce194

Browse files
committed
[df] Delete allocated node before throwing error
In the jitted version of the `Vary` transformation a node is allocated on the heap and its address is passed down to the function `JitVariationHelper`, which is also responsible for deleting the allocated memory. In case a mismatch in the return type of the jitted function given to the Vary call is detected, we throw an error to inform the user they should return an RVec for the Vary to properly work. This means that the call to JitVariationHelper does not happen, thus the memory of the node is not deallocated. This commit corrects that behaviour by properly deleting the pointer before throwing the exception. Thanks to the address sanitizer: ``` Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7f28c78d9e28 in operator new(unsigned long) (/lib64/libasan.so.8+0xd9e28) (BuildId: 2b657470ea196ba4342e3bd8a3cc138b1e200599) #1 0xb711e0 in std::shared_ptr<ROOT::Detail::RDF::RNodeBase>* ROOT::Internal::RDF::MakeSharedOnHeap<ROOT::Detail::RDF::RNodeBase>(std::shared_ptr<ROOT::Detail::RDF::RNodeBase> const&) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/InterfaceUtils.hxx:370 #2 0xb843a8 in ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager, void>::JittedVaryImpl(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::basic_string_view<char, std::char_traits<char> >, bool) /home/vpadulan/Programs/rootproject/rootbuild/master-a73f11dfc5-testing-asan/include/ROOT/RDF/RInterface.hxx:3108 ```
1 parent 19e7d5c commit 80ce194

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tree/dataframe/src/RDFInterfaceUtils.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,14 @@ BookVariationJit(const std::vector<std::string> &colNames, std::string_view vari
777777
const auto funcName = DeclareFunction(parsedExpr.fExpr, parsedExpr.fVarNames, exprVarTypes);
778778
const auto type = RetTypeOfFunc(funcName);
779779

780-
if (type.rfind("ROOT::VecOps::RVec", 0) != 0)
780+
if (type.rfind("ROOT::VecOps::RVec", 0) != 0) {
781+
// Avoid leak
782+
delete upcastNodeOnHeap;
783+
upcastNodeOnHeap = nullptr;
781784
throw std::runtime_error(
782785
"Jitted Vary expressions must return an RVec object. The following expression returns a " + type +
783786
" instead:\n" + parsedExpr.fExpr);
787+
}
784788

785789
auto colRegisterCopy = new RColumnRegister(colRegister);
786790
const auto colRegisterAddr = PrettyPrintAddr(colRegisterCopy);

0 commit comments

Comments
 (0)