Skip to content

[AMDGPU] Scope hsaco tmp dir per-user to avoid collisions.#484

Merged
duburcqa merged 2 commits intomainfrom
duburcqa/qd_amdgpu_tmp_per_user
Apr 15, 2026
Merged

[AMDGPU] Scope hsaco tmp dir per-user to avoid collisions.#484
duburcqa merged 2 commits intomainfrom
duburcqa/qd_amdgpu_tmp_per_user

Conversation

@duburcqa
Copy link
Copy Markdown
Contributor

@duburcqa duburcqa commented Apr 15, 2026

Description

Scopes the AMDGPU JIT's hsaco temp directory per user (/tmp/quadrants_hsaco_<uid>/ instead of /tmp/quadrants_hsaco/), so the first user on a shared host doesn't lock everyone else out with a Permission denied when creating subdirectories. Also treats an empty
QD_TMP_DIR env var the same as unset, removing a pre-existing UB (tmp_dir_[SIZE_MAX]) the first commit was sitting next to.

Good points

  • Fixes a real shared-host footgun: previously a single mkdir /tmp/quadrants_hsaco/ by user A made qd.init(arch=qd.amdgpu) crash for every other user on the box until someone chmod'd or removed the directory.
  • The empty-env-var path is now well-defined (falls back to the per-user default) instead of indexing past the end of an empty string.
  • Minimal change: one line for the path, three for the env-var guard. No behavior change for users who already set QD_TMP_DIR to a real path.

Bad points

  • getuid() is POSIX-only, so the patch is Linux-only by construction. cmake/QuadrantsCore.cmake already forces QD_WITH_AMDGPU off on Windows and macOS, so this matches the existing build matrix rather than narrowing it.

Comment thread quadrants/runtime/amdgpu/jit_amdgpu.h Outdated
Comment thread quadrants/runtime/amdgpu/jit_amdgpu.h Outdated
Copy link
Copy Markdown
Collaborator

@hughperkins hughperkins left a comment

Choose a reason for hiding this comment

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

Thanks!

@duburcqa duburcqa changed the title [Bug] AMDGPU JIT: scope hsaco tmp dir per-user to avoid multi-user collisions. [Bug] AMDGPU JIT: scope hsaco tmp dir per-user to avoid collisions. Apr 15, 2026
@duburcqa duburcqa changed the title [Bug] AMDGPU JIT: scope hsaco tmp dir per-user to avoid collisions. [AMDGPU] AMDGPU JIT: scope hsaco tmp dir per-user to avoid collisions. Apr 15, 2026
@duburcqa duburcqa changed the title [AMDGPU] AMDGPU JIT: scope hsaco tmp dir per-user to avoid collisions. [AMDGPU] Scope hsaco tmp dir per-user to avoid collisions. Apr 15, 2026
@duburcqa duburcqa force-pushed the duburcqa/qd_amdgpu_tmp_per_user branch from 45634d8 to aa977dc Compare April 15, 2026 16:03
@duburcqa duburcqa enabled auto-merge (squash) April 15, 2026 17:13
@duburcqa duburcqa merged commit 9f7e43b into main Apr 15, 2026
47 checks passed
@duburcqa duburcqa deleted the duburcqa/qd_amdgpu_tmp_per_user branch April 15, 2026 17:24
gpinkert pushed a commit to ROCm/quadrants that referenced this pull request Apr 28, 2026
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.

2 participants