================
@@ -349,7 +349,10 @@ class CodeGenModule : public CodeGenTypeCache {
int Priority;
unsigned LexOrder;
llvm::Constant *Initializer;
- llvm::Constant *AssociatedData;
+ // GetOrCreateLLVMGlobal can replace and erase this global before
+ // EmitCtorList runs, so it should be a WeakTrackinhVH for RAUW to fix it
up
+ // properly.
+ llvm::WeakTrackingVH AssociatedData;
----------------
skadewdl3 wrote:
I'm.. not quite sure. I tried to come up with an example where a similar
use-after-free happens for `Initializer`, but couldn't.
I had Cursor take a crack at it, and it came up with this:
```cpp
int f();
inline int g = f();
extern "C" void __cxx_global_var_init(int x) { (void)x; }
```
Though this is valid code, I don't believe any real code would try to define
`__cxx_global_var_init` itself, so I don't think we need `WeakTrackingVH` for
`Initializer`.
https://github.com/llvm/llvm-project/pull/219137
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits