Skip to content

Conversation

@DanBlackwell
Copy link
Contributor

Currently, on Darwin running with -fsanitize=memtag-stack generates compact-unwind exception unwinding that does not untag MTE-tagged memory on the way back up.

This patch forces dwarf unwinding on MTE-tagged frames.

rdar://162195539

Currently, running with -fsanitize=memtag-stack generates CompactUnwind exception unwinding that does not untag MTE-tagged memory on the way back up on Darwin.

This patch forces dwarf unwinding on MTE-tagged frames.

rdar://162195539
@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Dan Blackwell (DanBlackwell)

Changes

Currently, on Darwin running with -fsanitize=memtag-stack generates compact-unwind exception unwinding that does not untag MTE-tagged memory on the way back up.

This patch forces dwarf unwinding on MTE-tagged frames.

rdar://162195539


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

1 Files Affected:

  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp (+5)
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index 7a2b6790f8a5b..1f9694cf98fec 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -586,6 +586,11 @@ class DarwinAArch64AsmBackend : public AArch64AsmBackend {
   /// Generate the compact unwind encoding from the CFI directives.
   uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
                                          const MCContext *Ctxt) const override {
+    // MTE-tagged frames must use DWARF unwinding because compact unwind
+    // doesn't handle MTE tags
+    if (FI->IsMTETaggedFrame)
+      return CU::UNWIND_ARM64_MODE_DWARF;
+
     ArrayRef<MCCFIInstruction> Instrs = FI->Instructions;
     if (Instrs.empty())
       return CU::UNWIND_ARM64_MODE_FRAMELESS;

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

🐧 Linux x64 Test Results

  • 186369 tests passed
  • 4859 tests skipped

@efriedma-quic
Copy link
Collaborator

Testcase?

@DanBlackwell
Copy link
Contributor Author

Testcase?

I've added one now thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants