-
Notifications
You must be signed in to change notification settings - Fork 9
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
#1574: objgroup: fix ubsan error with improper casting #1575
Conversation
src/vt/objgroup/manager.impl.h
Outdated
auto const type_idx = proxy::ObjGroupProxy::getTypeIdx(proxy_bits); | ||
auto const getter = registry::getObjGetter(type_idx); | ||
auto ptr = getter(proxy_bits, objs_); | ||
return static_cast<ObjT*>(ptr); |
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.
If you're just going to get back void*
and static_cast
it here, why not type erase at the point of storage, and just just look up the void*
? I.e. what purpose does the holder serve now?
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.
That said, I'm fine with just going with this. The code around this is already horrifically complicated, through use of the registry, so this isn't making it much worse. I don't think this is likely to be catastrophically bad for performance
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.
I'll approve, you can decide whether you want to merge or take a different approach.
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.
If you're just going to get back
void*
andstatic_cast
it here, why not type erase at the point of storage, and just just look up thevoid*
? I.e. what purpose does the holder serve now?
The holder holds a unique_ptr to the actual object so it can be destroyed properly. If it was stored as a void*
, it would not fire the destructor.
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.
There is another potential solution of using a virtual method in the base holder to get to the void*. Would you prefer that approach?
src/vt/objgroup/manager.impl.h
Outdated
auto const type_idx = proxy::ObjGroupProxy::getTypeIdx(proxy_bits); | ||
auto const getter = registry::getObjGetter(type_idx); | ||
auto ptr = getter(proxy_bits, objs_); | ||
return static_cast<ObjT*>(ptr); |
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.
I'll approve, you can decide whether you want to merge or take a different approach.
PR tests (clang-10, ubuntu, mpich) Build for cfdee3e
|
ad310e0
to
cfdee3e
Compare
I like this solution more. It's super simple compared to |
Codecov Report
@@ Coverage Diff @@
## develop #1575 +/- ##
===========================================
- Coverage 82.96% 82.90% -0.07%
===========================================
Files 784 784
Lines 29740 29740
===========================================
- Hits 24675 24655 -20
- Misses 5065 5085 +20
|
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 a work of art
Fixes #1574