Fix the issue where ipc_shmem_->read_index goes out of bounds when waiting for an IPC event. #1949
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the hipEvent_t stream-wait operation using shared-memory (IPC) events, the calculation of
offset = ipc_shmem_->read_index
does not apply a modulo with IPC_SIGNALS_PER_EVENT (which is fixed at 32), causing subsequent access to
ipc_shmem_->signal[offset]
to go out of bounds.
rocm-systems/projects/clr/hipamd/src/hip_event_ipc.cpp
Line 107 in f733871
Looking at the initialization code, ipc_shmem_->signal[] is only initialized with IPC_SIGNALS_PER_EVENT = 32 elements:
rocm-systems/projects/clr/hipamd/src/hip_event_ipc.cpp
Line 67 in f733871
Therefore, when an IPC event’s stream-wait is invoked more than 32 times, it triggers an out-of-bounds access and results in an abnormal termination — which indeed matches what we encountered in practice.