Bug#1115373: perl: Data::Dumper bugs with shared arrays and hashes with circular loops

David Christensen dpchrist at holgerdanske.com
Tue Sep 16 01:56:00 BST 2025


Package: perl
Version: 5.32.1-4+deb11u4
Severity: normal
X-Debbugs-Cc: dpchrist at holgerdanske.com

Dear Maintainer,

I use Perl and use the module Data::Dumper for development.
Unforunately, it fails on deep recursion when I attempt to dump
shared arrays or hashes with circular loops:

2025-09-15 17:45:55 dpchrist at laalaa ~/sandbox/perl
$ cat /etc/debian_version ; uname -a ; perl -v
11.11
Linux laalaa 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64 GNU/Linux

This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux-gnu-thread-multi
(with 56 registered patches, see perl -V for more detail)

Copyright 1987-2021, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


2025-09-15 17:45:56 dpchrist at laalaa ~/sandbox/perl
$ cat Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 
#!/usr/bin/env perl
# $Id: Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t,v 1.1 2025/09/16 00:19:45 dpchrist Exp $
#
# Demonstrate Data::Dumper bugs:
# 1.  Shared arrays with circular loops.
# 2.  Shared hashes with circular loops.
#
# By David Paul Christensen dpchrist at holgerdanske.com
# Public Domain.

use strict;
use warnings;
use threads;
use threads::shared;

use Data::Dumper;
use Test::More;

sub ok_r
{
    my ($f, $l, $r) = @_;
    ok
       	$r,
       	join
	    $",
	    $f,
	    $l,
	    '$r=' . (defined($r) ? "'$r'" : 'undef');
}

{
diag 'my $s';
      my $s;
    my $r = Data::Dumper->Dump([$s], [qw(s)]);
    ok_r(__FILE__, __LINE__, $r);
diag '$s = \$s';
      $s = \$s;
    $r = Data::Dumper->Dump([$s], [qw(s)]);
    ok_r(__FILE__, __LINE__, $r);
}

{
diag 'my $ss :shared';
      my $ss :shared;
    my $r = Data::Dumper->Dump([$ss], [qw(ss)]);
    ok_r(__FILE__, __LINE__, $r);
diag '$ss = \$ss';
      $ss = \$ss;
    $r = Data::Dumper->Dump([$ss], [qw(ss)]);
    ok_r(__FILE__, __LINE__, $r);
}

{
diag 'my @a';
      my @a;
    my $r = Data::Dumper->Dump([\@a], [qw(*a)]);
    ok_r(__FILE__, __LINE__, $r);
diag '$a[0] = \@a';
      $a[0] = \@a;
    $r = Data::Dumper->Dump([\@a], [qw(*a)]);
    ok_r(__FILE__, __LINE__, $r);
}

{
diag 'my @sa :shared';
      my @sa :shared;
    my $r = Data::Dumper->Dump([\@sa], [qw(*sa)]);
    ok_r(__FILE__, __LINE__, $r);
diag '$sa[0] = \@sa';
      $sa[0] = \@sa;
TODO: {
    local $TODO = "Shared array with circular loop";
    $r = eval { Data::Dumper->Dump([\@sa], [qw(*sa)]) };
    warn $@ if $@;
    ok_r(__FILE__, __LINE__, $r);
}}

{
diag 'my %h';
      my %h;
    my $r = Data::Dumper->Dump([\%h], [qw(*h)]);
    ok_r(__FILE__, __LINE__, $r);
diag '$h{loop} = \%h';
      $h{loop} = \%h;
    $r = Data::Dumper->Dump([\%h], [qw(*h)]);
    ok_r(__FILE__, __LINE__, $r);
}

{
diag 'my %sh :shared';
      my %sh :shared;
    my $r = Data::Dumper->Dump([\%sh], [qw(*sh)]);
    ok_r(__FILE__, __LINE__, $r);
diag '$sh{loop} = \%sh';
      $sh{loop} = \%sh;
TODO: {
    local $TODO = "Shared hash with circular loop";
    $r = eval { Data::Dumper->Dump([\%sh], [qw(*sh)]) };
    warn $@ if $@;
    ok_r(__FILE__, __LINE__, $r);
}}

done_testing;


2025-09-15 17:46:02 dpchrist at laalaa ~/sandbox/perl
$ perl Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 
# my $s
ok 1 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 35 $r='$s = undef;
# '
# $s = \$s
ok 2 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 39 $r='$s = \$s;
# '
# my $ss :shared
ok 3 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 46 $r='$ss = undef;
# '
# $ss = \$ss
ok 4 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 50 $r='$ss = \$ss;
# '
# my @a
ok 5 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 57 $r='@a = ();
# '
# $a[0] = \@a
ok 6 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 61 $r='@a = (
#        \@a
#      );
# '
# my @sa :shared
ok 7 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 68 $r='@sa = ();
# '
# $sa[0] = \@sa
Recursion limit of 1000 exceeded at /usr/lib/x86_64-linux-gnu/perl/5.32/Data/Dumper.pm line 232.
not ok 8 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 75 $r=undef # TODO Shared array with circular loop
#   Failed (TODO) test 'Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 75 $r=undef'
#   at Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t line 22.
# my %h
ok 9 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 82 $r='%h = ();
# '
# $h{loop} = \%h
ok 10 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 86 $r='%h = (
#        'loop' => \%h
#      );
# '
# my %sh :shared
ok 11 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 93 $r='%sh = ();
# '
# $sh{loop} = \%sh
Recursion limit of 1000 exceeded at /usr/lib/x86_64-linux-gnu/perl/5.32/Data/Dumper.pm line 232.
not ok 12 - Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 100 $r=undef # TODO Shared hash with circular loop
#   Failed (TODO) test 'Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t 100 $r=undef'
#   at Data-Dumper-bugs-shared-arrays-hashes-with-circular-loops.t line 22.
1..12

2025-09-15 17:46:05 dpchrist at laalaa ~/sandbox/perl
$ 


I am unable to contact the module author via e-mail:

On 9/15/25 17:29, Mail Delivery Subsystem wrote:
> 
> ** Address not found **
> 
> Your message wasn't delivered to gsar at activestate.com because the address couldn't be found, or is unable to receive mail.
> 
> Learn more here: https://support.google.com/mail/?p=NoSuchUser
> 
> The response was:
> 
> The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. For more information, go to https://support.google.com/mail/?p=NoSuchUser


These bugs may affect newer Debian, Perl, and/or Data::Dumper releases.


Please feel free to modify and/or add the test script to your testing
infrastructure.


Please advise.


Thank you,

David



-- System Information:
Debian Release: 11.11
  APT prefers oldoldstable-updates
  APT policy: (500, 'oldoldstable-updates'), (500, 'oldoldstable-security'), (500, 'oldoldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-35-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages perl depends on:
ii  dpkg               1.20.13
ii  libperl5.32        5.32.1-4+deb11u4
ii  perl-base          5.32.1-4+deb11u4
ii  perl-modules-5.32  5.32.1-4+deb11u4

Versions of packages perl recommends:
ii  netbase  6.3

Versions of packages perl suggests:
pn  libtap-harness-archive-perl                             <none>
pn  libterm-readline-gnu-perl | libterm-readline-perl-perl  <none>
ii  make                                                    4.3-4.1
ii  perl-doc                                                5.32.1-4+deb11u4

-- no debconf information



More information about the Perl-maintainers mailing list