[Lldb-commits] [lldb] [debugserver] Support for `qMemTags` packet	(PR #160952)
    David Spickett via lldb-commits 
    lldb-commits at lists.llvm.org
       
    Thu Oct  2 02:14:03 PDT 2025
    
    
  
================
@@ -0,0 +1,28 @@
+#include <malloc/malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Produce some names on the trace
+const size_t tag_granule = 16;
+static uint8_t *my_malloc(void) { return malloc(2 * tag_granule); }
+static uint8_t *allocate(void) { return my_malloc(); }
+
+static void my_free(void *ptr) { free(ptr); }
+static void deallocate(void *ptr) { my_free(ptr); }
+
+static void touch_memory(uint8_t *ptr) { ptr[7] = 1; } // invalid access
+static void modify(uint8_t *ptr) { touch_memory(ptr); }
+
+int main() {
+  uint8_t *ptr = allocate();
+
+  strncpy((char *)ptr, "Hello", 16);
+  strncpy((char *)ptr + 16, "World", 16);
+
+  deallocate(ptr); // before free
+
+  modify(ptr); // use-after-free
----------------
DavidSpickett wrote:
Ok I'm guessing since you don't have to PROT_MTE like we do on Linux, that tagging is a per process property?
Which makes your job significantly easier.
https://github.com/llvm/llvm-project/pull/160952
    
    
More information about the lldb-commits
mailing list