Repository navigation
[core] Fix TDataMember::GetOffsetCint interference with GetOffset #23844
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -446,7 +446,12 @@ const char *TDataMember::GetTrueTypeName() const | |
|
|
||
| Longptr_t TDataMember::GetOffset() const | ||
| { | ||
| if (fOffset>=0) return fOffset; | ||
| if (Property() & (kIsStatic | kIsEnum)) { | ||
| Error("GetOffset", "Cannot get offset of static or enum data member %s", GetName()); | ||
| return -1; | ||
| } | ||
|
|
||
| if (fOffset >= 0) return fOffset; | ||
|
|
||
| R__LOCKGUARD(gInterpreterMutex); | ||
| //case of an interpreted or emulated class | ||
|
|
@@ -495,13 +500,17 @@ Longptr_t TDataMember::GetOffset() const | |
|
|
||
| Longptr_t TDataMember::GetOffsetCint() const | ||
| { | ||
| if (fOffset>=0) return fOffset; | ||
| if (fOffset >= 0) return fOffset; | ||
|
|
||
| R__LOCKGUARD(gInterpreterMutex); | ||
| TDataMember *dm = const_cast<TDataMember*>(this); | ||
|
|
||
| if (dm->IsValid()) return gCling->DataMemberInfo_Offset(dm->fInfo); | ||
| else return -1; | ||
| if (dm->IsValid()) { | ||
| Longptr_t offset = gCling->DataMemberInfo_Offset(dm->fInfo); | ||
| dm->fOffset = offset; | ||
| return offset; | ||
| } | ||
| return -1; | ||
|
Comment on lines
+508
to
+513
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure this is the right solution. A priori the value can be as well cached for these call as for the previous call. It is not clear whether there is really a need for both functions to be distinct. However this need a deep analysis of the usage pattern in ROOT and in user codes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @pcanal. Should we cache this into a dedicated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The firsts step is to do an analysis of whether it makes sense or not to merge the 2 or to protect them from being called in the wrong context.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking through the codebase usages:
Would it make sense to protect
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should indeed protect
One special feature of it may make sense to add a new function Side note: Cppyy::GetDatamemberOffset is the only non-test usage of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated as suggested: protected |
||
| } | ||
|
|
||
| //////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the best solution. The address of the enums and static should also be cached. The main issue is that
GetOffsetupdatesfOffsetto a valid looking value instead of leaving it to-1when called with static and enums.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, now caching the address in
fOffsetwithinGetOffsetCint().