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

Validate REntry belonging to right model when reading #16841

Open
hahnjo opened this issue Nov 6, 2024 · 0 comments
Open

Validate REntry belonging to right model when reading #16841

hahnjo opened this issue Nov 6, 2024 · 0 comments

Comments

@hahnjo
Copy link
Member

hahnjo commented Nov 6, 2024

Explain what you would like to see improved and how.

When passing a mismatched REntry to RNTupleReader, the following crashes:

#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleReader.hxx>
#include <ROOT/RNTupleWriter.hxx>

using ROOT::Experimental::REntry;
using ROOT::Experimental::RNTupleModel;
using ROOT::Experimental::RNTupleReader;
using ROOT::Experimental::RNTupleWriter;

#include <cstdint>

void reader_mismatch() {
  auto model = RNTupleModel::CreateBare();
  model->MakeField<std::uint16_t>("u16");
  model->Freeze();

  auto entry = model->CreateEntry();

  {
    auto writer = RNTupleWriter::Recreate(model->Clone(), "ntpl", "mismatch.root");
    // For writing, the entry is checked
    // writer->Fill(*entry);
    auto writeEntry = writer->CreateEntry();
    writer->Fill(*writeEntry);
  }

  {
    auto reader = RNTupleReader::Open(model->Clone(), "ntpl", "mismatch.root");
    // For reading, the entry is NOT checked and results in a crash!
    reader->LoadEntry(0, *entry);
    auto readEntry = reader->GetModel().CreateEntry();
    reader->LoadEntry(0, *readEntry);
  }
}

It would be nicer to throw an exception, as we do for writing. What needs thinking here is if and how this applies to the RNTupleProcessor? @enirolf

ROOT version

master

Installation method

from source

Operating system

any

Additional context

No response

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

No branches or pull requests

3 participants