File 2306-etp.py-Test-for-bad-list-and-boxed-pointers.patch of Package erlang

From 46dd49f7fe52b65f688752e97dc6f584c83a5091 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Mon, 12 Apr 2021 06:05:26 +0200
Subject: [PATCH 5/7] etp.py: Test for bad list and boxed pointers

---
 erts/etc/unix/etp.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/erts/etc/unix/etp.py b/erts/etc/unix/etp.py
index 88afc26998..0eac75a5bb 100644
--- a/erts/etc/unix/etp.py
+++ b/erts/etc/unix/etp.py
@@ -310,7 +310,14 @@ def cons(valobj, depth = float('inf')):
     improper = False
     truncated = False
     depth *= 20
-    
+
+    ptr = cdr.CreateValueFromData(
+        "unconsed",
+        lldb.SBData.CreateDataFromInt(cdr.unsigned - 1),
+        EtermPtr(cdr.target))
+    if ptr.deref.error.fail:
+        return "#ConsError<%x>" % cdr.unsigned;
+
     while True:
         ptr = cdr.CreateValueFromData(
             "unconsed",
@@ -370,7 +377,10 @@ def boxed(valobj, depth = float('inf')):
         "unboxed",
         lldb.SBData.CreateDataFromInt(valobj.unsigned - 2),
         EtermPtr(valobj.target))
-    boxed_hdr = ptr.deref.unsigned
+    boxed_hdr = ptr.deref
+    if boxed_hdr.error.fail:
+        return "#BoxedError<%x>" % valobj.unsigned;
+    boxed_hdr = boxed_hdr.unsigned
     if boxed_hdr & 0x3f == 0x00:
         arity = (boxed_hdr >> 6)
         terms = []
-- 
2.26.2

openSUSE Build Service is sponsored by