Skip to content

[CLR] Fix hipMemUnmap segfault on multi-GPU: guard null device memory… - #8402

Merged
jaydeeppatel1111 merged 3 commits into
developfrom
users/jaypatel/pal-getmemaccess-null-deref-hipmemunmap-mgpu
Jul 20, 2026
Merged

[CLR] Fix hipMemUnmap segfault on multi-GPU: guard null device memory…#8402
jaydeeppatel1111 merged 3 commits into
developfrom
users/jaypatel/pal-getmemaccess-null-deref-hipmemunmap-mgpu

Conversation

@jaydeeppatel1111

@jaydeeppatel1111 jaydeeppatel1111 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

… in PAL GetMemAccess.

Motivation

hipMemUnmap segfaults on Windows with 2 GPUs while passing with 1 GPU. Crash occurs inside pal::Device::GetMemAccess during the multi-device access-probe loop added for synchronous unmap.

Technical Details

hipMemUnmap segfaults on Windows with 2 GPUs while passing with 1 GPU. Crash occurs inside pal::Device::GetMemAccess during the multi-device access-probe loop added for synchronous unmap.

JIRA ID

ROCM-27508

Test Plan

Seg faulting failures from reported tests.
830 - Unit_hipMemVmm_Uncached (SEGFAULT)
1141 - Unit_hipPointerGetAttribute_ipc_capable (SEGFAULT)
2484 - Unit_hipMemRetainAllocationHandle_SetGet (SEGFAULT)
2485 - Unit_hipMemRetainAllocationHandle_NegTst (SEGFAULT)
2486 - Unit_hipMemRetainAllocationHandle_Capture (SEGFAULT)
2487 - Unit_hipGetProcAddress_VMM (SEGFAULT)
2492 - Unit_hipMemCreate_ChkDev2HstMemcpy_ReleaseHdlPostUnmap (SEGFAULT)
2493 - Unit_hipMemCreate_ChkDev2HstMemcpy_ReleaseHdlPreUse (SEGFAULT)
2494 - Unit_hipMemCreate_ChkWithMemset (SEGFAULT)
2497 - Unit_hipMemSetAccess_SegmentsAccess (SEGFAULT)
2498 - Unit_hipMemSetAccess_Vmm2PeerPeerMemCpy (SEGFAULT)
2499 - Unit_hipMemSetGetAccess_Capture (SEGFAULT)
2503 - Unit_hipMemMap_VMMMemoryReuse_SingleGPU (SEGFAULT)
2504 - Unit_hipMemMap_MapPartialVMMMem (SEGFAULT)
2505 - Unit_hipMemMap_Capture (SEGFAULT)
2507 - Unit_hipMemMap_Retrieve_AllocationHandle (SEGFAULT)
2508 - Unit_hipMemMap_Retrieve_MultiAllocationHandle (SEGFAULT)
2509 - Unit_hipMemMap_CheckAddMemObj (SEGFAULT)
2510 - Unit_hipMemMap_RoundTrip (SEGFAULT)
2511 - Unit_hipMemMap_ConcurrentDisjointMapsNoDeadlock (SEGFAULT)
2514 - Unit_hipMemUnmap_negative (SEGFAULT)
2515 - Unit_hipMemUnmap_Capture (SEGFAULT)
2516 - Unit_hipMemUnmap_CrossLinksTornDown (SEGFAULT)
2517 - Unit_hipMemUnmap_RemapCrossLinks (SEGFAULT)
2518 - Unit_hipMemUnmap_DirectPath_BasicRoundTrip (SEGFAULT)
2519 - Unit_hipMemUnmap_DirectPath_InFlightKernelDrained (SEGFAULT)

Test Result

Seg faulting failures from reported tests pass.

Submission Checklist

@therock-pr-bot

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
🌿 Branch Name ✅ Pass
📝 PR Title/Description ❌ Fail Error: Title does not follow Conventional Commits style.
Expected: start with a valid type (feat, fix, docs, …).
Desired format: type(optional-scope): short description
───
Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
JIRA ID : TESTAUTO-6039
JIRA ID - #330
JIRA ID #330
ISSUE ID : TESTUTO-3334
ISSUE ID #3334
ISSUE ID - TESTAUTO-3433
ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
Closes #10
Fixes octo-org/octo-repo#100
Resolves: #123
#123
https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
Forbidden Files ✅ Pass
🧪 Unit Test ❌ Fail Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/clr/rocclr/device/pal/paldevice.cpp; no test file found
🔎 pre-commit ⏳ Pending ⏳ Still running…
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

