Skip to content

[lldb] Truncate an over-wide symbol address in the IR interpreter#210372

Merged
JDevlieghere merged 1 commit into
llvm:mainfrom
JDevlieghere:wasm-ir-interprter
Jul 17, 2026
Merged

[lldb] Truncate an over-wide symbol address in the IR interpreter#210372
JDevlieghere merged 1 commit into
llvm:mainfrom
JDevlieghere:wasm-ir-interprter

Conversation

@JDevlieghere

Copy link
Copy Markdown
Member

IRInterpreter::ResolveConstantValue built a pointer-width APInt directly from the address returned by FindSymbol. That address can be wider than a target pointer, because lldb records extra information in the high bits on some targets, such as the code/memory address-space tag on WebAssembly.

A 32-bit pointer then cannot hold the tagged address and the APInt constructor asserts, aborting the debugger when a function-valued expression is evaluated (for example expr main).

Truncate to the pointer width instead of asserting, matching the idiom already used in DWARFExpression. On targets whose addresses fit in a pointer this is a no-op.

IRInterpreter::ResolveConstantValue built a pointer-width APInt directly
from the address returned by FindSymbol. That address can be wider than a
target pointer, because lldb records extra information in the high bits on
some targets, such as the code/memory address-space tag on WebAssembly.

A 32-bit pointer then cannot hold the tagged address and the APInt
constructor asserts, aborting the debugger when a function-valued
expression is evaluated (for example `expr main`).

Truncate to the pointer width instead of asserting, matching the idiom
already used in DWARFExpression. On targets whose addresses fit in a
pointer this is a no-op.
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

IRInterpreter::ResolveConstantValue built a pointer-width APInt directly from the address returned by FindSymbol. That address can be wider than a target pointer, because lldb records extra information in the high bits on some targets, such as the code/memory address-space tag on WebAssembly.

A 32-bit pointer then cannot hold the tagged address and the APInt constructor asserts, aborting the debugger when a function-valued expression is evaluated (for example expr main).

Truncate to the pointer width instead of asserting, matching the idiom already used in DWARFExpression. On targets whose addresses fit in a pointer this is a no-op.


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

1 Files Affected:

  • (modified) lldb/source/Expression/IRInterpreter.cpp (+6-1)
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index 163f9dac384eb..8a696c27fb262 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -267,7 +267,12 @@ class InterpreterStackFrame {
         lldb::addr_t addr = m_execution_unit.FindSymbol(name, missing_weak);
         if (addr == LLDB_INVALID_ADDRESS)
           return false;
-        value = APInt(m_target_data.getPointerSizeInBits(), addr);
+        // A resolved symbol address may be wider than a target pointer when we
+        // store extra information in the high bits, such as an address-space
+        // tag. Truncate to the pointer width rather than asserting. When the
+        // address already fits this is a no-op.
+        value = APInt(m_target_data.getPointerSizeInBits(), addr,
+                      /*isSigned=*/false, /*implicitTrunc=*/true);
         return true;
       }
       break;

@JDevlieghere
JDevlieghere merged commit 977eced into llvm:main Jul 17, 2026
13 checks passed
@JDevlieghere
JDevlieghere deleted the wasm-ir-interprter branch July 17, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants