[all-commits] [llvm/llvm-project] f792f1: [WebAssembly] Allocate MCSymbolWasm data on MCCont...

Tim Neumann via All-commits all-commits at lists.llvm.org
Tue Apr 2 10:59:50 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f792f14b01605453c7c0c17f3b4564335c0d9d14
      https://github.com/llvm/llvm-project/commit/f792f14b01605453c7c0c17f3b4564335c0d9d14
  Author: Tim Neumann <timnn at google.com>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M llvm/include/llvm/MC/MCContext.h
    M llvm/lib/MC/MCContext.cpp
    M llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
    M llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
    A llvm/test/MC/WebAssembly/module-asm.ll

  Log Message:
  -----------
  [WebAssembly] Allocate MCSymbolWasm data on MCContext (#85866)

Fixes #85578, a use-after-free caused by some `MCSymbolWasm` data being
freed too early.

Previously, `WebAssemblyAsmParser` owned the data that is moved to
`MCContext` by this PR, which caused problems when handling module ASM,
because the ASM parser was destroyed after parsing the module ASM, but
the symbols persisted.

The added test passes locally with an LLVM build with AddressSanitizer
enabled.

Implementation notes:

* I've called the added method
<code>allocate<b><i>Generic</i></b>String</code> and added the second
paragraph of its documentation to maybe guide people a bit on when to
use this method (based on my (limited) understanding of the `MCContext`
class). We could also just call it `allocateString` and remove that
second paragraph.
* The added `createWasmSignature` method does not support taking the
return and parameter types as arguments: Specifying them afterwards is
barely any longer and prevents them from being accidentally specified in
the wrong order.
* This removes a _"TODO: Do the uniquing of Signatures here instead of
ObjectFileWriter?"_ since the field it's attached to is also removed.
Let me know if you think that TODO should be preserved somewhere.



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