Package: debtree
Version: 1.1.2
Severity: important
X-Debbugs-Cc: depaoli.re...@gmail.com

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



-- System Information:
Debian Release: 12.9
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.1.0-31-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_IE:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages debtree depends on:
ii  dctrl-tools      2.24-3+b1
ii  libapt-pkg-perl  0.1.40+b2
ii  perl             5.36.0-7+deb12u1
ii  ucf              3.0043+nmu1+deb12u1

Versions of packages debtree recommends:
ii  graphviz  2.42.2-7+deb12u1

debtree suggests no packages.

-- no debconf information

Reply via email to