[llvm-bugs] [Bug 48095] New: Stack memory object managed by a unique_ptr in GCNIterativeScheduler::OverrideLegacyStrategy

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 5 23:34:00 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48095

            Bug ID: 48095
           Summary: Stack memory object managed by a unique_ptr in
                    GCNIterativeScheduler::OverrideLegacyStrategy
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AMDGPU
          Assignee: unassignedbugs at nondot.org
          Reporter: alansnape3058 at gmail.com
                CC: llvm-bugs at lists.llvm.org

In function GCNIterativeScheduler::scheduleLegacyMaxOccupancy of file
llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp on line 492, a "stack memory
object managed by a unique_ptr" is reported by my clang static analyzer fork.

A local variable of GCNMaxOccupancySchedStrategy is created on line 512, then
its address is managed by a unique_ptr through the call to the constructor of
OverrideLegacyStrategy on line 520 and the call to unique_ptr::reset on line
193. Although the managed local address is released from the unique_ptr on line
202 in the destructor of OverrideLegacyStrategy, it would be better to replace
the local variable with a heap memory object, as smart pointers without
customized deleters are not originally designed for non-heap memory objects.

---

The reported execution path:

In function GCNIterativeScheduler::scheduleLegacyMaxOccupancy

512   GCNMaxOccupancySchedStrategy LStrgy(Context);
--> Local variable 'LStrgy' is defined.

520       OverrideLegacyStrategy Ovr(*R, LStrgy, *this);
--> Local address of variable 'LStrgy' is taken as a reference when calling the
constructor of OverrideLegacyStrategy.

In function
GCNIterativeScheduler::OverrideLegacyStrategy::OverrideLegacyStrategy

193     Sch.SchedImpl.reset(&OverrideStrategy);
--> Assign the address of the local variable 'LStrgy' to a unique_ptr.

---

Suggested fix:

Replace the local variable on line 512 with a unique_ptr or a new-ed memory
object.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201106/885f33dc/attachment-0001.html>


More information about the llvm-bugs mailing list