Skip to content

Fix double-free in TRT EP custom op domain Release functions#27471

Merged
tianleiwu merged 2 commits intomainfrom
copilot/address-review-feedback-issues
Mar 3, 2026
Merged

Fix double-free in TRT EP custom op domain Release functions#27471
tianleiwu merged 2 commits intomainfrom
copilot/address-review-feedback-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

Description

Apply the same double-free fix from NvTensorRtRtx EP (PR #27192) to the TRT EP.

CreateTensorRTCustomOpDomainList() owns domains/ops via static unique_ptrs, but ReleaseTensorRTCustomOpDomain() was manually delete-ing the same objects through raw pointers — double-free at program exit.

  • ReleaseTensorRTCustomOpDomain() → no-op (static unique_ptrs own the lifetime)
  • ReleaseTensorRTCustomOpDomainList()clear() the reference vector only
  • Added ownership comments to static members matching NvTensorRtRtx EP style

Motivation and Context

PR #27192 review (thread) identified TRT EP has the identical bug pattern that was fixed in NvTensorRtRtx EP. The TRT EP code was the original source this pattern was borrowed from. @tianleiwu noted a follow-up PR was needed.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Apply the same fix from NvTensorRtRtx EP (PR #27192) to the TRT EP:
- ReleaseTensorRTCustomOpDomain: make no-op since objects are owned
  by static unique_ptrs in CreateTensorRTCustomOpDomainList()
- ReleaseTensorRTCustomOpDomainList: just clear the vector instead
  of deleting static-owned objects
- Add ownership documentation comments to static members

Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix remaining review feedback issues from PR #27192 Fix double-free in TRT EP custom op domain Release functions Feb 27, 2026
@tianleiwu tianleiwu requested a review from chilo-ms February 27, 2026 01:39
@tianleiwu tianleiwu marked this pull request as ready for review February 27, 2026 01:39
@tianleiwu tianleiwu enabled auto-merge (squash) March 3, 2026 00:25
@tianleiwu tianleiwu merged commit 4a80b0b into main Mar 3, 2026
89 of 91 checks passed
@tianleiwu tianleiwu deleted the copilot/address-review-feedback-issues branch March 3, 2026 00:25
tianleiwu added a commit that referenced this pull request Mar 5, 2026
### Description

Apply the same double-free fix from NvTensorRtRtx EP ([PR
#27192](#27192)) to the TRT
EP.

`CreateTensorRTCustomOpDomainList()` owns domains/ops via static
`unique_ptr`s, but `ReleaseTensorRTCustomOpDomain()` was manually
`delete`-ing the same objects through raw pointers — double-free at
program exit.

- `ReleaseTensorRTCustomOpDomain()` → no-op (static `unique_ptr`s own
the lifetime)
- `ReleaseTensorRTCustomOpDomainList()` → `clear()` the reference vector
only
- Added ownership comments to static members matching NvTensorRtRtx EP
style

### Motivation and Context

PR #27192 review
([thread](#27192 (comment)))
identified TRT EP has the identical bug pattern that was fixed in
NvTensorRtRtx EP. The TRT EP code was the original source this pattern
was borrowed from. @tianleiwu noted a follow-up PR was needed.

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent
pull requests. You can protect all pull requests by enabling Advanced
Security for your repositories. [Learn more about Advanced
Security.](https://gh.io/cca-advanced-security)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
tianleiwu added a commit that referenced this pull request Mar 5, 2026
This cherry-picks the following commits for the release:

| Commit ID | PR Number | Commit Title |
|-----------|-----------|-------------|
| d5387d8 | #27192 | Avoid repetitive creation of fp4/fp8
native-custom-op domains for NvTensorRtRtx EP |
| 0b9906a | #27454 | Suppress spurious Array Out of Bounds warnings
produced by GCC 14.2 compiler on Linux builds |
| 4a80b0b | #27471 | Fix double-free in TRT EP custom op domain
Release functions |
| c7c939f | #27499 | Fix -Warray-bounds build error in MLAS on clang
17+ |
| f99dcca | #27514 | [Build] Fix pybind11 vcpkg configuration |
| ef04b10 | #27518 | [CXX Lora] Prevent heap OOB from maliciously
crafted Lora Adapters. |
| 0b2b6d0 | #27288 | [NvTensorRTRTX EP]: Add missing override
specifiers to suppress warnings |
| c1d8f5c | #27522 | Add "library_path" metadata entry to OrtEpDevice
instances for plugin and provider bridge EPs |
| fdead1c | #27537 | Account for ORT_NO_EXCEPTIONS builds in Lora
test |
| 3d1365e | #27521 | increase kMaxValueLength to 8192 |
| df8f4a7 | #27535 | Add OrtEnv.DisableDllImportResolver to prevent
fatal error on resolver conflict |
| bdd672a | #27356 | Add/Update telemetry events |
| 2da1a30 | #27543 | Fix RoiAlign heap out-of-bounds read via
unchecked batch_indices |
| 5c3f544 | #27466 | DQ→MatMulNBits fusion transformer for
NvTensorRtRtx ep |

---------

Co-authored-by: vishalpandya1990 <vipandya@nvidia.com>
Co-authored-by: Vishnudas Thaniel S <vishnudas.thaniel.s@intel.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Stephan Seitz <sseitz@nvidia.com>
Co-authored-by: Scott McKay <skottmckay@gmail.com>
Co-authored-by: xieofxie <xieofxie@126.com>
Co-authored-by: hualxie <hualxie@microsoft.com>
Co-authored-by: Darshak Bhatti <47045043+dabhattimsft@users.noreply.github.com>
Co-authored-by: Darshak Bhatti <dabhatti@micorsoft.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: anujj <ajalota@nvidia.com>
Co-authored-by: praneshgo <227579474+praneshgo@users.noreply.github.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.

3 participants