diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl index b2f3798c43cc..47d7425be2fc 100644 --- a/lib/dumpvar.pl +++ b/lib/dumpvar.pl @@ -477,26 +477,32 @@ sub main::dumpvar { $package .= "::" unless $package =~ /::$/; *stab = *{"main::"}; while ($package =~ /(\w+?::)/g){ - *stab = $ {stab}{$1}; + *stab = $ {stab}{$1}; } local $TotalStrings = 0; local $Strings = 0; local $CompleteTotal = 0; - while (($key,$val) = each(%stab)) { - return if $DB::signal; - next if @vars && !grep( matchvar($key, $_), @vars ); - if ($usageOnly) { - globUsage(\$val, $key) - if ($package ne 'dumpvar' or $key ne 'stab') - and ref(\$val) eq 'GLOB'; - } else { - dumpglob(0,$key, $val, 0, $m); - } + for my $key (keys %stab) { + my $val = $stab{$key}; + return if $DB::signal; + next if @vars && !grep( matchvar($key, $_), @vars ); + if ($usageOnly) { + if ( + ($package ne 'dumpvar' or $key ne 'stab') + and + (ref(\$val) eq 'GLOB') + ) { + globUsage(\$val, $key) + } + } + else { + dumpglob(0,$key, $val, 0, $m); + } } if ($usageOnly) { - print "String space: $TotalStrings bytes in $Strings strings.\n"; - $CompleteTotal += $TotalStrings; - print "Grand total = $CompleteTotal bytes (1 level deep) + overhead.\n"; + print "String space: $TotalStrings bytes in $Strings strings.\n"; + $CompleteTotal += $TotalStrings; + print "Grand total = $CompleteTotal bytes (1 level deep) + overhead.\n"; } } diff --git a/lib/perl5db.t b/lib/perl5db.t index ab35f993e0dc..f91b1d1e4b30 100644 --- a/lib/perl5db.t +++ b/lib/perl5db.t @@ -3662,6 +3662,46 @@ EOS $wrapper->contents_like(qr/print "2\\n"/, "break immediately after defining problem"); } +{ + # gh #23663 (variant 1) + my $wrapper = DebugWrap->new( + { + cmds => + [ + 'b 4', + 'X', + 'c', + 'q', + ], + prog => \1, + } + ); + + $wrapper->contents_unlike( + qr/Use of each\(\) on hash after insertion without resetting hash iterator results in undefined behavior/, + q/gh-23663: 'X' command does not warn about undefined behavior/, + ); + + # gh #23663 (variant 2) + $wrapper = DebugWrap->new( + { + cmds => + [ + 'b 4', + 'V main', + 'c', + 'q', + ], + prog => \1, + } + ); + + $wrapper->contents_unlike( + qr/Use of each\(\) on hash after insertion without resetting hash iterator results in undefined behavior/, + q/gh-23663: 'V main' command does not warn about undefined behavior/, + ); +} + done_testing(); END {