8446b7
From 2ce7bf1ad5fd7aee21975b3dd1c8dceef3aab7e4 Mon Sep 17 00:00:00 2001
8446b7
From: David Mitchell <davem@iabyn.com>
8446b7
Date: Tue, 9 Mar 2021 16:42:11 +0000
8446b7
Subject: [PATCH] Perl_do_sv_dump(): handle PL_strtab
8446b7
MIME-Version: 1.0
8446b7
Content-Type: text/plain; charset=UTF-8
8446b7
Content-Transfer-Encoding: 8bit
8446b7
8446b7
When dumping this special hash, the values in the HE entry are refcounts
8446b7
rather than SV pointers. sv_dump() used to crash here.
8446b7
8446b7
Petr Písař: Ported to 5.32.1 from upstream
8446b7
a9bb6a62ae45bb372a5cca98a76d1a79edd89ccb.
8446b7
8446b7
Signed-off-by: Petr Písař <ppisar@redhat.com>
8446b7
---
8446b7
 dump.c | 11 +++++++++--
8446b7
 1 file changed, 9 insertions(+), 2 deletions(-)
8446b7
8446b7
diff --git a/dump.c b/dump.c
8446b7
index f03c3f6..0f15d77 100644
8446b7
--- a/dump.c
8446b7
+++ b/dump.c
8446b7
@@ -2224,8 +2224,15 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
8446b7
                             PerlIO_printf(file, "[UTF8 \"%s\"] ", sv_uni_display(d, keysv, 6 * SvCUR(keysv), UNI_DISPLAY_QQ));
8446b7
 			if (HvEITER_get(hv) == he)
8446b7
 			    PerlIO_printf(file, "[CURRENT] ");
8446b7
-                        PerlIO_printf(file, "HASH = 0x%" UVxf "\n", (UV) hash);
8446b7
-                        do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
8446b7
+                        PerlIO_printf(file, "HASH = 0x%" UVxf, (UV) hash);
8446b7
+
8446b7
+                        if (sv == (SV*)PL_strtab)
8446b7
+                            PerlIO_printf(file, " REFCNT = 0x%" UVxf "\n",
8446b7
+                                (UV)he->he_valu.hent_refcount );
8446b7
+                        else {
8446b7
+                            (void)PerlIO_putc(file, '\n');
8446b7
+                            do_sv_dump(level+1, file, elt, nest+1, maxnest, dumpops, pvlim);
8446b7
+                        }
8446b7
                     }
8446b7
 		}
8446b7
 	      DONEHV:;
8446b7
-- 
8446b7
2.26.3
8446b7