Skip to content

Conversation

pcanal
Copy link
Member

@pcanal pcanal commented Sep 22, 2025

No description provided.

@pcanal pcanal requested a review from Copilot September 22, 2025 15:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a bug in TTree where previously read data from a deleted scratch area could be accessed incorrectly for associative containers. The fix involves preventing duplicate reads on associative containers when the same entry is accessed multiple times, and ensures proper reset of read entry cursors for sub-branches.

Key changes:

  • Added helper function to identify associative containers and prevent duplicate reads
  • Modified entry reading logic to handle associative containers specially
  • Added recursive reset functionality for sub-branch read cursors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

void RecursiveResetReadEntry(TBranch *br) {
br->ResetReadEntry();
for(auto sub : *br->GetListOfBranches())
RecursiveResetReadEntry((TBranch*)sub);
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C-style cast to TBranch* should be replaced with a static_cast for better type safety and clarity.

Suggested change
RecursiveResetReadEntry((TBranch*)sub);
RecursiveResetReadEntry(static_cast<TBranch*>(sub));

Copilot uses AI. Check for mistakes.

Comment on lines 2803 to 2804
// this currently actually prevents the reading of the sub-branches because
// the branch count GetEntry actually relies on this code portion to do the
// reading.
Copy link
Preview

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is unclear and contains grammatical issues. Consider revising to: 'This currently prevents reading of sub-branches because the branch count GetEntry relies on this code section to perform the reading.'

Suggested change
// this currently actually prevents the reading of the sub-branches because
// the branch count GetEntry actually relies on this code portion to do the
// reading.
// This currently prevents reading of sub-branches because the branch count
// GetEntry relies on this code section to perform the reading.

Copilot uses AI. Check for mistakes.

Copy link

github-actions bot commented Sep 22, 2025

Test Results

    21 files      21 suites   3d 15h 10m 36s ⏱️
 3 667 tests  3 665 ✅ 0 💤 2 ❌
75 189 runs  75 183 ✅ 0 💤 6 ❌

For more details on these failures, see this check.

Results for commit bfba580.

♻️ This comment has been updated with latest results.

Fix one case that had not been updated to support multimap/multiset.
@pcanal pcanal force-pushed the tbranchelement-associative branch from bfba580 to 70af8e1 Compare September 23, 2025 21:28
The flow for reading an STL associative container is:
  (a) Read branch count
  (b) load sub-branch data into a staging/temporary area
  (c) copy/insert that data into the associative container
Previously doing a direct read like:
  tree->GetBranch("map.second")->GetEntry(e);
was leading to 'write' into deleted memory.
This allow to read individual sub-branches that were written as part of map but are being read into a
non-associative container (for example via an emulated proxy which for a map deprecated to vector like behavior)
@pcanal pcanal force-pushed the tbranchelement-associative branch from 70af8e1 to 4a7fa82 Compare September 23, 2025 21:52
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