-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The tied hash interface sometimes returns undef for keys that clearly exist (and can be queried without problems from the CDB file using different software).
For a minimal reporoducer consider this:
use constant FILENAME => 't.cdb';
my $t = CDB_File->new(FILENAME, "t.$$") or die $!;
$t->insert('R8Y', 1);
$t->insert('SYY', 1);
$t->finish;
tie(my %h, 'CDB_File', FILENAME) or die $!;
die unless defined $h{'SYY'};It runs successfully with CDB_File version 1.03, but unexpectedly dies in the last line since version 1.04. The file created appears to be okay, the problem must be in the reading part. Note that R8Y and SYY have the same djb2 hash.
Iteration over keys or entries hides the problem. For example, the following works when you remove the sort in the last line, but quite reliably dies otherwise:
my %t = map {$_ => 1} qw/Q5M QCX QK3 TPM QN5/;
CDB_File::create %t, FILENAME, "t.$$" or die $!;
undef %t;
tie(%t, 'CDB_File', FILENAME) or die $!;
for (sort keys %t) { die unless defined $t{$_} }Metadata
Metadata
Assignees
Labels
No labels