Dear Maintainer,
debtree fails with this error for a number of packages:
Can't use string ("") as a HASH ref while "strict refs" in use at /usr/bin/debtree line 329.
Example test case:
debtree gcc-12-multilib:amd64
The root cause appears to lie within an unhandled third condition in
sub get_apt_pinfo {}
If the $pdata exists, but does neither meet the if ($show_installed ...), nor the elsif (exists $$pdata ...), then the sub is returning
something that is interpreted as an "". The behaviour changes when a final/closing empty else {} branch is added.
Note: This effect was also seen on KUbuntu 24.04 for
debtree gcc-13-x86-64-linux-gnu:amd64
Note: This bug may be related to
bug report #954795
Adding the empty else {} changes the error to
Use of uninitialized value in string eq at /usr/bin/debtree line 329.
The root cause for this appears to be within the
check_version {}
which doesn't check, if $$pinfo{VerStr} actually exists before trying to eq it with $version.
Adding a check like this
sub check_version {
my ($package, $version) = @_;
my $pinfo = get_apt_pinfo($package, "");
if (exists ${$pinfo}{VerStr}) {
return ($$pinfo{VerStr} eq $version);
} else {
return 0;
}
}
seems to remove the error.
Note: This "uninitialized value" error can be reproduced directly on KUbuntu 24.04 by issuing
debtree g++-13-x86-64-linux-gnu:amd64
The HASH error stops debtree from creating a viable .gv file, as it seems to stop in the middle of the process.
The corruption prevents any rendering.
This may be related to
bug report #1003856
I am not a Perl developer, but tried to make a best effort to try to narrow down the root cause.
I hope this helps finding and fixing the issue.
Best regards,
Renzo de Paoli
Concordia Domi Foris Pax