Subject: | checking the return value of commit() in scalar context results with: panic: attempt to copy freed scalar when using transactions and the debugger |
Hi,
Please see the attached:
i) test file
ii) sample output
iii) perl version details.
DBI version: 1.628
DBD::mysql version: 4.029
mysql server: 5.6.14
This only happens when using the debugger. The program runs fine otherwise.
I assume this is a DBD::mysql issue as the transactions are handled by it.
There are some posts mentioning this issue dating back to several years, in which one
person suggests calling the method in list context, and it indeed removes the error:
my($rv) = $dbh->commit;
Thanks,
Burak
Subject: | dbd_mysql_bug.pl |
#!perl
use strict;
use warnings;
use DBI;
use Config::General;
use Data::Dumper;
my $conf = Config::General->new(
-ConfigFile => '/etc/bookings/db.conf',
-InterPolateEnv => 1,
)->{config}{Database}{test};
my $dbh = DBI->connect(
@{ $conf }{qw/ rw_dsn rw_username ro_password / },
{PrintError => 0, RaiseError => 1 }
);
$dbh->do('
create table if not exists dbi_bug (
id int auto_increment,
val varchar(10),
primary key(id) )
');
$dbh->begin_work;
$dbh->do('insert into dbi_bug (val) values ("testing") ');
my $rv = $dbh->commit;
print "got: $rv\n";
Subject: | dbd_mysql_bug_output.txt |
$ perl -d dbd_mysql_bug.pl
Loading DB routines from perl5db.pl version 1.39_10
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(dbi_bug.pl:8): my $conf = Config::General->new(
main::(dbi_bug.pl:9): -ConfigFile => '/etc/bookings/db.conf',
main::(dbi_bug.pl:10): -InterPolateEnv => 1,
main::(dbi_bug.pl:11): )->{config}{Database}{test};
DB<1> c
panic: attempt to copy freed scalar 2dd7fb8 to 24d37a0 at /usr/local/booking-perl/5.18.2/lib/perl5db.pl line 4203.
at /usr/local/booking-perl/5.18.2/lib/perl5db.pl line 4203.
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
Subject: | perl_V.txt |
$ perl -V
Summary of my perl5 (revision 5 version 18 subversion 2) configuration:
Platform:
osname=linux, osvers=2.6.32-358.6.2.el6.x86_64, archname=x86_64-linux
uname='linux bkbuild-201.lhr4.prod.booking.com 2.6.32-358.6.2.el6.x86_64 #1 smp thu may 16 20:59:36 utc 2013 x86_64 x86_64 x86_64 gnulinux '
config_args='-des -DSILENT_NO_TAINT_SUPPORT -Dprefix=/usr/local/booking-perl/5.18.2 -Uusevendorprefix -Dsiteprefix=/usr/local/booking-perl/5.18.2 -Dinstallprefix=/usr/local/booking-perl/5.18.2 -Dinstallstyle=lib -Darchlib=/usr/local/booking-perl/5.18.2/lib -Dman1dir=/usr/local/booking-perl/5.18.2/man/man1 -Dman3dir=/usr/local/booking-perl/5.18.2/man/man3 -Dprivlib=/usr/local/booking-perl/5.18.2/lib -Dsitearch=/usr/local/booking-perl/5.18.2/site/lib -Dsitebin=/usr/local/booking-perl/5.18.2/site/bin -Dsitelib=/usr/local/booking-perl/5.18.2/site/lib -Dsiteman1dir=/usr/local/booking-perl/5.18.2/site/man/man1 -Dsiteman3dir=/usr/local/booking-perl/5.18.2/site/man/man3 -Dcc=gcc -Dlibpth=/usr/local/booking-perl/5.18.2/lib /usr/lib64 -Dglibpth=/usr/local/booking-perl/5.18.2/lib /usr/lib64 -Dscriptdir=/usr/local/booking-perl/5.18.2/bin -Uinstallusrbinperl -Duseshrplib -Dusesitecustomize -UDEBUGGING -Di_db -A prepend:libswanted=pthread '
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.4.6 20120305 (Red Hat 4.4.6-4)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -fstack-protector'
libpth=/usr/lib64
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.12'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/local/booking-perl/5.18.2/lib/CORE'
cccdlflags='-fPIC', lddlflags='-shared -O2 -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
USE_SITECUSTOMIZE
Built under linux
Compiled at Jan 28 2014 12:07:45
%ENV:
PERL5LIB="/usr/local/git_tree/main/lib"
@INC:
/usr/local/git_tree/main/lib
/usr/local/booking-perl/5.18.2/site/lib
/usr/local/booking-perl/5.18.2/lib
.