Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions python/templates/CollectionData.cc.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@
if (!isSubsetColl) {
m_data.reset(buffers.dataAsVector<{{ class.full_type }}Data>());

// The following is ugly code for the case when reading garbage data from ROOT
// after calling dataAsVector, which can trigger infinite loops that consume
// all the available memory and this works at least for GCC 15 and Clang 20 in
// {Debug,RelWithDebInfo,Release} modes.
// https://github.com/AIDASoft/podio/pull/817#issuecomment-3266748609 and
// https://github.com/AIDASoft/podio/pull/842
volatile std::uint64_t s = m_data->size();
if (s > 1e15) throw std::runtime_error("Bad data after reading: a collection is too big");
else
if (s == 0)
for ([[maybe_unused]] const auto& _ : *m_data.get())
throw std::runtime_error("Bad data after reading: zero-sized collection with data");
// end of ugly


{% for member in VectorMembers %}
m_vec_{{ member.name }}.reset(podio::CollectionReadBuffers::asVector<{{ member.full_type }}>(m_vecmem_info[{{ loop.index0 }}].second));
{% endfor %}
Expand Down