Bug 1151572

Summary: Runaway rapid memory growth when handling Net::DNS::Packet
Product: [Fedora] Fedora Reporter: John McEleney <john+redhat>
Component: perl-Net-DNSAssignee: Petr Šabata <psabata>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 20CC: perl-devel, psabata, pwouters
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: perl-Net-DNS-0.81-1.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-10 06:20:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John McEleney 2014-10-10 17:42:56 UTC
Description of problem:

When I query the NS records for a certain domain using Net::DNS::Resolver::Recurse, the perl script gets stuck in a infinite loop, rapidly expanding in size until it is killed by the OOM killer.

How reproducible:
Can be reproduced every time you query certain domain(s). I've reproduced it on four different Fedora 20 systems, once of which was a virgin system booted from the Fedora Live DVD.

The problem does _not_ occur on CentOS/RHEL 6.5 or CentOS/RHEL 7.


Steps to Reproduce:
1. Create a perl script that queries NS records for domain villamontanavista.co.uk
2. Run the script
3. Watch top and see the script grow in size until the OOM killer steps in.

Actual results:
Perl script devours all available memory until it is killed by OOM Killer

Expected results:
DNS records should be handled by the script and it should exit almost instantly

Additional info:
This perl script will always trigger the bug on Fedora 20:
=========================
#!/usr/bin/perl

use strict;
use Net::DNS;
use Net::DNS::Resolver::Recurse;
use Data::Dumper;

select STDERR; $| = 1;
select STDOUT; $| = 1;

my $res = Net::DNS::Resolver::Recurse->new;
$res->hints();
$res->recursion_callback(sub {
    my $packet = shift;
    print "==============\n".Dumper($packet)."\n--------------------\n";
    for  ($packet->additional){ print $_->string."\n"; }
});

$res->tcp_timeout(10);
$res->udp_timeout(10);

print "Starting recursion\n";
my $packet=$res->query_dorecursion("villamontanavista.co.uk","NS");
print "Finished recursion\n";
=========================

Some strace output (goes on like this until killed):
brk(0)                                  = 0x18a1000
brk(0x18c2000)                          = 0x18c2000
brk(0)                                  = 0x18c2000
brk(0x18e3000)                          = 0x18e3000
brk(0)                                  = 0x18e3000
brk(0x1904000)                          = 0x1904000
brk(0)                                  = 0x1904000
brk(0x1925000)                          = 0x1925000
brk(0)                                  = 0x1925000
brk(0x1946000)                          = 0x1946000
brk(0)                                  = 0x1946000
brk(0x1967000)                          = 0x1967000
brk(0)                                  = 0x1967000
brk(0x1988000)                          = 0x1988000
brk(0)                                  = 0x1988000

Comment 1 John McEleney 2014-10-11 10:36:08 UTC
I've done a bit more work on this and determined that:

* The problem exists in the upstream Net::DNS v0.80
* This can be reproduced on Ubuntu Trusty with Net::DNS built from CPAN

I've reported the bug here:
https://rt.cpan.org/Public/Bug/Display.html?id=99429

Comment 2 Petr Šabata 2014-10-13 13:10:48 UTC
Thanks for the report, John.

A workaround patch has been submitted on RT.

Comment 3 Paul Wouters 2014-10-29 15:27:15 UTC
confirmed fixed in 0.81

Comment 4 Fedora Update System 2014-10-29 15:47:34 UTC
perl-Net-DNS-0.81-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/perl-Net-DNS-0.81-1.fc19

Comment 5 Fedora Update System 2014-10-29 15:52:09 UTC
perl-Net-DNS-0.81-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/perl-Net-DNS-0.81-1.fc21

Comment 6 Fedora Update System 2014-10-31 01:27:48 UTC
Package perl-Net-DNS-0.81-1.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing perl-Net-DNS-0.81-1.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-13988/perl-Net-DNS-0.81-1.fc21
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2014-11-10 06:20:25 UTC
perl-Net-DNS-0.81-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2014-11-13 18:19:24 UTC
perl-Net-DNS-0.81-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.