[all-commits] [llvm/llvm-project] eac746: [LTO] Fix a crash with thin LTO caching and asm ou...

Alexey Karyakin via All-commits all-commits at lists.llvm.org
Wed May 14 08:34:20 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eac7466448f920e733f12beca28ff848cfa4810d
      https://github.com/llvm/llvm-project/commit/eac7466448f920e733f12beca28ff848cfa4810d
  Author: Alexey Karyakin <akaryaki at quicinc.com>
  Date:   2025-05-14 (Wed, 14 May 2025)

  Changed paths:
    M llvm/lib/LTO/LTOBackend.cpp
    A llvm/test/ThinLTO/X86/cache-emit-asm.ll

  Log Message:
  -----------
  [LTO] Fix a crash with thin LTO caching and asm output (#138203)

The `CacheStream::commit()` function (defined in Caching.cpp) deletes
the underlying raw stream. Some output streamers may hold a pointer
to it, which then will outlive the stream object.
In particular, MCAsmStreamer keeps the pointer to the raw stream
though a separate `formatted_raw_stream` object, which buffers data and
there is no path to explicitly flush this data. Before this change,
the buffered data was flushed during the MCAsmStreamer destructor.
After #136121, this happened after the `commit()` function is called.
Therefore, it caused a crash because the `formatted_raw_stream` object
tries to write the buffered data into a deleted raw stream. Even if
we don't delete the stream to avoid the crash, it would be too late
as the output stream cannot accept data after commit().

Fixes: #138194.



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