Skip Menu |

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

Report information
The Basics
Id: 96007
Status: resolved
Priority: 0/
Queue: Net-LDAP-Express

People
Owner: bronto [...] cpan.org
Requestors: des [...] des.no
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.11
Fixed in: 0.12



Subject: Attempt to dereference an undefined reference
Lines 44-47 in Net/LDAP/Express.pm: # try connection my $ldap = $class->SUPER::new($host,%args) ; eval { $ldap->isa('Net::LDAP') } ; croak "Cannot connect to $host: $@" if $@ ; If Net::LDAP->new() fails, $ldap is undefined. This results in a cryptic error message: Cannot connect to dc01.example.com: Can't call method "isa" on an undefined value at /usr/local/lib/perl5/site_perl/5.16/Net/LDAP/Express.pm line 46, <DATA> line 751. It would be better to check that $ldap is defined before trying $ldap->isa inside the eval. It might also be a good idea to call SUPER::new within the eval, in case it throws an exception.
Hi Dag-Erling I see your point and yes, it makes sense to check $ldap before attempting a method call. I'm a bit swamped at the moment but I'll work on it ASAP. I should be able to push out a new version by next week. Thanks for reporting the bug! Kind Regards -- Marco Il Mar 27 Maggio 2014 10:57:01, des@des.no ha scritto: Show quoted text
> Lines 44-47 in Net/LDAP/Express.pm: > > # try connection > my $ldap = $class->SUPER::new($host,%args) ; > eval { $ldap->isa('Net::LDAP') } ; > croak "Cannot connect to $host: $@" if $@ ; > > If Net::LDAP->new() fails, $ldap is undefined. This results in a > cryptic error message: > > Cannot connect to dc01.example.com: Can't call method "isa" on an > undefined value at > /usr/local/lib/perl5/site_perl/5.16/Net/LDAP/Express.pm line 46, > <DATA> line 751. > > It would be better to check that $ldap is defined before trying $ldap-
> >isa inside the eval.
> > It might also be a good idea to call SUPER::new within the eval, in > case it throws an exception.
Hi Apologies that this is still unresolved. I have not forgotten this ticket, it's just a period of pre-vacation high-load at work, and I really couldn't find a spot to work 100% on this. I am working to convert my old on-disk CVS repository into a GIT repository, and having issues with commits that were not imported -- it stops at version 0.10. As soon as the CVS repo is fixed and online on github, I'll proceed with the patch. Sorry for any inconvenience Ciao -- bronto
Made it, finally. The code is now on Github: https://github.com/brontolinux/net-ldap-express I finally have everything in place to fix the bug, and can forget about theold CVS repository.
Hi! Show quoted text
> # try connection > my $ldap = $class->SUPER::new($host,%args) ; > eval { $ldap->isa('Net::LDAP') } ; > croak "Cannot connect to $host: $@" if $@ ;
According to the documentation of Net::LDAP, it's actually enough to remove the eval to establish the correct behavior. I have just pushed an updated version of Express in github, it's in the branch bug-96007. Would you mind testing it and tell me if it fixes the problem? Unfortunately I don't have an LDAP server at hand any more, and I'd like the fix to be tested in the same environment where the bug showed up. If it works for you, I'll update the documentation, merge the changes in master and release a new version straight away. Ciao -- bronto
Subject: Re: [rt.cpan.org #96007] Attempt to dereference an undefined reference
Date: Thu, 26 Jun 2014 22:57:07 +0200
To: bug-Net-LDAP-Express [...] rt.cpan.org
From: Dag-Erling Smørgrav <des [...] des.no>
"Marco Marongiu via RT" <bug-Net-LDAP-Express@rt.cpan.org> writes: Show quoted text
> According to the documentation of Net::LDAP, it's actually enough to > remove the eval to establish the correct behavior. I have just pushed > an updated version of Express in github, it's in the branch > bug-96007. Would you mind testing it and tell me if it fixes the > problem? Unfortunately I don't have an LDAP server at hand any more, > and I'd like the fix to be tested in the same environment where the > bug showed up.
Can you give me the github URL? It's very easy to reproduce, though - if I recall correctly, it triggers any time Net::LDAP fails to establish a connection, so you don't even need a server to test it. DES -- Dag-Erling Smørgrav - des@des.no
Subject: Re: [rt.cpan.org #96007] Attempt to dereference an undefined reference
Date: Thu, 26 Jun 2014 23:07:14 +0200
To: bug-Net-LDAP-Express [...] rt.cpan.org
From: Marco Marongiu <mmarongiu [...] tiscali.it>
On 06/26/2014 10:57 PM, Dag-Erling Smørgrav via RT wrote: Show quoted text
> Queue: Net-LDAP-Express > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=96007 > > > Can you give me the github URL?
Right, there https://github.com/brontolinux/net-ldap-express Show quoted text
> It's very easy to reproduce, though - if I recall correctly, it triggers > any time Net::LDAP fails to establish a connection, so you don't even > need a server to test it.
I see. Please check it if you can, otherwise I'll try tomorrow. Thanks in any case, ciao -- bronto
Subject: Re: [rt.cpan.org #96007] Attempt to dereference an undefined reference
Date: Thu, 26 Jun 2014 23:28:38 +0200
To: bug-Net-LDAP-Express [...] rt.cpan.org
From: Dag-Erling Smørgrav <des [...] des.no>
No LDAP server is needed to reproduce the bug: % git clone https://github.com/brontolinux/net-ldap-express Initialized empty Git repository in /home/des/src/net-ldap-express/.git/ remote: Counting objects: 46, done. remote: Compressing objects: 100% (26/26), done. remote: Total 46 (delta 22), reused 44 (delta 20) Unpacking objects: 100% (46/46), done. % cd net-ldap-express % perl -MExpress -e 'Net::LDAP::Express->new(host => "foo", base => "foo", searchattrs => [])' Cannot connect to foo: Can't call method "isa" on an undefined value at Express.pm line 46, <DATA> line 522. at -e line 1 Let's switch to the bugfix branch and try a couple of different failure modes: % git checkout --track origin/bug-96007 Branch bug-96007 set up to track remote branch bug-96007 from origin. Switched to a new branch 'bug-96007' % perl -MExpress -e 'Net::LDAP::Express->new(host => "foo", base => "foo", searchattrs => [])' Cannot connect to foo: IO::Socket::INET: Bad hostname 'foo' at -e line 1 % perl -MExpress -e 'Net::LDAP::Express->new(host => "localhost", base => "foo", searchattrs => [])' Cannot connect to localhost: IO::Socket::INET: connect: Connection refused at -e line 1 This is far more sensible. DES -- Dag-Erling Smørgrav - des@des.no
Subject: Re: [rt.cpan.org #96007] Attempt to dereference an undefined reference
Date: Fri, 27 Jun 2014 10:25:44 +0200
To: bug-Net-LDAP-Express [...] rt.cpan.org
From: Marco Marongiu <mmarongiu [...] tiscali.it>
On 06/26/2014 11:29 PM, Dag-Erling Smørgrav via RT wrote: Show quoted text
> % git checkout --track origin/bug-96007 > Branch bug-96007 set up to track remote branch bug-96007 from origin. > Switched to a new branch 'bug-96007' > % perl -MExpress -e 'Net::LDAP::Express->new(host => "foo", base => "foo", searchattrs => [])' > Cannot connect to foo: IO::Socket::INET: Bad hostname 'foo' at -e line 1 > % perl -MExpress -e 'Net::LDAP::Express->new(host => "localhost", base => "foo", searchattrs => [])' > Cannot connect to localhost: IO::Socket::INET: connect: Connection refused at -e line 1 > > This is far more sensible.
Good, I'll update the rest soonest and release a new version. Thanks for your help! -- M
I've just sent the file through PAUSE and it should hit CPAN soon. In the meanwhile, you can clone the new version from github.
Subject: Re: [rt.cpan.org #96007] Attempt to dereference an undefined reference
Date: Mon, 30 Jun 2014 14:44:51 +0200
To: bug-Net-LDAP-Express [...] rt.cpan.org
From: Dag-Erling Smørgrav <des [...] des.no>
I can confirm that the bug is fixed in 0.12. DES -- Dag-Erling Smørgrav - des@des.no
Il Lun 30 Giu 2014 08:45:01, des@des.no ha scritto: Show quoted text
> I can confirm that the bug is fixed in 0.12.
Wonderful! thanks for submitting the bug. I'll now close the ticket.