You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to run Functional algorithms with mismatched input types without any check catching that at runtime. I.e. if users put in a wrong collection name by accident, things will ideally explode without an apparent reason why or, even worse, run but produce garbage.
Operating System and Version
all
compiler
all
The version of the key4hep stack
nightlies
Package Version
main
Reproducer
As a minimal reproducer consider the following transformer
structTypeMisMatchDemofinal : k4FWCore::Transformer<edm4hep::MCParticleCollection(const edm4hep::TrackCollection&)> {
TypeMisMatchDemo(const std::string& name, ISvcLocator* svcLoc)
: Transformer(name, svcLoc, {KeyValues("InputCollection", {"MCParticles"})},
{KeyValues("OutputCollection", {"MCParticles2"})}) {}
edm4hep::MCParticleCollection operator()(const edm4hep::TrackCollection& inputs) constfinal {
debug() << inputs.size() << " type = " << inputs.getTypeName() << endmsg;
auto track = inputs[0];
// The next line goes boom if the input is not really a TrackerHitCollectiondebug() << track.getTrackerHits().size() << endmsg;
return edm4hep::MCParticleCollection{};
}
};
We get a segmentation fault, because inputs is not actually a edm4hep::TrackerHitCollection, but rather a edm4hep::MCParticleCollection. Depending on which functions we call on the input collection and its members, we either get a segmentation fault (yay) or simply apparently run without problems (but most likely not with what we intended to to).
Check duplicate issues.
Issue
It is possible to run Functional algorithms with mismatched input types without any check catching that at runtime. I.e. if users put in a wrong collection name by accident, things will ideally explode without an apparent reason why or, even worse, run but produce garbage.
Operating System and Version
all
compiler
all
The version of the key4hep stack
nightlies
Package Version
main
Reproducer
As a minimal reproducer consider the following transformer
if we pair this with the following python config:
We get a segmentation fault, because
inputs
is not actually aedm4hep::TrackerHitCollection
, but rather aedm4hep::MCParticleCollection
. Depending on which functions we call on theinput
collection and its members, we either get a segmentation fault (yay) or simply apparently run without problems (but most likely not with what we intended to to).I have added the simple reproducer as a test case on https://github.com/tmadlener/K4FWCore/tree/mismatch-repro
Additional context
The underlying issue is the
static_cast
here:k4FWCore/k4FWCore/include/k4FWCore/FunctionalUtils.h
Line 147 in ce56844
The text was updated successfully, but these errors were encountered: