Skip to content

Prevent hanging when opening old REST files with schema mismatches#563

Open
cmargalejo wants to merge 2 commits intomasterfrom
cris_fix_old_file_hang
Open

Prevent hanging when opening old REST files with schema mismatches#563
cmargalejo wants to merge 2 commits intomasterfrom
cris_fix_old_file_hang

Conversation

@cmargalejo
Copy link
Copy Markdown
Member

@cmargalejo cmargalejo commented Apr 17, 2026

cmargalejo Ok: 22 Powered by Pull Request Badge

This PR prevents restRoot from hanging when opening files produced with older REST versions.

Context

When a REST file is produced, each class (e.g. TRestDetectorSignalToHitsProcess) is saved with a specific internal layout: which fields, in which order, how many bytes. If the class changes in a newer version, this layout no longer matches. ROOT tries to reconcile the old data with the new layout, but in some cases gets stuck, causing restRoot to hang at GetEntry(0). This fix detects those errors and skips the event loading, printing a warning instead. The analysis tree (ana_tree) and metadata remain accessible. Files produced with compatible versions are (or at least should be) unaffected.

How it works

  • ROOT provides a function called SetErrorHandler() that allows replacing the default error printing with a custom function.
  • We use this to temporarily install our own handler (SchemaErrorHandler) that does two things. It prints the error as usual, and sets a flag if the error is related to schema mismatches.
  • Before calling GetEntry(0) (the line that causes the hang), we check the flag. If schema errors were found, we skip GetEntry(0) and print a warning instead.
  • The custom handler is only active while the file is being opened. After that, ROOT's default handler is restored

Tested with two files:

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

Successfully merging this pull request may close these issues.

1 participant