Skip Menu |

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

Report information
The Basics
Id: 16447
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: rpinuaga [...] s21sec.com
Cc:
AdminCc:

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



Subject: Net::DNS Crash in Cygwin with more than 200 threads
Hi: I'm developing a class C scanner that looks for active DNS servers. It uses threads to speed up the process. (code attached) When I create more than 200 threads, Perl dies with a segmentation fault in Cygwin (In linux works fine). I’ve done similar things with perl, but without Net::DNS and never get in this situation. It's a cygwin problem? It's a perl problem? It's a Net::DNS problem? Thanks in advance
#!/usr/bin/perl # # DNSFINDER.pl v0.2 - DNS Server Scanner (multithread) # # by The Dark Raver <darkraver@open-labs.org> (10/12/2005) # # # Scans a range of IP address looking for open DNS servers. # # Example: # # ./dnsfinder.pl 192.168.0.1-254 -v # use strict; use warnings; use threads; use Net::DNS; # Not thread safe in Cygwin with +200 threads :( my $verbose=0; my $found=0; if(!$ARGV[0]) { print "Usage: ./dnsfinder.pl xx.xx.xx.xx[-xx] [-v]\n"; exit; } my @target=split(/-/, $ARGV[0]); my $start=$target[0]; my @ip=split(/\./, $start); my $end=$ip[3]; if($target[1]) { $end=$target[1]; } else { $verbose=1; } if($end > 255) { $end=255; } if(defined $ARGV[1] and $ARGV[1] eq "-v") { $verbose=1; } print "\n-- DNSFINDER by The Dark Raver --\n\n"; #print "IP_START: $ip[0].$ip[1].$ip[2].$ip[3]\n\n"; print " IP Address Host Name Bind Version Recursive Cache ------------------------------------------------------------------------------- "; my @iplist; for(my $i=$ip[3];$i<=$end;$i++) { push(@iplist, $ip[0].".".$ip[1].".".$ip[2].".".$i); } my $child; my @child_list; foreach my $iplist (@iplist) { $child = threads->new(\&scan_host, $iplist, $verbose); push(@child_list, $child); sleep(1); } #print "P\n"; select(STDOUT); foreach $child (@child_list) { my $returned_data = $child->join; #print "Child thread returned: $returned_data\n"; if($returned_data==1) { $found++; } } print "\n-- Found $found Active DNS Servers --\n\n"; exit; sub scan_host { my ($ipname, $my_verbose) = @_; my $ok=0; my $recursive=0; my $caching=0; my $name=""; my $version=""; my $random="www.random.org"; #print "C\n"; select(STDOUT); format STDOUT = @<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<< @> @>>>> $ipname, $name, $version, $recursive, $caching . my $res = Net::DNS::Resolver->new(); $res->nameservers($ipname); #__QUERY1__ my $query = $res->search($ipname); if($query) { $ok=1; foreach my $rr ($query->answer) { if($rr->type eq "PTR") { $name=$rr->ptrdname; #print "PTR: ".$rr->ptrdname."\n"; } } } else { if($my_verbose) { print "QUERY1 ($ipname): ".$res->errorstring."\n"; select(STDOUT); $| = 1; } if($res->errorstring eq "NOERROR") { $ok=1; $name="(none)"} } if($ok) { #__VERSION.BIND__ $query = $res->search("version.bind", "TXT", "CH"); if($query) { foreach my $rr ($query->answer) { if($rr->type eq "TXT") { $version=$rr->txtdata; #print "TXT: ".$rr->txtdata."\n"; } } } else { if($my_verbose) { print "QUERY2 ($ipname): ".$res->errorstring."\n"; select(STDOUT); $| = 1; } if($res->errorstring eq "NOTIMP") { $version="(not_implemented)";} if($res->errorstring eq "SERVFAIL") { $version="(server_failed)";} } #__IS.RECURSIVE__ $query = $res->search($random); if($query) { $recursive=1; } else { if($my_verbose) { print "QUERY3 ($ipname): ".$res->errorstring."\n"; select(STDOUT); $| = 1; } } #__IS.CACHING__ $res->recurse(0); $query = $res->search($random); if($query) { $caching=1; } else { if($my_verbose) { print "QUERY4 ($ipname): ".$res->errorstring."\n"; select(STDOUT); $| = 1; } } write; select(STDOUT); $| = 1; return 1; } return 0; }
From: "Olaf M. Kolkman" <olaf [...] dacht.net>
Subject: Re: [cpan #16447] Net::DNS Crash in Cygwin with more than 200 threads
Date: Tue, 13 Dec 2005 09:11:01 +0100
To: bug-Net-DNS [...] rt.cpan.org
RT-Send-Cc:
This seems like an error somebody else noticed too. Could you please try replacing Base.pm with the version on http://www.net-dns.org/svn/net-dns/trunk/lib/Net/DNS/Resolver/Base.pm Let me know if this fixes the problem, if so I release a new version ASAP. --Olaf On Dec 12, 2005, at 19:50 , Guest via RT wrote: Show quoted text
> > This message about Net-DNS was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=16447 > > > Hi: > > I'm developing a class C scanner that looks for active DNS servers. > It uses threads to speed up the process. (code attached) > > When I create more than 200 threads, Perl dies with a segmentation > fault in Cygwin (In linux works fine). > > I’ve done similar things with perl, but without Net::DNS and never > get in this situation. > > It's a cygwin problem? It's a perl problem? It's a Net::DNS problem? > > Thanks in advance
------------------------------------------------------ Ik dacht net... heel even maar.
Download PGP.sig
application/pgp-signature 227b

Message body not shown because it is not plain text.

From: rpinuaga [...] s21sec.com
Still crashing :( Some details: CYGWIN_NT-5.1 1.5.18(0.132/4/2) on Windows XP SP2 Spanish all patches perl v5.8.7 built for cygwin-thread-multi-64int Net::DNS 0.5.4 Stack dump: Exception: STATUS_ACCESS_VIOLATION at eip=610C4914 eax=00000000 ebx=00040000 ecx=00010000 edx=00000000 esi=611CA258 edi=00000000 ebp=0022E738 esp=0022E72C program=C:\cygwin\bin\perl.exe, pid 3096, thread main cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023 0x610C4914 is memcpy() cygwin1!memcpy+0x34: 610c4914 f3a5 rep movsd ds:611c9a38=000000c8 es:00000000=????????
From: "Olaf M. Kolkman" <olaf [...] dacht.net>
Subject: Re: [cpan #16447] Net::DNS Crash in Cygwin with more than 200 threads
Date: Tue, 13 Dec 2005 10:00:05 +0100
To: bug-Net-DNS [...] rt.cpan.org
RT-Send-Cc:
Show quoted text
> Still crashing :(
Bummer... Show quoted text
> I'm developing a class C scanner that looks for active DNS servers. > It uses threads to speed up the process. (code attached) > > When I create more than 200 threads, Perl dies with a segmentation > fault in Cygwin (In linux works fine). >
I was thinking that what might have happened is that you ran out of TCP state. That is a known bug in 0.54 and the code supplied had that fixed. So we are back to the original question: Show quoted text
> > It's a cygwin problem? It's a perl problem? It's a Net::DNS problem?
I hate to say it but I do not have sufficient clue to troubleshoot this. The core dump seems to bang out from the main thread on a low level memcpy that could basically happen anywhere in the code. --Olaf ------------------------------------------------------ Ik dacht net... heel even maar.
Download PGP.sig
application/pgp-signature 227b

Message body not shown because it is not plain text.

From: lithron [...] gmail.com
See http://perlmonks.org/?node_id=532956 This is a Windows perl compile issue. Threading in general is the problem, not Net::DNS. On Tue Dec 13 04:01:23 2005, olaf@dacht.net wrote: Show quoted text
> >
> > Still crashing :(
> > Bummer... > >
> > I'm developing a class C scanner that looks for active DNS
servers. Show quoted text
> > It uses threads to speed up the process. (code attached) > > > > When I create more than 200 threads, Perl dies with a
segmentation Show quoted text
> > fault in Cygwin (In linux works fine). > >
> > I was thinking that what might have happened is that you ran out of > TCP state. That is a known bug in 0.54 and the code supplied had
that Show quoted text
> fixed. > > So we are back to the original question: >
> > > > It's a cygwin problem? It's a perl problem? It's a Net::DNS
problem? Show quoted text
> > I hate to say it but I do not have sufficient clue to troubleshoot > this. The core dump seems to bang out from the main thread on a low > level memcpy that could basically happen anywhere in the code. > > > --Olaf > > ------------------------------------------------------ > Ik dacht net... heel even maar. > > >
Subject: Re: [rt.cpan.org #16447] Net::DNS Crash in Cygwin with more than 200 threads
Date: Sat, 04 Mar 2006 16:00:42 +0100
To: bug-Net-DNS [...] rt.cpan.org
From: "Olaf M. Kolkman" <olaf [...] dacht.net>
Guest via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=16447 > > > See http://perlmonks.org/?node_id=532956 > > This is a Windows perl compile issue. Threading in general is the > problem, not Net::DNS. > >
Thanks... its good to know this. I will close the ticket. --Olaf Show quoted text
> >
Download signature.asc
application/pgp-signature 252b

Message body not shown because it is not plain text.