Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Sep 18, 2025

uintptr_t is usually a good idea when handling pointers, but lldb has to handle 64-bit addresses that might be from a remote system, on a 32-bit system.

So I've changed a few instances here to use addr_t which is 64-bit everywhere.

Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247

../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28: error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant expression
   81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
      |                            ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61: note: shift count 56 >= width of type 'uintptr_t' (aka 'unsigned int') (32 bits)
   81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
      |                                                             ^
1 error generated.

Original code added by #159117.

uintptr_t is usually a good idea when handling pointers, but lldb
has to handle 64-bit addresses that might be from a remote system,
on a 32-bit system.

So I've changed a few instances here to use addr_t which is 64-bit
everywhere.

Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247

```
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28: error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant expression
   81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
      |                            ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61: note: shift count 56 >= width of type 'uintptr_t' (aka 'unsigned int') (32 bits)
   81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
      |                                                             ^
1 error generated.
```
@DavidSpickett DavidSpickett added the skip-precommit-approval PR for CI feedback, not intended for review label Sep 18, 2025
@llvmbot llvmbot added the lldb label Sep 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2025

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

uintptr_t is usually a good idea when handling pointers, but lldb has to handle 64-bit addresses that might be from a remote system, on a 32-bit system.

So I've changed a few instances here to use addr_t which is 64-bit everywhere.

Before we got:
https://lab.llvm.org/buildbot/#/builders/18/builds/21247

../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:28: error: constexpr variable 'g_mte_tag_mask' must be initialized by a constant expression
   81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f &lt;&lt; g_mte_tag_shift;
      |                            ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:81:61: note: shift count 56 &gt;= width of type 'uintptr_t' (aka 'unsigned int') (32 bits)
   81 | static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f &lt;&lt; g_mte_tag_shift;
      |                                                             ^
1 error generated.

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

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp (+2-2)
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 6853121f3e01c..601cfdcb4e9f7 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -78,7 +78,7 @@ static void DescribeAddressBriefly(Stream &strm, const Address &addr,
 }
 
 static constexpr uint8_t g_mte_tag_shift = 64 - 8;
-static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
+static constexpr addr_t g_mte_tag_mask = (addr_t)0x0f << g_mte_tag_shift;
 
 bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
   const bool IsBadAccess = m_value == 1;            // EXC_BAD_ACCESS
@@ -97,7 +97,7 @@ bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
               m_exc_code, bad_address);
 
   const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift;
-  const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask;
+  const addr_t canonical_addr = bad_address & ~g_mte_tag_mask;
   strm.Printf(
       "Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64,
       tag, canonical_addr);

@DavidSpickett DavidSpickett merged commit 88b5c74 into llvm:main Sep 18, 2025
9 of 11 checks passed
@DavidSpickett
Copy link
Collaborator Author

Landing this to fix the build, but @JDevlieghere please do give it a look.

@DavidSpickett DavidSpickett deleted the lldb-machstop branch September 18, 2025 08:59
@JDevlieghere
Copy link
Member

Thanks, I saw the commit but forgot to reply here.

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

Labels

lldb skip-precommit-approval PR for CI feedback, not intended for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants