Repository navigation
[ntuple] Fail cleanly if a field value cannot be constructed - #23806
Open
SamdaniSayam wants to merge 1 commit into
Open
SamdaniSayam wants to merge 1 commit into
SamdaniSayam wants to merge 1 commit into
Conversation
RClassField::ConstructValue() ignored TClass::New() failures, so MakeField<Abstract>() or MakeField<T>() for a class without a default constructor returned a pointer to unconstructed memory. For interpreted classes, TClass::New() also JITs a constructor wrapper; the failed compilation is what triggered the Cling state corruption from root-project#13910. Check kIsAbstract and HasDefaultConstructor() before calling TClass::New(), throw an RException if construction fails, and free the allocated buffer. Also make REntry::AddValue() construct the value before recording the field name/type so a failed MakeField() leaves the entry unchanged. Add a roottest regression covering abstract classes, classes without a default constructor, and continued model/interpreter use afterwards.
SamdaniSayam
requested review from
bellenot,
dpiparo,
jblomer and
silverweed
as code owners
October 23, 2026 05:20
1 task done
Member
|
Did you have a look to https://github.com/root-project/root/blob/master/CONTRIBUTING.md#ai-assisted-coding-disclosure ? |
Author
|
AI-assisted coding disclosure (per CONTRIBUTING.md):
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RClassField::ConstructValue()ignored failures fromTClass::New(). For an abstract class, or a class without a default constructor,TClass::New()first JITs a constructor wrapper that fails to compile and then returnsnullptr. RNTuple ignored that return value, soMakeField<T>()returned a non-nullstd::shared_ptr<T>to unconstructed memory. Destroying that value crashes inRClassDeleter. The failed JIT compilation is also the trigger for the Cling state corruption reported in #13910.This PR:
kIsAbstractandHasDefaultConstructor(kTRUE)before callingTClass::New(), throwsRExceptionwith a useful message otherwise, and checks theTClass::New()return value;RSoAFieldandRStreamerField;RFieldBase::CreateObjectRawPtr()if construction throws;REntry::AddValue()before recording the field name/type, so a failedMakeField()leaves the default entry/model unchanged;roottestregression for abstract types, no-default-constructor types, partial-entry corruption, and continued use of the same model/interpreter.There are no public API changes: the new behavior is a thrown
RExceptionwhere a broken object used to be returned.Validation
g++ -fsyntax-onlypasses for the modified translation units against 6.40.04 headers.MakeField<Abstract>()emitted the Cling error, returned a non-null pointer to unconstructed memory, and teardown segfaulted inRClassDeleter.RException; the same model still acceptsstd::vector<float>and a concrete derived class with an abstract base.REntry::AddValue, the regression'sHasFieldchecks catch the partially added field; with the reorderedAddValue, they pass.all MakeField failure checks passed.I could not run a full ROOT rebuild in this environment (8 cores, limited memory), so CI will be the first full-build run.
Related to #13910 (this addresses the RNTuple side; the Cling transaction/rollback discussion may still need a separate fix).