-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Fix SegFault when accessor passed to reduction is destroyed early #3498
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
[SYCL] Fix SegFault when accessor passed to reduction is destroyed early #3498
Conversation
The error may happen when the copy of the accessor passed to ONEAPI::reduction is destroyed right after being passed to reduction. The fix is simple - to create a new copy of the given accessor. Signed-off-by: Vyacheslav N Klochkov <[email protected]>
@@ -508,30 +508,24 @@ class reduction_impl : private reduction_impl_base { | |||
} | |||
|
|||
/// Constructs reduction_impl when the identity value is statically known. | |||
// Note that aliasing constructor was used to initialize MRWAcc to avoid |
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.
Why "aliasing constructor" was not enough?
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.
The idea of using aliasing constructor was to give the pointer to user's accessor to shared_ptr, but not release memory (i.e. user's accessor) when that shared_ptr is destroyed, at least that is how I understood it when wrote that code.
That was wrong approach for cases where user's accessor is destroyed before the accessor is needed in reduction computation.
At this line: https://github.com/v-klochkov/llvm-test-suite/blob/public_vklochkov_reduction_ctor_acc_destroyed_early/SYCL/Reduction/reduction_nd_lambda.cpp#L41
MRWAcc shared_ptr holded a pointer to released memory.
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.
OK, thanks for explanation
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
The corresponding change in SYCL RT: intel/llvm#3498 Signed-off-by: Vyacheslav N Klochkov <[email protected]>
…or (#222) The corresponding change in SYCL RT: intel/llvm#3498 Signed-off-by: Vyacheslav N Klochkov <[email protected]>
…or (intel/llvm-test-suite#222) The corresponding change in SYCL RT: intel#3498 Signed-off-by: Vyacheslav N Klochkov <[email protected]>
The error may happen when the copy of the accessor passed to ONEAPI::reduction
is destroyed right after being passed to reduction.
The fix is simple - to create a new copy of the given accessor.
The corresponding LIT test changes: intel/llvm-test-suite#222
Signed-off-by: Vyacheslav N Klochkov [email protected]