Skip Menu |

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

Report information
The Basics
Id: 37027
Status: resolved
Priority: 0/
Queue: DBD-mysql

People
Owner: CAPTTOFU [...] cpan.org
Requestors: daniel.frett [...] ccci.org
Cc:
AdminCc:

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



Subject: mysql_auto_reconnect causing seg faults
whenever a dbh has mysql_auto_reconnect set on it, it will cause a seg fault when trying to reconnect a killed connection. this bug appears to have shown up with v4.007 and appears to be related to the TAKE_IMP_DATA_VERSION block of code. Disabling the block by removing the define TAKE_IMP_DATA_VERSION makes the seg fault go away attached is a script that is regularly reproducing the error on my perl installation. I have perl 5.8.5, DBI v1.605, and DBD::mysql v4.007 installed.
Subject: dbdMySQLCrash.pl
use DBI; my $user = 'test'; my $pass = 'test'; my $dsn = 'DBI:mysql:database=test'; #need 2 database handles, first with auto-reconnect, second to kill the first connection and force auto-reconnect my $dbh = DBI->connect($dsn, $user, $pass, { 'mysql_auto_reconnect' => 1, }); my $dbh2 = DBI->connect($dsn, $user, $pass); #kill first db connection to trigger an auto reconnect $dbh2->do('kill ' . $dbh->{'mysql_thread_id'}); #insert a temporary delay, try uncommenting this if it's not seg-faulting at first, # one of my initial tests without this delay didn't seg fault #sleep 1; #ping first dbh handle to trigger auto-reconnect $dbh->ping;
On Mon Jun 23 13:54:40 2008, dfrett wrote: Show quoted text
> I have perl 5.8.5, DBI v1.605, and DBD::mysql v4.007 installed.
Confirmed also with perl 5.8.8, DBI 1.51. Also this is described here : http://bugs.mysql.com/bug.php?id=36810 Brian
Thank you very much for the bug report -- I'll fix this in 4.008.
Thank you! I'm in the process of fixing this and getting a release (4.008). On Mon Jun 23 13:54:40 2008, dfrett wrote: Show quoted text
> whenever a dbh has mysql_auto_reconnect set on it, it will cause a seg > fault when trying to reconnect a killed connection. > > this bug appears to have shown up with v4.007 and appears to be related > to the TAKE_IMP_DATA_VERSION block of code. Disabling the block by > removing the define TAKE_IMP_DATA_VERSION makes the seg fault go away > > > attached is a script that is regularly reproducing the error on my perl > installation. > > I have perl 5.8.5, DBI v1.605, and DBD::mysql v4.007 installed.
Thank you! I'm in the process of fixing this and getting a release (4.008). On Mon Jun 23 13:54:40 2008, dfrett wrote: Show quoted text
> whenever a dbh has mysql_auto_reconnect set on it, it will cause a seg > fault when trying to reconnect a killed connection. > > this bug appears to have shown up with v4.007 and appears to be related > to the TAKE_IMP_DATA_VERSION block of code. Disabling the block by > removing the define TAKE_IMP_DATA_VERSION makes the seg fault go away > > > attached is a script that is regularly reproducing the error on my perl > installation. > > I have perl 5.8.5, DBI v1.605, and DBD::mysql v4.007 installed.
I've tried on both 32-bit Suse Linux 10.2, MySQL 5.1, and AMD64 Ubuntu, MySQL 5.0.45, both with DBI 1.607, no segfault. I did try it with 1.605 on the AMD64 box at first and it didn't segfault, but I had errors on the test. I probably need to only enable it if it's DBI 1.607 and greater. On Mon Jun 23 13:54:40 2008, dfrett wrote: Show quoted text
> whenever a dbh has mysql_auto_reconnect set on it, it will cause a seg > fault when trying to reconnect a killed connection. > > this bug appears to have shown up with v4.007 and appears to be related > to the TAKE_IMP_DATA_VERSION block of code. Disabling the block by > removing the define TAKE_IMP_DATA_VERSION makes the seg fault go away > > > attached is a script that is regularly reproducing the error on my perl > installation. > > I have perl 5.8.5, DBI v1.605, and DBD::mysql v4.007 installed.
From: daniel.frett [...] ccci.org
I'll double check tomorrow using the latest version of DBI to see if I still am experiencing the bug. On Thu Aug 14 23:18:34 2008, CAPTTOFU wrote: Show quoted text
> I've tried on both 32-bit Suse Linux 10.2, MySQL 5.1, and AMD64 Ubuntu, > MySQL 5.0.45, both with DBI 1.607, no segfault. > > I did try it with 1.605 on the AMD64 box at first and it didn't > segfault, but I had errors on the test. > > I probably need to only enable it if it's DBI 1.607 and greater. > > On Mon Jun 23 13:54:40 2008, dfrett wrote:
> > whenever a dbh has mysql_auto_reconnect set on it, it will cause a seg > > fault when trying to reconnect a killed connection. > > > > this bug appears to have shown up with v4.007 and appears to be related > > to the TAKE_IMP_DATA_VERSION block of code. Disabling the block by > > removing the define TAKE_IMP_DATA_VERSION makes the seg fault go away > > > > > > attached is a script that is regularly reproducing the error on my perl > > installation. > > > > I have perl 5.8.5, DBI v1.605, and DBD::mysql v4.007 installed.
>
I'm disabling TAKE_IMP_DATA_VERSION for now. I was actually able to reproduce this on an OS X box: radha:trunk patg$ ~/segfault.pl Bus error Ug. This was with DBI version 1.52
From: daniel.frett [...] ccci.org
On Fri Aug 15 07:43:28 2008, CAPTTOFU wrote: Show quoted text
> I'm disabling TAKE_IMP_DATA_VERSION for now. I was actually able to > reproduce this on an OS X box: > > radha:trunk patg$ ~/segfault.pl > Bus error > > Ug. > > This was with DBI version 1.52
I downloaded the test you added to the svn repository and it wasn't giving me the segfault with 4.007 until I removed AutoCommit => 0 from the dbh connect options, just a heads up so the test actually does work in the future when you come back to re-address the TAKE_IMP_DATA code. Thanks for all your hard work on this driver.
From: daniel.frett [...] ccci.org
Here's a patch that fixes the segfault.t test, the auto_reconnect bug, and re-enables the 2 impdata tests because TAKE_IMP_DATA_VERSION was still active code. -Daniel Frett On Fri Aug 15 07:43:28 2008, CAPTTOFU wrote: Show quoted text
> I'm disabling TAKE_IMP_DATA_VERSION for now. I was actually able to > reproduce this on an OS X box: > > radha:trunk patg$ ~/segfault.pl > Bus error > > Ug. > > This was with DBI version 1.52
diff -urx .svn dbd-mysql.orig/dbdimp.c dbd-mysql/dbdimp.c --- dbd-mysql.orig/dbdimp.c 2008-08-01 18:35:40.000000000 -0400 +++ dbd-mysql/dbdimp.c 2008-08-01 18:09:57.000000000 -0400 @@ -4409,7 +4409,11 @@ memcpy (&save_socket, imp_dbh->pmysql,sizeof(save_socket)); memset (imp_dbh->pmysql,0,sizeof(*(imp_dbh->pmysql))); - if (!my_login(h, imp_dbh)) + /* we should disconnect the db handle before reconnecting, this will + * prevent my_login from thinking it's adopting an active child which + * would prevent the handle from actually reconnecting + */ + if (!dbd_db_disconnect(h, imp_dbh) || !my_login(h, imp_dbh)) { do_error(h, mysql_errno(imp_dbh->pmysql), mysql_error(imp_dbh->pmysql), mysql_sqlstate(imp_dbh->pmysql)); diff -urx .svn dbd-mysql.orig/t/65segfault.t dbd-mysql/t/65segfault.t --- dbd-mysql.orig/t/65segfault.t 2008-08-01 18:35:40.000000000 -0400 +++ dbd-mysql/t/65segfault.t 2008-08-01 18:15:47.000000000 -0400 @@ -17,7 +17,7 @@ mysql_auto_reconnect => 1, RaiseError => 1, PrintError => 1, - AutoCommit => 0 }); + AutoCommit => 1 }); }; if ($@) { diff -urx .svn dbd-mysql.orig/t/70takeimp.t dbd-mysql/t/70takeimp.t --- dbd-mysql.orig/t/70takeimp.t 2008-08-01 18:35:40.000000000 -0400 +++ dbd-mysql/t/70takeimp.t 2008-08-01 18:18:46.000000000 -0400 @@ -34,7 +34,6 @@ unless ($dbh->can('take_imp_data')) { plan skip_all => "version of DBI $DBI::VERSION doesn't support this test. Can't continue test"; } -plan skip_all => "This test is disabled"; plan tests => 21; pass("obtained driver handle"); diff -urx .svn dbd-mysql.orig/t/71impdata.t dbd-mysql/t/71impdata.t --- dbd-mysql.orig/t/71impdata.t 2008-08-01 18:35:40.000000000 -0400 +++ dbd-mysql/t/71impdata.t 2008-08-01 18:19:15.000000000 -0400 @@ -24,7 +24,6 @@ unless ($dbh->can('take_imp_data')) { plan skip_all => "version of DBI $DBI::VERSION doesn't support this test. Can't continue test"; } -plan skip_all => "This test is disabled"; plan tests => 10; pass("Connected to database");
Subject: Re: [rt.cpan.org #37027] mysql_auto_reconnect causing seg faults
Date: Wed, 20 Aug 2008 11:59:18 -0400
To: bug-DBD-mysql [...] rt.cpan.org
From: Patrick Galbraith <patg [...] patg.net>
Daniel Frett via RT wrote: Show quoted text
> Queue: DBD-mysql > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=37027 > > > On Fri Aug 15 07:43:28 2008, CAPTTOFU wrote: >
>> I'm disabling TAKE_IMP_DATA_VERSION for now. I was actually able to >> reproduce this on an OS X box: >> >> radha:trunk patg$ ~/segfault.pl >> Bus error >> >> Ug. >> >> This was with DBI version 1.52 >>
> > I downloaded the test you added to the svn repository and it wasn't > giving me the segfault with 4.007 until I removed AutoCommit => 0 from > the dbh connect options, just a heads up so the test actually does work > in the future when you come back to re-address the TAKE_IMP_DATA code. > > Thanks for all your hard work on this driver. >
Hey! Thank you for the patch! Crazy week for me, but I intend to do another release this week. thanks muchly! --Patrick -- Satyam Eva Jayate - Truth Alone Triumphs Mundaka Upanishad
On Wed Aug 20 12:00:17 2008, patg@patg.net wrote: Show quoted text
> Thank you for the patch! Crazy week for me, but I intend to do another > release this week.
By the way, this isn't fixed in 4.008.
I will test this over the weekend to see if I can reproduce it. Thank you for the bug report! On Tue Oct 07 19:33:14 2008, BRONG wrote: Show quoted text
> On Wed Aug 20 12:00:17 2008, patg@patg.net wrote:
> > Thank you for the patch! Crazy week for me, but I intend to do another > > release this week.
> > By the way, this isn't fixed in 4.008.
On Wed Aug 20 12:00:17 2008, patg@patg.net wrote: Show quoted text
> Daniel Frett via RT wrote:
> > Queue: DBD-mysql > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=37027 > > > > > On Fri Aug 15 07:43:28 2008, CAPTTOFU wrote: > >
> >> I'm disabling TAKE_IMP_DATA_VERSION for now. I was actually able to > >> reproduce this on an OS X box: > >> > >> radha:trunk patg$ ~/segfault.pl > >> Bus error > >> > >> Ug. > >> > >> This was with DBI version 1.52 > >>
> > > > I downloaded the test you added to the svn repository and it wasn't > > giving me the segfault with 4.007 until I removed AutoCommit => 0 from > > the dbh connect options, just a heads up so the test actually does work > > in the future when you come back to re-address the TAKE_IMP_DATA code. > > > > Thanks for all your hard work on this driver. > >
> Hey! > > Thank you for the patch! Crazy week for me, but I intend to do another > release this week. > > thanks muchly! > > --Patrick >
Ok, I became buried with work and writing my book. Ug. However, I've tested your patch. I still need to check for DBI version 1.607. Tests 70 and 71 still fail if DBI < 1.607 I'm trying to get out a release this week, really ;)
same issue: $DBI::VERSION = "1.609" DBD::mysql: $VERSION = '4.008'; This script (auto reconnect commented): --snip use DBI; my $dbh = DBI->connect("dbi:mysql:dbname=TABLE", "USER", "PWD"); #$dbh->{mysql_auto_reconnect} = 1; my $sth = $dbh->prepare("select * from assessor_bof limit 1"); while(1) { print "doing\n"; $sth->execute(); sleep 15; } --snap execution (restart of mysql): --snip $ perl 1.pl doing doing DBD::mysql::st execute failed: MySQL server has gone away at 1.pl line 7. --snap execution with string uncommented: --snip $ perl 1.pl doing doing Segmentation fault --snap As I can see this issue isn't fixed yet. mysql/system versions: $ mysql -V mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using readline 5.2 $ uname -a Linux cyga 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux
Works for me in: DBD::mysql version 4.013 On Mon Jul 27 03:02:21 2009, CYGA wrote: Show quoted text
> same issue: > $DBI::VERSION = "1.609" > DBD::mysql: > $VERSION = '4.008'; > > This script (auto reconnect commented): > --snip > use DBI; > my $dbh = DBI->connect("dbi:mysql:dbname=TABLE", "USER", "PWD"); > #$dbh->{mysql_auto_reconnect} = 1; > my $sth = $dbh->prepare("select * from assessor_bof limit 1"); > while(1) { > print "doing\n"; > $sth->execute(); > sleep 15; > } > --snap > > execution (restart of mysql): > --snip > $ perl 1.pl > doing > doing > DBD::mysql::st execute failed: MySQL server has gone away at 1.pl line > 7. > --snap > > execution with string uncommented: > --snip > $ perl 1.pl > doing > doing > Segmentation fault > --snap > > As I can see this issue isn't fixed yet. > > mysql/system versions: > $ mysql -V > mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using > readline 5.2 > $ uname -a > Linux cyga 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC > 2009 i686 GNU/Linux
Thank you. I will verify with the latest DBD::mysql that this works. Looking over previous comments, "mysql server gone away" sounds to me like a server error as opposed to client. On Fri Mar 05 01:22:52 2010, CYGA wrote: Show quoted text
> Works for me in: > DBD::mysql version 4.013 > > On Mon Jul 27 03:02:21 2009, CYGA wrote:
> > same issue: > > $DBI::VERSION = "1.609" > > DBD::mysql: > > $VERSION = '4.008'; > > > > This script (auto reconnect commented): > > --snip > > use DBI; > > my $dbh = DBI->connect("dbi:mysql:dbname=TABLE", "USER", "PWD"); > > #$dbh->{mysql_auto_reconnect} = 1; > > my $sth = $dbh->prepare("select * from assessor_bof limit 1"); > > while(1) { > > print "doing\n"; > > $sth->execute(); > > sleep 15; > > } > > --snap > > > > execution (restart of mysql): > > --snip > > $ perl 1.pl > > doing > > doing > > DBD::mysql::st execute failed: MySQL server has gone away at 1.pl line > > 7. > > --snap > > > > execution with string uncommented: > > --snip > > $ perl 1.pl > > doing > > doing > > Segmentation fault > > --snap > > > > As I can see this issue isn't fixed yet. > > > > mysql/system versions: > > $ mysql -V > > mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using > > readline 5.2 > > $ uname -a > > Linux cyga 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC > > 2009 i686 GNU/Linux
> >
Verified this is fixed, as of 4.017/4.018