Skip to content

fix(rocDecode): Runtime environment variable cleanup#8869

Open
jeffqjiangNew wants to merge 7 commits into
developfrom
users/jeffqjiangNew/rocDecode_env_var_cleanup
Open

fix(rocDecode): Runtime environment variable cleanup#8869
jeffqjiangNew wants to merge 7 commits into
developfrom
users/jeffqjiangNew/rocDecode_env_var_cleanup

Conversation

@jeffqjiangNew

Copy link
Copy Markdown
Contributor

Motivation

This PR resolves the libva load issue with the sample apps and removes the environment variable workaround.

Technical Details

  • Symptom
    Running a sample app linked to FFmpeg libs on an installed TheRock stack can result in a runtime libva error.
  • Root cause
    rocDeocde core library links to the vendor libva which comes with the TheRock stack. FFmpeg links to the system libva. These two libva copies can have different versions and difference function symbols. Since the sample app links to FFmpeg libs before rocDecode lib, the system libva enters the global scope first and gets loaded. It then tries to open a VA driver version which is not in the TheRock stack.
  • The workaround
    Currently we set both LD_PRELOAD and LIBVA_DRIVERS_PATH env vars to force loading the vendor libva copy.
  • The fix
    In each sample's CMakeLists.txt, immediately before target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARY_LIST}), prepend the vendor libva as a forced early direct dependency.

Issue Tracking

AICV-192

Test Plan

Remove both LD_PRELOAD and LIBVA_DRIVERS_PATH env vars and run a FFmpeg linked sample app.

Test Result

The sample app runs fine.

Submission Checklist

jeffqjiangNew and others added 2 commits July 17, 2026 18:34
On TheRock installs, running a sample directly failed with
"radeonsi_drv_video.so has no function __vaDriverInit_1_0". librocdecode.so
links the vendored libva (librocm_sysdeps_va.so.2, VA 1.22), but the samples
link system FFmpeg which drags in system libva (VA 1.14). Because the FFmpeg
libs preceded librocdecode.so in DT_NEEDED order, system libva won the
unversioned vaInitialize and dlopened TheRock's driver with the wrong init
symbol. CTest masked this by injecting LD_PRELOAD of the vendored libva.

Fix: in each sample CMakeLists.txt, on TheRock installs, link the vendored
libva as a forced early direct dependency (-Wl,--no-as-needed) so it wins
symbol resolution. It then self-locates its VA driver via its compiled-in
default path, so neither LD_PRELOAD nor LIBVA_DRIVERS_PATH is needed.

- samples/*/CMakeLists.txt: force vendored libva first in link order
- test/CMakeLists.txt: drop now-redundant VA LD_PRELOAD/LIBVA_DRIVERS_PATH
  injection (ASAN preload retained)
- docs: remove LD_PRELOAD/LIBVA_DRIVERS_PATH run instructions (ROCM_PATH kept)

Verified: default (6/6) and extended FFmpeg-demuxer (4/4) CTest suites pass
in a clean environment with no LD_PRELOAD or LIBVA_DRIVERS_PATH set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocdecode labels Jul 20, 2026
@therock-pr-bot

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
🌿 Branch Name ✅ Pass
📝 PR Title/Description ❌ Fail 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
JIRA ID (on separate line)
ROCM-25757
ISSUE ID : TESTUTO-3334
ISSUE ID #3334
ISSUE ID - TESTAUTO-3433
ISSUE ID (on separate line)
AIRUNTIME-2352
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 ✅ Pass PR does not contain code files — Unit Test auto-passed
🔎 pre-commit ⏳ Pending ⏳ Still running…
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

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

🚫 Please fix the failed policies

  • ❌ PR Title/Description

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

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

This PR aims to eliminate the runtime libva loader conflict seen on TheRock-installed stacks by removing the LD_PRELOAD/LIBVA_DRIVERS_PATH workaround and instead forcing sample executables to link the TheRock-provided libva early so it wins global symbol resolution.

Changes:

  • Removed TheRock-specific environment-variable injection for CTest runs in projects/rocdecode/test.
  • Updated multiple sample CMakeLists.txt files to prepend libva libraries (via find_package(Libva)) before other link dependencies.
  • Updated rocDecode documentation and changelog to remove the LD_PRELOAD/LIBVA_DRIVERS_PATH instructions and note the new behavior.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
projects/rocdecode/test/CMakeLists.txt Removes TheRock LD_PRELOAD/LIBVA_DRIVERS_PATH environment workaround for tests.
projects/rocdecode/samples/videoToSequence/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodeRaw/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodePicFiles/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodeMultiFiles/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/videoDecode/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/samples/rocdecDecode/CMakeLists.txt Attempts to force early libva linkage for TheRock builds.
projects/rocdecode/docs/tutorials/rocDecode-samples.rst Removes environment-variable workaround instructions from sample-running docs.
projects/rocdecode/docs/how-to/using-rocDecode-videodecode-sample.rst Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only.
projects/rocdecode/docs/how-to/using-rocDecode-video-decoder.rst Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only.
projects/rocdecode/docs/how-to/using-rocDecode-rocdecdecoder.rst Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only.
projects/rocdecode/docs/how-to/using-rocDecode-ffmpeg.rst Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only.
projects/rocdecode/docs/how-to/using-rocDecode-bitstream.rst Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only.
projects/rocdecode/CHANGELOG.md Adds a changelog entry about resolving the vendored libva link issue.

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

Comment thread projects/rocdecode/samples/videoDecode/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoToSequence/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodePicFiles/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeRaw/CMakeLists.txt Outdated
Comment thread projects/rocdecode/samples/rocdecDecode/CMakeLists.txt Outdated
Comment thread projects/rocdecode/test/CMakeLists.txt

@AryanSalmanpour AryanSalmanpour left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jeffqjiangNew 9 rocdecode CTESTs are failing with the current PR.

https://github.com/ROCm/rocm-systems/actions/runs/29769363209/job/88449819570?pr=8869

The following tests FAILED:
	  7 - video_decode-HEVC (Failed)
	  8 - video_decode-AVC (Failed)
	  9 - video_decode-AV1 (Failed)
	 10 - video_decode-VP9 (Failed)
	 11 - video_decodePerf-HEVC (Failed)
	 12 - video_decodeBatch (Failed)
	 13 - video_decodeRGB-HEVC (Failed)
	 14 - video_decodeMem-HEVC (Failed)
	 15 - video_decodeRGB-Resize (Failed)

Comment thread projects/rocdecode/test/CMakeLists.txt
Comment thread projects/rocdecode/docs/how-to/using-rocDecode-bitstream.rst
… as the first DT_NEEDED instead of linking libva; the app no

  longer links libva at all.

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

Copilot reviewed 17 out of 17 changed files in this pull request and generated 12 comments.

Comment thread projects/rocdecode/samples/videoToSequence/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeRaw/CMakeLists.txt Outdated
Comment thread projects/rocdecode/samples/videoDecodePicFiles/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt
Comment thread projects/rocdecode/samples/videoDecode/CMakeLists.txt
Comment thread projects/rocdecode/samples/rocdecDecode/CMakeLists.txt Outdated
Comment thread projects/rocdecode/samples/videoDecodeRaw/CMakeLists.txt Outdated
Comment thread projects/rocdecode/samples/rocdecDecode/CMakeLists.txt Outdated

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

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

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.

3 participants