⚠️ 2 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Title/Description
  • ❌ Unit Test

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

@therock-pr-bot

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Title/Description
  • ❌ Unit Test

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a multi-GPU Windows crash in the PAL backend where hipMemUnmap can probe a VA on a device that doesn’t physically back the allocation, leading to a null dereference inside pal::Device::GetMemAccess.

Changes:

  • Switch GetMemAccess to query device backing without allocating (getDeviceMemory(*this, false)).
  • Add a nullptr guard to avoid dereferencing a missing per-device memory backing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread projects/clr/rocclr/device/pal/paldevice.cpp

@AidanBeltonS AidanBeltonS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks fine, one change needed

Comment thread projects/clr/rocclr/device/pal/paldevice.cpp
@jaydeeppatel1111
jaydeeppatel1111 force-pushed the users/jaypatel/pal-getmemaccess-null-deref-hipmemunmap-mgpu branch from 2faf711 to d10491b Compare July 12, 2026 05:59
@litvaOo
litvaOo force-pushed the users/jaypatel/pal-getmemaccess-null-deref-hipmemunmap-mgpu branch from 66bebc9 to b7bb881 Compare July 13, 2026 07:24
@jaydeeppatel1111

Copy link
Copy Markdown
Contributor Author

Hello @gandryey, @saleelk , Can you pls review this PR? thanks!

