llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Philipp Dominik Schubert (pdschbrt)

<details>
<summary>Changes</summary>

CodeGenModule::DeferredAnnotations was keyed by StringRef, but not every 
mangled name passed to GetOrCreateLLVMFunction outlives the call. 
CodeGenVTables::maybeEmitThunk mangles the thunk name into a stack-local 
SmallString and hands it to GetAddrOfThunk, so for an annotated virtual 
function the map retained a reference into a frame that was gone by the time 
EmitGlobalAnnotations looked the key up.

ASan reports this as a stack-use-after-return in EmitGlobalAnnotations, with 
the freed frame being maybeEmitThunk's 'Name'. The user-visible effect is that 
annotations silently disappear from the this-adjusting thunks once the dead 
frame has been reused.

Make the key own its storage, using StringMap&lt;unsigned&gt; as the MapVector 
map type so lookups still hash a StringRef without allocating.

---
Full diff: https://github.com/llvm/llvm-project/pull/226942.diff


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.md (+4) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2-2) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+4-1) 
- (added) clang/test/CodeGenCXX/attr-annotate-thunk.cpp (+40) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you 
try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/226942
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to