AIDASoft / podio

PODIO
GNU General Public License v3.0
24 stars 59 forks source link

Invalid files cause irrecoverable crashes in `ROOTReader::openFile(...)` #401

Closed veprbl closed 7 months ago

veprbl commented 1 year ago

include <podio/EventStore.h>

include <podio/Frame.h>

include <podio/ROOTFrameWriter.h>

include <podio/ROOTReader.h>

include <datamodel/EventInfoCollection.h>

int main() { { auto col = EventInfoCollection();

col.create();

podio::Frame frame;

frame.put(std::move(col), "infos");

podio::ROOTFrameWriter writer("frames.root");
writer.writeFrame(frame, "events");
writer.finish();

}

{ auto reader = podio::ROOTReader(); reader.openFile("frames.root");

auto store = podio::EventStore();
store.setReader(&reader);

reader.closeFile();

}

return EXIT_SUCCESS; }

 - Input: link to input files if applicable
 - Output:

Break segmentation violation [/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info) [] (no debug info) [/Users/veprbl/podio/prefix/lib/libpodioRootIO.so] podio::ROOTReader::openFile(std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const&) /Users/veprbl/podio/src/ROOTReader.cc:140 [/Users/veprbl/podio/build/tests/roundtrip] main /Users/veprbl/podio/tests/roundtrip.cpp:27 [/usr/lib/system/libdyld.dylib] start (no debug info) [] (no debug info)


 - Goal: We are looking to be able to be able to provide meaningful error messages. A typical case is to fail when a file with frames written by DD4hep 01-25+ is processed by the ROOTReader.
tmadlener commented 1 year ago

Thanks for reporting this. Given that the ROOTReader and the EventStore are deprecated now, we will probably not fix these. However, a similar issue exists in the new Frame based readers as well, where the only check that exists with a "nice" exception is whether the file exists.

This doesn't fix anything for you, but the python bindings deal with this slightly better as we have implemented some functionality there for detecting this:

from podio.reading import get_reader
reader = get_reader("<filename>")
# ...

https://github.com/AIDASoft/podio/blob/9cd03731dfe4b4c37eac34e6364411bb55be940a/python/podio/reading.py#L33-L57

tmadlener commented 7 months ago

Closing this since the EventStore based Readers and Writers have been removed in #485