@jaydeeppatel1111
jaydeeppatel1111 merged commit ca63267 into develop Jul 20, 2026
64 of 76 checks passed
@jaydeeppatel1111
jaydeeppatel1111 deleted the users/jaypatel/pal-getmemaccess-null-deref-hipmemunmap-mgpu branch July 20, 2026 10:51
systems-assistant Bot pushed a commit to ROCm/clr that referenced this pull request Jul 20, 2026
 =?UTF-8?q?ti-GPU:=20guard=20null=20device=20memory=E2=80=A6=20(#8402)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

… in PAL GetMemAccess.

## Motivation

hipMemUnmap segfaults on Windows with 2 GPUs while passing with 1 GPU.
Crash occurs inside pal::Device::GetMemAccess during the multi-device
access-probe loop added for synchronous unmap.

## Technical Details

hipMemUnmap segfaults on Windows with 2 GPUs while passing with 1 GPU.
Crash occurs inside pal::Device::GetMemAccess during the multi-device
access-probe loop added for synchronous unmap.

## JIRA ID

ROCM-27508

## Test Plan

Seg faulting failures from reported tests.
        830 - Unit_hipMemVmm_Uncached (SEGFAULT)
        1141 - Unit_hipPointerGetAttribute_ipc_capable (SEGFAULT)
        2484 - Unit_hipMemRetainAllocationHandle_SetGet (SEGFAULT)
        2485 - Unit_hipMemRetainAllocationHandle_NegTst (SEGFAULT)
        2486 - Unit_hipMemRetainAllocationHandle_Capture (SEGFAULT)
        2487 - Unit_hipGetProcAddress_VMM (SEGFAULT)
2492 - Unit_hipMemCreate_ChkDev2HstMemcpy_ReleaseHdlPostUnmap (SEGFAULT)
2493 - Unit_hipMemCreate_ChkDev2HstMemcpy_ReleaseHdlPreUse (SEGFAULT)
        2494 - Unit_hipMemCreate_ChkWithMemset (SEGFAULT)
        2497 - Unit_hipMemSetAccess_SegmentsAccess (SEGFAULT)
        2498 - Unit_hipMemSetAccess_Vmm2PeerPeerMemCpy (SEGFAULT)
        2499 - Unit_hipMemSetGetAccess_Capture (SEGFAULT)
        2503 - Unit_hipMemMap_VMMMemoryReuse_SingleGPU (SEGFAULT)
        2504 - Unit_hipMemMap_MapPartialVMMMem (SEGFAULT)
        2505 - Unit_hipMemMap_Capture (SEGFAULT)
        2507 - Unit_hipMemMap_Retrieve_AllocationHandle (SEGFAULT)
        2508 - Unit_hipMemMap_Retrieve_MultiAllocationHandle (SEGFAULT)
        2509 - Unit_hipMemMap_CheckAddMemObj (SEGFAULT)
        2510 - Unit_hipMemMap_RoundTrip (SEGFAULT)
2511 - Unit_hipMemMap_ConcurrentDisjointMapsNoDeadlock (SEGFAULT)
        2514 - Unit_hipMemUnmap_negative (SEGFAULT)
        2515 - Unit_hipMemUnmap_Capture (SEGFAULT)
        2516 - Unit_hipMemUnmap_CrossLinksTornDown (SEGFAULT)
        2517 - Unit_hipMemUnmap_RemapCrossLinks (SEGFAULT)
        2518 - Unit_hipMemUnmap_DirectPath_BasicRoundTrip (SEGFAULT)
2519 - Unit_hipMemUnmap_DirectPath_InFlightKernelDrained (SEGFAULT)

## Test Result

Seg faulting failures from reported tests pass.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
[rocm-systems] ROCm/rocm-systems#8402 (commit ca63267)
anujshuk-amd pushed a commit that referenced this pull request Jul 21, 2026
#8402)

… in PAL GetMemAccess.

## Motivation

hipMemUnmap segfaults on Windows with 2 GPUs while passing with 1 GPU.
Crash occurs inside pal::Device::GetMemAccess during the multi-device
access-probe loop added for synchronous unmap.

## Technical Details

hipMemUnmap segfaults on Windows with 2 GPUs while passing with 1 GPU.
Crash occurs inside pal::Device::GetMemAccess during the multi-device
access-probe loop added for synchronous unmap.

## JIRA ID

ROCM-27508

## Test Plan

Seg faulting failures from reported tests.
        830 - Unit_hipMemVmm_Uncached (SEGFAULT)
        1141 - Unit_hipPointerGetAttribute_ipc_capable (SEGFAULT)
        2484 - Unit_hipMemRetainAllocationHandle_SetGet (SEGFAULT)
        2485 - Unit_hipMemRetainAllocationHandle_NegTst (SEGFAULT)
        2486 - Unit_hipMemRetainAllocationHandle_Capture (SEGFAULT)
        2487 - Unit_hipGetProcAddress_VMM (SEGFAULT)
2492 - Unit_hipMemCreate_ChkDev2HstMemcpy_ReleaseHdlPostUnmap (SEGFAULT)
2493 - Unit_hipMemCreate_ChkDev2HstMemcpy_ReleaseHdlPreUse (SEGFAULT)
        2494 - Unit_hipMemCreate_ChkWithMemset (SEGFAULT)
        2497 - Unit_hipMemSetAccess_SegmentsAccess (SEGFAULT)
        2498 - Unit_hipMemSetAccess_Vmm2PeerPeerMemCpy (SEGFAULT)
        2499 - Unit_hipMemSetGetAccess_Capture (SEGFAULT)
        2503 - Unit_hipMemMap_VMMMemoryReuse_SingleGPU (SEGFAULT)
        2504 - Unit_hipMemMap_MapPartialVMMMem (SEGFAULT)
        2505 - Unit_hipMemMap_Capture (SEGFAULT)
        2507 - Unit_hipMemMap_Retrieve_AllocationHandle (SEGFAULT)
        2508 - Unit_hipMemMap_Retrieve_MultiAllocationHandle (SEGFAULT)
        2509 - Unit_hipMemMap_CheckAddMemObj (SEGFAULT)
        2510 - Unit_hipMemMap_RoundTrip (SEGFAULT)
2511 - Unit_hipMemMap_ConcurrentDisjointMapsNoDeadlock (SEGFAULT)
        2514 - Unit_hipMemUnmap_negative (SEGFAULT)
        2515 - Unit_hipMemUnmap_Capture (SEGFAULT)
        2516 - Unit_hipMemUnmap_CrossLinksTornDown (SEGFAULT)
        2517 - Unit_hipMemUnmap_RemapCrossLinks (SEGFAULT)
        2518 - Unit_hipMemUnmap_DirectPath_BasicRoundTrip (SEGFAULT)
2519 - Unit_hipMemUnmap_DirectPath_InFlightKernelDrained (SEGFAULT)

## Test Result

Seg faulting failures from reported tests pass.

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

---------

Co-authored-by: Jaydeep Patel <jaypatel@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants