Skip to content

DPL Analysis: harden the native AOD reader against corrupt input - #16031

Open
ktf wants to merge 1 commit into
AliceO2Group:devfrom
ktf:pr16031
Open

ktf wants to merge 1 commit into
AliceO2Group:devfrom
ktf:pr16031

Conversation

@ktf

@ktf ktf commented Nov 1, 2026

Copy link
Copy Markdown
Member

Follow-up to #16019, from a review of the reader:

  • Refuse leaves with fLen <= 0, which ROOT never writes. A corrupt length
    of 0 produced columns of N rows over an empty buffer.
  • Read TBasket headers forwards, as TBasket::Streamer writes them, in one
    helper used by the container, the object reader and the decoder. Baskets
    written with TTree::kGenerateOffsetMap store a negative fNevBufSize
    followed by one fIOBits byte; reading a fixed 19-byte tail backwards from
    fKeylen misread them, so such valid files were rejected as corrupt.
  • Check that the baskets of a size branch cover its fEntries before
    allocating the offsets from it.
  • In auto mode fall back to ROOT on any exception from the native reader,
    not only on FormatError, and map any per-DF exception to an invalid
    timeframe. A DF number longer than 19 digits is refused as corrupt data
    instead of escaping as std::out_of_range.

Tested with a new decoder test for baskets with fIOBits, the AODNative unit
tests (34 cases), the framework root, aod-native and analysis-support tests,
and the native-vs-ROOT comparison on a production AO2D (264 DFs, 792 trees,
byte-identical).

Follow-up to AliceO2Group#16019, from a review of the reader:

- Refuse leaves with fLen <= 0, which ROOT never writes. A corrupt length
  of 0 produced columns of N rows over an empty buffer.
- Read TBasket headers forwards, as TBasket::Streamer writes them, in one
  helper used by the container, the object reader and the decoder. Baskets
  written with TTree::kGenerateOffsetMap store a negative fNevBufSize
  followed by one fIOBits byte; reading a fixed 19-byte tail backwards from
  fKeylen misread them, so such valid files were rejected as corrupt.
- Check that the baskets of a size branch cover its fEntries before
  allocating the offsets from it.
- In auto mode fall back to ROOT on any exception from the native reader,
  not only on FormatError, and map any per-DF exception to an invalid
  timeframe. A DF number longer than 19 digits is refused as corrupt data
  instead of escaping as std::out_of_range.

Tested with a new decoder test for baskets with fIOBits, the AODNative unit
tests (34 cases), the framework root, aod-native and analysis-support tests,
and the native-vs-ROOT comparison on a production AO2D (264 DFs, 792 trees,
byte-identical).
@ktf
ktf requested a review from a team as a code owner November 1, 2026 22:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant