[all-commits] [llvm/llvm-project] f4dd1b: [AMDGPU] Fix leak and self-assignment in copy assi...
Fraser Cormack via All-commits
all-commits at lists.llvm.org
Wed Sep 11 02:24:03 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f4dd1bc8fc625d3938f95b9d06aaaeebd2e90dca
https://github.com/llvm/llvm-project/commit/f4dd1bc8fc625d3938f95b9d06aaaeebd2e90dca
Author: Fraser Cormack <fraser at codeplay.com>
Date: 2024-09-11 (Wed, 11 Sep 2024)
Changed paths:
M llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h
Log Message:
-----------
[AMDGPU] Fix leak and self-assignment in copy assignment operator (#107847)
A static analyzer identified that this operator was unsafe in the case
of self-assignment.
In the placement new statement, StringValue's copy constructor was being
implicitly called, which received a reference to "itself". In fact, it
was being passed an old StringValue at the same address - one whose
lifetime had already ended. The copy constructor was thus copying fields
from a dead object.
We need to be careful when switching active union members, and calling
the destructor on the old StringValue will avoid memory leaks which I
believe the old code exhibited.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list