[llvm] [offload] Do not pool memory while allocation traces are requested (PR #214752)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 07:48:14 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Robert Imschweiler (ro-i)
<details>
<summary>Changes</summary>
Would otherwise hide use-after-free because memory stays valid if it's in the pool.
---
Full diff: https://github.com/llvm/llvm-project/pull/214752.diff
1 Files Affected:
- (modified) offload/plugins-nextgen/common/src/PluginInterface.cpp (+6-2)
``````````diff
diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp
index e539cbfc55324..d4f3d8b62a272 100644
--- a/offload/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp
@@ -598,9 +598,13 @@ Error GenericDeviceTy::init(GenericPluginTy &Plugin) {
GridValues.GV_Max_WG_Size =
std::min(GridValues.GV_Max_WG_Size, uint32_t(OMP_TeamsThreadLimit));
- // Enable the memory manager if required.
+ // Enable the memory manager if required. Memory that the manager pools is
+ // not returned to the driver when it is freed, so a later access to it
+ // neither faults nor is reported by the allocation tracker. Leave the pool
+ // disabled while allocation traces are requested, so that we don't mask
+ // use-after-free (since they don't fault if the memory is still in the pool).
auto [ThresholdMM, EnableMM] = MemoryManagerTy::getSizeThresholdFromEnv();
- if (EnableMM) {
+ if (EnableMM && !OMPX_TrackAllocationTraces) {
if (ThresholdMM == 0)
ThresholdMM = getMemoryManagerSizeThreshold();
MemoryManager = new MemoryManagerTy(*this, ThresholdMM);
``````````
</details>
https://github.com/llvm/llvm-project/pull/214752
More information about the llvm-commits
mailing list