[Lldb-commits] [PATCH] D127016: [lldb] Prevent crash due to reading memory from page zero.

Chelsea Cassanova via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 8 15:18:31 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f02dd34f226: [lldb/Commands] Prevent crash due to reading memory from page zero. (authored by cassanova).

Changed prior to commit:
  https://reviews.llvm.org/D127016?vs=434172&id=435359#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127016/new/

https://reviews.llvm.org/D127016

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/Shell/Driver/TestPageZeroRead.test


Index: lldb/test/Shell/Driver/TestPageZeroRead.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Driver/TestPageZeroRead.test
@@ -0,0 +1,6 @@
+# REQUIRES: system-darwin
+# Ensure that the read from memory command doesn't try and read from page zero.
+# RUN: %clang_host %p/Inputs/hello.c -g -o a.out
+# RUN: %lldb -b a.out -o 'settings set interpreter.stop-command-source-on-error false' -s %s 2>&1 | FileCheck %s
+x 0
+# CHECK: error: error reading data from section __PAGEZERO
Index: lldb/source/Commands/CommandObjectMemory.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -592,7 +592,10 @@
       return false;
     }
 
-    ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI();
+    ABISP abi;
+    if (Process *proc = m_exe_ctx.GetProcessPtr())
+      abi = proc->GetABI();
+
     if (abi)
       addr = abi->FixDataAddress(addr);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127016.435359.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220608/0473190c/attachment.bin>


More information about the lldb-commits mailing list