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