Skip Menu |

This queue is for tickets about the DBD-Firebird CPAN distribution.

Report information
The Basics
Id: 119764
Status: open
Priority: 0/
Queue: DBD-Firebird

People
Owner: Nobody in particular
Requestors: kuzvesov [...] list.ru
Cc:
AdminCc:

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



Subject: Segmentation fault if alarm signalled during connect
I use alarm to set connection timeout (10.0.0.1 host does not exist in my network): [code] use DBI; use DBD::Firebird; my $dbh; print "start connect\n"; eval { local $SIG{ALRM} = sub { die "connect timeout"; }; alarm(5); $dbh = DBI->connect("dbi:Firebird:database=nonexistent;host=10.0.0.1;", "sysdba", "masterkey") or die "connect failed: " . $DBI::errstr; alarm(0); }; if ($@) { die "connect failed: timeout" if ($@ eq "connect timeout"); die "connect failed: " . $DBI::errstr if defined $DBI::errstr; die "connect failed: " . $@; } print "connected\n"; [/code] Running this code ends up with segmentation fault =( And I don't know why =((( N.B If database connection is replaced with 'sleep 10', then code works properly. N.B.B DBD-InterBase produces the same segmentation fault in the same conditions =( Configuration: DBD-Firebird-1.24 perl v5.24.1 FreeBSD 10.3-RELEASE-p12
Subject: Re: [rt.cpan.org #119764] Segmentation fault if alarm signalled during connect
Date: Wed, 11 Jan 2017 19:48:54 +0000
To: Konstantin Kuzvesov via RT <bug-DBD-Firebird [...] rt.cpan.org>
From: Damyan Ivanov <dam [...] cpan.org>
-=| Konstantin Kuzvesov via RT, 08.01.2017 10:05:55 -0500 |=- Show quoted text
> Sun Jan 08 10:05:55 2017: Request 119764 was acted upon. > Broken in: 1.24 > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=119764 > > > I use alarm to set connection timeout (10.0.0.1 host does not exist in my network): > > [code] >... > [/code] > > Running this code ends up with segmentation fault =( And I don't know why =((( > N.B If database connection is replaced with 'sleep 10', then code works properly. > N.B.B DBD-InterBase produces the same segmentation fault in the same conditions =( > > Configuration: > DBD-Firebird-1.24 > perl v5.24.1 > FreeBSD 10.3-RELEASE-p12
This seems to work more or less as expected for me on linux (Debian/sid) on amd64 using libfbclient2 from firebird 3.0.1. What is a bit strange is that I get an error that seems to be coming from the firebird client: $ time perl test.pl start connect DBI connect('database=nonexistent;host=192.168.0.16;','sysdba',...) failed: Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements -Unable to complete network request to host "192.168.0.16". -Failed to establish a connection. at test.pl line 11. connect failed: Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements -Unable to complete network request to host "192.168.0.16". -Failed to establish a connection. at test.pl line 18. perl test.pl 0,04s user 0,01s system 1% cpu 3,113 total This may be caused by some linux-related thing, causing the network connection to fail quick. Interestingly, if I change "alarm(5)" to "alarm(2)", the result is similar, but comes after just 2 seconds: $ time perl test.pl start connect connect failed: Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements -Unable to complete network request to host "192.168.0.16". -Failed to establish a connection. at test.pl line 18. perl test.pl 0,04s user 0,01s system 2% cpu 2,051 total Still, no segfaults. What's your firebird client version?
From: kuzvesov [...] list.ru
Show quoted text
> What's your firebird client version?
firebird25-client-2.5.6_1
From: kuzvesov [...] list.ru
I ran trace (perl -d:Trace) and here's what it shows: .... /usr/local/lib/perl5/site_perl/mach/5.24/DBD/Firebird.pm:160: DBD::Firebird::db::_login($dbh, $dsn, $dbuser, $dbpasswd, $attr) Segmentation fault So it looks like firebird client uses alarm handler internally. Am I right?
На 30 апр. 2017, нд 19:47:41, bmth написа: Show quoted text
> I ran trace (perl -d:Trace) and here's what it shows: > > .... > /usr/local/lib/perl5/site_perl/mach/5.24/DBD/Firebird.pm:160: > DBD::Firebird::db::_login($dbh, $dsn, $dbuser, $dbpasswd, $attr) > Segmentation fault > > So it looks like firebird client uses alarm handler internally. Am I > right?
Seems so to me too. Perhaps the correct way to address this is to provide a 'timeout' parameter to the ->connect() method. The firebird client library supports that, but DBD::Firebird doesn't provide the interface (yet)