Skip to content

Conversation

lbushi25
Copy link
Contributor

@lbushi25 lbushi25 commented Oct 21, 2025

Fix of #20225.

I think that the issue here is that the default accessor is being passed by reference rather than by value to the set_arg function which causes the handler object to sporadically have a corrupted copy of the accessor during its finalize function where some final checks are done. I suspect that with other types of accessors that are constructed using the command group handler, we can declare the accessor at any scope we want because some internal deep copy of the accessor is stored within the handler whereas with default constructed accessors we need a scope that will not die before the handler. This would explain the sporadic nature of the bug.

An easy fix is to move the accessor outside the scope of the command group. Since this is a host-side issue, I played around with Valgrind and indeed, before the fix, I was seeing several reports of memory access inside a deallocated region that I traced back to the default constructed accessors and after the fix, nothing, so fingers crossed.

Closes #20225

@lbushi25 lbushi25 requested a review from a team as a code owner October 21, 2025 20:19
@lbushi25 lbushi25 requested a review from vinser52 October 21, 2025 20:19
@lbushi25 lbushi25 requested a review from maarquitos14 October 21, 2025 21:28
@AlexeySachkov
Copy link
Contributor

I think that the issue here is that the default accessor is being passed by reference rather than by value to the set_arg function

Accessors are passed by-value into set_args:

template <typename DataT, int Dims, access::mode AccessMode,
access::target AccessTarget, access::placeholder IsPlaceholder>
void
set_arg(int ArgIndex,
accessor<DataT, Dims, AccessMode, AccessTarget, IsPlaceholder> Arg) {
setArgHelper(ArgIndex, std::move(Arg));
}

But they implement common reference semantics, meaning that internally we probably don't pass an actual object, but simply copy a reference to an underlying actual object.

I'm fine with merging this PR to re-enable a test for the sake of free function kernels test coverage, but I do not agree that this is a fix, it is a workaround. I do not see anything in the specification saying that this code is invalid.

which causes the handler object to sporadically have a corrupted copy of the accessor during its finalize function where some final checks are done. I suspect that with other types of accessors that are constructed using the command group handler, we can declare the accessor at any scope we want because some internal deep copy of the accessor is stored within the handler whereas with default constructed accessors we need a scope that will not die before the handler. This would explain the sporadic nature of the bug.

I think that this is a bug in our runtime implementation, not in the test. We should submit a dedicated issue about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FreeFunctionKernels/enum_parameter.cpp sporadically fails on Linux BMG L0 V2 adapter

3 participants