Skip to content

[VitisAI] fix dangling pointer#27949

Merged
adrianlizarraga merged 2 commits intomicrosoft:mainfrom
amd-genmingz:fix_vitisai_dangling_pointer
Apr 10, 2026
Merged

[VitisAI] fix dangling pointer#27949
adrianlizarraga merged 2 commits intomicrosoft:mainfrom
amd-genmingz:fix_vitisai_dangling_pointer

Conversation

@amd-genmingz
Copy link
Copy Markdown
Contributor

@amd-genmingz amd-genmingz commented Apr 2, 2026

Description

set the pointer to nullptr immediately after UnloadDynamicLibrary.

Motivation and Context

After unload library, set the function pointer to nullptr to avoid a dangling pointer. Otherwise, the following scenario may cause errors:

RegisterExecutionProviderLibrary()
SessionOptions::AppendExecutionProvider_VitisAI()

In this scenario, the OrtVitisAIEpAPI will call initialize_vitisai_ep once but call deinitialize_vitisai_ep twice. During deinitialization, functions deinitialize_onnxruntime_vitisai_ep are invoked, which leads to errors.

@adrianlizarraga
Copy link
Copy Markdown
Contributor

Hi @amd-genmingz Could you please sync this branch with main to make the DML CI check pass?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 addresses a use-after-unload risk in the VitisAI EP loader by clearing cached function pointers immediately after unloading the onnxruntime_vitisai_ep dynamic library, preventing later accidental invocations of stale pointers.

Changes:

  • Update OrtVitisAIEpAPI::Clear() to set all resolved function pointers to nullptr after UnloadDynamicLibrary.
  • Ensure the deinitialization function pointer is cleared as part of shutdown to avoid double-deinit calling into unloaded code.

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

@amd-genmingz amd-genmingz force-pushed the fix_vitisai_dangling_pointer branch from 56a5096 to 8da6f4b Compare April 7, 2026 02:19
@amd-genmingz
Copy link
Copy Markdown
Contributor Author

Hi @adrianlizarraga This request has been synchronized to main; please re-trigger CI checks.

@amd-genmingz
Copy link
Copy Markdown
Contributor Author

Hi @adrianlizarraga @a-akoval Can we trigger CI and then proceed with the merge process?

@adrianlizarraga
Copy link
Copy Markdown
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 1 out of 1 changed files in this pull request and generated 1 comment.


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

@adrianlizarraga adrianlizarraga enabled auto-merge (squash) April 10, 2026 08:33
@adrianlizarraga adrianlizarraga merged commit 5e55544 into microsoft:main Apr 10, 2026
98 checks passed
@amd-genmingz amd-genmingz deleted the fix_vitisai_dangling_pointer branch April 10, 2026 10:57
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.

5 participants