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

[ntuple] Fixes and cleanups for RRecordField and subclasses #16764

Merged
merged 5 commits into from
Oct 29, 2024

Conversation

hahnjo
Copy link
Member

@hahnjo hahnjo commented Oct 28, 2024

  • Remove dangerous RField constructors, where the user could pass subfields into typed RField<std::pair<T1, T2>> and RField<std::tuple<ItemTs...>> without checks.
  • Avoid UB in RRecordField construction, related to unspecified order of evaluation of function arguments.
  • Take container of unique_ptr's by value, to signal ownership handover.
  • Fix fSize calculation in RRecordField::AttachItemFields, to have less (critical) logic in the typed RField constructors.

For typed RField<std::pair<T1, T2>> and RField<std::tuple<ItemTs...>>,
it is dangerous to accept user-created item fields because there is
no check that the types match.
In C++, the order of evaluation of function arguments is unspecified.
This could lead to problems in the constructors of RPairField and
RTupleField where itemFields was both std::move'd and passed to the
respective GetTypeList. (In practice, the base class constructor took
itemFields as xvalue so it was only passing a pointer.)

This cannot be solved when callign a base class constructor, so split
attaching the item fields into a separate method.
Similar to taking a single std::unique_ptr by value to signal ownership
handover, we should take containers thereof by value. This avoids having
two overloads and requires the user to explicitly move the container of
item fields instead of modifying it when passed by reference.
@hahnjo hahnjo self-assigned this Oct 28, 2024
It was missing the trailing padding, which was covered up by the typed
RField specializations overriding the fSize member. Convert them into
assertions, which can only compare inequality because the alignment of
RMapField and RSetField are pessimized since commit 49ef6f9.
Copy link
Contributor

@jblomer jblomer left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

Copy link

Test Results

    18 files      18 suites   3d 18h 38m 1s ⏱️
 2 699 tests  2 698 ✅ 0 💤 1 ❌
46 086 runs  46 085 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit bcc29e8.

@hahnjo hahnjo merged commit 1dfe02c into root-project:master Oct 29, 2024
19 of 21 checks passed
@hahnjo hahnjo deleted the ntuple-record branch October 29, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants