Skip Menu |

This queue is for tickets about the Net-DBus CPAN distribution.

Report information
The Basics
Id: 108409
Status: resolved
Priority: 0/
Queue: Net-DBus

People
Owner: Nobody in particular
Requestors: DJCOLLINS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Autovivification causes memory leak in Net::DBus::Reactor
Net::DBus::Reactor will autovivify undefined elements in the timeouts array to empty hashes which won't be reused, leaking memory. Have only experienced this when calling a (remote) D-Bus method from inside another D-Bus method, but suspect this can be caused other ways too.
Subject: net-dbus-timeout-autovivify.patch
Author: Daniel Collins <daniel.collins@smoothwall.net> Description: Don't leak memory by autovivifying undefined elements in the reactor timeouts array to empty hashes. Seems to only happen when a D-Bus method calls a D-Bus method in another service for some reason. Also prevent the same from occuring if toggle_timeout() is called with an invalid key. --- a/lib/Net/DBus/Reactor.pm +++ b/lib/Net/DBus/Reactor.pm @@ -417,7 +417,7 @@ my $timeout; foreach (@{$self->{timeouts}}) { - next unless $_->{enabled}; + next unless defined && $_->{enabled}; my $expired = $now - $_->{last_fired}; my $interval = ($expired > $_->{interval} ? 0 : $_->{interval} - $expired); @@ -453,7 +453,7 @@ my @callbacks; foreach my $timeout (@{$self->{timeouts}}) { - next unless $timeout->{enabled}; + next unless defined($timeout) && $timeout->{enabled}; my $expired = $now - $timeout->{last_fired}; # Select typically returns a little (0-10 ms) before we @@ -609,6 +609,9 @@ my $key = shift; my $enabled = shift; + die "no timeout active with key '$key'" + unless defined $self->{timeouts}->[$key]; + $self->{timeouts}->[$key]->{enabled} = $enabled; $self->{timeouts}->[$key]->{interval} = shift if @_; }
Thanks, I have pushed your proposed patch as commit fbe6558b038bceceb668964694e21603705a1eeb Author: Daniel Collins <daniel.collins@smoothwall.net> Date: Mon Dec 16 21:22:21 2019 +0000 Avoid autovivifying timeout array entries