-
Notifications
You must be signed in to change notification settings - Fork 113
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
[PROTOTYPE] Add unused temporary storage to single work-group scan to fix use-after free error #1712
[PROTOTYPE] Add unused temporary storage to single work-group scan to fix use-after free error #1712
Conversation
@@ -681,6 +681,10 @@ __parallel_transform_scan_single_group(oneapi::dpl::__internal::__device_backend | |||
// Specialization for devices that have a max work-group size of 1024 | |||
constexpr ::std::uint16_t __targeted_wg_size = 1024; | |||
|
|||
using _ValueType = typename _InitType::__value_type; | |||
using _TempStorage = __result_and_scratch_storage<std::decay_t<_ExecutionPolicy>, _ValueType>; | |||
_TempStorage __result_and_scratch{__exec, 0}; |
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.
Can we name this __dummy_result_and_scratch
or something similar to draw attention to why this is here but unused in practice?
Also can we add a comment explaining the purpose of this dummy scratch space?
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 renamed it and added a comment explaining why it's here.
@@ -699,17 +703,17 @@ __parallel_transform_scan_single_group(oneapi::dpl::__internal::__device_backend | |||
::std::integral_constant<::std::uint16_t, __num_elems_per_item>, _BinaryOperation, | |||
/* _IsFullGroup= */ std::true_type, _Inclusive, _CustomName>>>()( | |||
::std::forward<_ExecutionPolicy>(__exec), std::forward<_InRng>(__in_rng), | |||
std::forward<_OutRng>(__out_rng), __n, __init, __binary_op, __unary_op); | |||
std::forward<_OutRng>(__out_rng), __n, __init, __binary_op, __unary_op, __result_and_scratch); |
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.
Do we need to pass this scratch space in only to return it?
Perhaps it is more clear if we instead return an event from the submitter, and construct the future here with the dummy variable. It would make it more clear that it goes unused, and minimize the changes required.
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.
Good point. I changed the submitters to return an event and constructed the future in the outer context instead.
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.
LGTM
LGTM (from phone) |
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
… fix use-after free error (#1712)
We were throwing away the result and scratch container inside of the future in
__parallel_transform_scan
because we needed to return a future without storage. This was causing a use-after free error because the scratch storage was freed before it was used in the kernel.