Package: munin-common
Version: 2.0.76-5
Severity: normal
Tags: patch
While investigating intermittent "Odd number of elements in hash assignment"
noise from the diskstat_ plugin in munin-node.log, I noticed behaviour
hopefully demonstrated by this short example:
use Munin::Plugin;
$Munin::Plugin::statefile='./state';
my %test_state=(
'foo'=>'',
'bar'=>42,
'baz'=>''
);
save_state(time(), %test_state);
my ($prev_time, %new_state) = restore_state();
print(map {"before save: $_: ".(defined
$test_state{$_}?$test_state{$_}:"undef")."\n"} sort keys %test_state);
print(map {"after restore: $_: ".(defined $new_state{$_}?
$new_state{$_}:"undef")."\n"} sort keys %new_state);
Two thirds of the time, the generated state file will have an empty last
line. This breaks because by default, split() strips out trailing empty
fields (see manpage), resulting in an uneven-length list.
I offer the attached trivial patch against Munin::Plugin as a solution.
HTH,
-MD
-- System Information:
Debian Release: 13.3
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500,
'stable-security-debug'), (500, 'stable-security'), (500, 'stable-debug'),
(500, 'proposed-updates-debug'), (500, 'proposed-updates'), (500,
'oldstable-updates'), (500, 'oldstable-security'), (500,
'oldoldstable-updates'), (500, 'oldoldstable-security'), (500, 'oldoldstable'),
(500, 'stable'), (490, 'testing-debug'), (490, 'oldstable-debug'), (490,
'testing'), (490, 'oldstable'), (400, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.12.63+deb13-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8),
LANGUAGE=en_AU:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages munin-common depends on:
ii adduser 3.152
ii liblist-moreutils-perl 0.430-2
ii perl 5.40.1-6
munin-common recommends no packages.
munin-common suggests no packages.
-- no debconf information
--- /usr/share/perl5/Munin/Plugin.pm.orig 2025-04-12 22:27:16.000000000 +0800
+++ /usr/share/perl5/Munin/Plugin.pm 2026-02-05 10:37:18.753021910 +0800
@@ -281,7 +281,7 @@
# Munin-state 1.0 encodes %, \n and \r in URL encoding and leaves
# the rest.
print $STATE "%MUNIN-STATE1.0\n";
- print $STATE join("\n",_encode_state(@_)),"\n";
+ print $STATE join("\n",_encode_state(@_));
close $STATE;
@@ -322,7 +322,7 @@
# Slurp the rest
local $/;
- my @state = split(/\n/, <$STATE>);
+ my @state = split(/\n/, <$STATE>, -1);
return _decode_state(@state);
}