Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
veprbl opened this issue Mar 27, 2023 · 2 comments
Closed

Comments

@veprbl
Copy link
Contributor

veprbl commented Mar 27, 2023

  • OS version: macOS
  • Compiler version: 11.1.0
  • PODIO version: 00-16-02
  • Reproduced by:
#include <cstddef>

#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)
[<unknown binary>] (no debug info)
[/Users/veprbl/podio/prefix/lib/libpodioRootIO.so] podio::ROOTReader::openFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > 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)
[<unknown binary>] (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
Copy link
Collaborator

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>")
# ...

def get_reader(filename):
"""Get an appropriate reader for the passed file.
Args:
filename (str): The input file
Returns:
root_io.[Legacy]Reader, sio_io.[Legacy]Reader: an initialized reader that
is able to process the input file.
Raises:
ValueError: If the file cannot be recognized, or if podio has not been
built with the necessary backend I/O support
"""
if filename.endswith('.sio'):
if _is_frame_sio_file(filename):
return sio_io.Reader(filename)
return sio_io.LegacyReader(filename)
if filename.endswith('.root'):
if _is_frame_root_file(filename):
return root_io.Reader(filename)
return root_io.LegacyReader(filename)
raise ValueError('file must end on .root or .sio')

@tmadlener
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants