Skip to content

Bad error handling with pyroot template instantiations #11854

Description

@bendavid

In some cases with template instantiation from pyroot together with RDF code which should fail to compile with clear error messages leads instead to cryptic output. Even worse, execution continues and gives undefined results.

Example

import ROOT

ret = ROOT.gInterpreter.Declare('#include "test.h"')

print("declare ret", ret)

print("creating helper")
helper = ROOT.helper[ROOT.std.vector["double"]]()

d = ROOT.ROOT.RDataFrame(1000)

print("Define with helper")
d = d.Define("fx", helper, [])
print("done define")

res = d.Sum("fx")

print(res.GetValue())
template <typename T>
class helper {

public:

  helper() {}

  std::size_t operator() () {
    const double res = 0.;
    res = T{0, 0}.size();
    return res;
  }

};

Note the assignment to const double which should fail to compile.

output (centos stream 8, root 6.26/10)

declare ret True
creating helper
Define with helper
IncrementalExecutor::executeFunction: symbol '_ZN6helperISt6vectorIdSaIdEEEclEv' unresolved while linking symbol '__cf_13'!
You are probably missing the definition of helper<std::vector<double, std::allocator<double> > >::operator()()
Maybe you need to load the corresponding shared library?
done define
9.408421539373414e+16

(if the spurious const is removed then instead one gets the correct output of 2000 and no error message)

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions