Subject: | Apache::TestSSLCA inserts into a hash while iterating over it |
Hi,
I was just trying to install Apache2::Request under Perl 5.20.1, but it was failing with an error
[ error] configure() has failed:
Use of each() on hash after insertion without resetting hash iterator results in undefined behavior at /usr/local/lib/perl5/site_perl/5.20.1/x86_64-linux/Apache/TestSSLCA.pm line 104.
Compilation failed in require at /usr/local/lib/perl5/site_perl/5.20.1/x86_64-linux/Apache/TestConfig.pm line 1474.
This is due to the following:
#generate DSA versions of the server certs/keys
while (my($key, $val) = each %$cert_dn) {
next unless $key =~ /^server/;
my $name = join '_', $key, 'dsa';
$cert_dn->{$name} = { %$val }; #copy
$cert_dn->{$name}->{OU} =~ s/rsa/dsa/;
}
This is down to the following line in "perldoc -f each"
If you add or delete a hash's elements while iterating over it, the effect on the iterator is unspecified
I changed it to the following:
my %dsa_entries;
while (my($key, $val) = each %$cert_dn) {
next unless $key =~ /^server/;
my $name = join '_', $key, 'dsa';
$dsa_entries{$name} = { %$val }; #copy
$dsa_entries{$name}->{OU} =~ s/rsa/dsa/;
}
$cert_dn->{$_} = $dsa_entries{$_} for keys %dsa_entries;
Which then let me install Apache2::Request.
Cheers,
Neil