Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic error ("attempt to copy freed scalar") in perl5db.pl:3733 #12175

Closed
p5pRT opened this issue Jun 14, 2012 · 15 comments
Closed

Panic error ("attempt to copy freed scalar") in perl5db.pl:3733 #12175

p5pRT opened this issue Jun 14, 2012 · 15 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 14, 2012

Migrated from rt.perl.org#113644 (status was 'resolved')

Searchable as RT113644$

@p5pRT
Copy link
Author

p5pRT commented Jun 14, 2012

From ericp@ActiveState.com

Created by ericp@activestate.com

Debug this program in the command-line (using 5.10.0)

########################################
use strict;
use warnings;

use DBI;

my $DBUSER = 'root';
my $DBPASS = 'password';
my $DBNAME = 'fc02';

my $dbh = DBI->connect('DBI​:mysql​:' . $DBNAME, $DBUSER, $DBPASS);

if($DBI​::errstr){
  print STDERR $DBI​::errstr . "\n";
  exit 1;
}

$dbh->do('create table info(id int auto_increment PRIMARY KEY, data varchar(255))');

$dbh->begin_work();

$dbh->do('INSERT INTO info(data) VALUES(123)');
$dbh->do('INSERT INTO info(data) VALUES(456)');
$dbh->do('INSERT INTO info(data) VALUES(789)');

my $status = $dbh->commit();

exit 0;
###########################################################

c​:> perl -d bug-mysql-freed-scalar.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main​::(bug-mysql-freed-scalar.pl​:6)​:
6​: my $DBUSER = 'root';
  DB<1> b 25

  DB<2> c
DBD​::mysql​::db do failed​: Table 'info' already exists at bug-mysql-freed-scalar
pl line 17.
  at bug-mysql-freed-scalar.pl line 17
main​::(bug-mysql-freed-scalar.pl​:25)​:
25​: my $status = $dbh->commit();

  DB<2> n
panic​: attempt to copy freed scalar 3c8d45c to 2936664 at C​:/Perl/lib/perl5db.p
  line 3733.
  at C​:/Perl/lib/perl5db.pl line 3733
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.

This happens with the call to

$ret = &$sub;

in DB​::sub

Perl Info

Flags:
     category=core
     severity=medium

Site configuration information for perl 5.10.0:

Configured by SYSTEM at Wed Sep  3 13:16:08 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
   Platform:
     osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
     uname=''
     config_args='undef'
     hint=recommended, useposix=true, d_sigaction=undef
     useithreads=define, usemultiplicity=define
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=undef, use64bitall=undef, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
     optimize='-MD -Zi -DNDEBUG -O1',
     cppflags='-DWIN32'
     ccversion='12.00.8804', gccversion='', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
     d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
     libpth=\lib
     libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
     perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
     libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl510.lib
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
     ACTIVEPERL_LOCAL_PATCHES_ENTRY
     33741 avoids segfaults invoking S_raise_signal() (on Linux)
     33763 Win32 process ids can have more than 16 bits
     32809 Load 'loadable object' with non-default file extension
     32728 64-bit fix for Time::Local


@INC for perl 5.10.0:
     C:/Perl/site/lib
     C:/Perl/lib
     .


Environment for perl 5.10.0:
     HOME=C:\Users\ericp
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=C:\Program Files\ActiveState Komodo IDE 7\;D:\apps\tcl-8.6.0.0b7\bin;C:\Program Files\ActiveState Komodo Edit 7\;C:\Program Files\ActiveState Komodo IDE 6\;C:\Program Files\ActiveState Perl Dev Kit 9.0.1\bin\;C:\Ruby186\bin;C:\Program Files\ActiveState Perl Dev Kit 9.0\bin\;C:\apps\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Program Files\Autodesk\Maya2009\bin;C:\Program Files\ActiveState Komodo IDE 5.2\;C:\Python26\\Scripts;C:\Python26\;C:\Program Files\ActiveState Komodo Edit 5\;C:\apps\php-5.3.0-nts-vc9\;C:\apps\php-5.3.0-nts\;C:\apps\PHP-5.3\;C:\Python26;C:\Python26\scripts;C:\Program Files\ActiveState Komodo IDE 5.1;C:\Program Files\ActiveState Perl Dev Kit 8.0.1\bin;C:\Perl\site\bin;C:\Perl\bin;c:\apps\svn\bin;c:\bin;c:\Users\ericp\bin;c:\msys\bin;C:\apps\p4;C:\TclDevKit\bin;C:\Tcl\bin;c:\apps\git\bin;C:\Users\ericp\svn\apps\komodo\util\black;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn;C:\Pr
ogram Files\MySQL\MySQL Server 
5.0\bin;C:\Program Files\QuickTime\QTSystem;C:\Program Files\Windows Resource Kits\Tools\;C:\Program Files\Common Files\Autodesk Shared\AdLM\R1;C:\Program Files\TortoiseSVN\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\apps\Mercurial;C:\Users\ericp\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Users\ericp\AppData\Roaming\Python\Scripts;C:\apps\CVSNT;c:\apps\PostgreSQL\8.4\bin
     PERL_BADLANG (unset)
     SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2012

From bannan@gmail.com

I can confirm that the same happens on Centos 6.2 with perl 5.14

@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2012

From [Unknown Contact. See original ticket]

I can confirm that the same happens on Centos 6.2 with perl 5.14

@p5pRT
Copy link
Author

p5pRT commented Jul 14, 2012

From @cpansprout

On Thu Jun 14 12​:44​:21 2012, ericp wrote​:

Message-Id​: <5.10.0_3332_1339702004@​edsel.activestate.com>

This is a bug report for perl from ericp@​activestate.com,
generated with the help of perlbug 1.36 running under perl 5.10.0.

-----------------------------------------------------------------
[Please enter your report here]

Debug this program in the command-line (using 5.10.0)

########################################
use strict;
use warnings;

use DBI;

my $DBUSER = 'root';
my $DBPASS = 'password';
my $DBNAME = 'fc02';

my $dbh = DBI->connect('DBI​:mysql​:' . $DBNAME, $DBUSER, $DBPASS);

if($DBI​::errstr){
print STDERR $DBI​::errstr . "\n";
exit 1;
}

$dbh->do('create table info(id int auto_increment PRIMARY KEY, data
varchar(255))');

$dbh->begin_work();

$dbh->do('INSERT INTO info(data) VALUES(123)');
$dbh->do('INSERT INTO info(data) VALUES(456)');
$dbh->do('INSERT INTO info(data) VALUES(789)');

my $status = $dbh->commit();

exit 0;
###########################################################

c​:> perl -d bug-mysql-freed-scalar.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main​::(bug-mysql-freed-scalar.pl​:6)​:
6​: my $DBUSER = 'root';
DB<1> b 25

DB<2> c
DBD​::mysql​::db do failed​: Table 'info' already exists at bug-mysql-
freed-scalar
pl line 17.
at bug-mysql-freed-scalar.pl line 17
main​::(bug-mysql-freed-scalar.pl​:25)​:
25​: my $status = $dbh->commit();

DB<2> n
panic​: attempt to copy freed scalar 3c8d45c to 2936664 at
C​:/Perl/lib/perl5db.p
line 3733.
at C​:/Perl/lib/perl5db.pl line 3733
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.

This happens with the call to

$ret = &$sub;

in DB​::sub

I don’t have mysql installed, so it’s not easy for me to test this. I
know I fixed some problems with $DB​::sub in perl 5.16. Could you try
that version and see whether the problem persists?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jul 14, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2012

From ericp@ActiveState.com

On Linux I get an internal error when I try to bind DBI​:mysql in the
$dbh = DBI->connect call​:

"""
install_driver(mysql) failed​: Unable to get DBI state function. DBI not
loaded. at /home/ericp/opt/ActivePerl-5.16.0.1600/lib/DynaLoader.pm line
214.
Compilation failed in require at (eval
12)[/home/ericp/opt/ActivePerl-5.16.0.1600/lib/DBI.pm​:771] line 3.
"""

On Windows ppm for ActivePerl 5.16.0 refuses to install DBD​::mysql
("No missing packages to install")

and I don't see an easy way to build it on a Windows box. I don't
see an obvious link to get the mysql dev source on Windows.

I haven't heard from the Komodo user who first reported this problem,
and can't help out much more than that. Sorry about that.

@p5pRT
Copy link
Author

p5pRT commented Jan 16, 2015

From cpan@goess.org

I'm also seeing this error on perl 5.14 (standard centos 6.3 build) with DBD​::mysql versions 4.021 and 4.029. Haven't tried it yet with perl 5.16, I'll see if I can do that.

It only happens when you try to *examine* the return value from commit.

Any kind of comparison or assignment anywhere in the call stack will trigger the error. If you ignore the return value from commit, then it all works fine.


$ cat test-err.pl

use warnings;
use strict;

use DBI;

my ($connectstr, $username, $password) = @​ARGV;

my $dbh = DBI->connect($connectstr, $username, $password, {});

$dbh->begin_work;

my $sth = $dbh->prepare('insert into kgtest set body=?') || die $dbh->errstr;
$sth->execute('kgtesting text body') || die $dbh->errstr;
print "PostingID is ". $sth->{'mysql_insertid'}."\n";

print "about to commit...\n";
my $rc = $dbh->commit;
print "done committing...\n";

$ ./test-err.sh

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main​::(test-err.pl​:7)​: my ($connectstr, $username, $password) = @​ARGV;
  DB<1> c
about to commit...
panic​: attempt to copy freed scalar 2244548 to 1c08278 at /usr/share/perl5/perl5db.pl line 3737.
at /usr/share/perl5/perl5db.pl line 3737
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.

@p5pRT
Copy link
Author

p5pRT commented Jan 16, 2015

From [Unknown Contact. See original ticket]

I'm also seeing this error on perl 5.14 (standard centos 6.3 build) with DBD​::mysql versions 4.021 and 4.029. Haven't tried it yet with perl 5.16, I'll see if I can do that.

It only happens when you try to *examine* the return value from commit.

Any kind of comparison or assignment anywhere in the call stack will trigger the error. If you ignore the return value from commit, then it all works fine.


$ cat test-err.pl

use warnings;
use strict;

use DBI;

my ($connectstr, $username, $password) = @​ARGV;

my $dbh = DBI->connect($connectstr, $username, $password, {});

$dbh->begin_work;

my $sth = $dbh->prepare('insert into kgtest set body=?') || die $dbh->errstr;
$sth->execute('kgtesting text body') || die $dbh->errstr;
print "PostingID is ". $sth->{'mysql_insertid'}."\n";

print "about to commit...\n";
my $rc = $dbh->commit;
print "done committing...\n";

$ ./test-err.sh

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main​::(test-err.pl​:7)​: my ($connectstr, $username, $password) = @​ARGV;
  DB<1> c
about to commit...
panic​: attempt to copy freed scalar 2244548 to 1c08278 at /usr/share/perl5/perl5db.pl line 3737.
at /usr/share/perl5/perl5db.pl line 3737
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.

@p5pRT
Copy link
Author

p5pRT commented Jan 16, 2015

From cpan@goess.org

Haven't tried it yet with perl 5.16, I'll see if I can do that.

Verified with 5.16.3, 5.18.0, 5.20.1​:

  DB<1> c
versions are perl​: v5.16.3 DBI​: 1.627 DBD​::mysql​: 4.023
PostingID is 4
about to commit...
panic​: attempt to copy freed scalar 13dca08 to e0b548 at /usr/share/perl5/perl5db.pl line 3545.
at /usr/share/perl5/perl5db.pl line 3545.

  DB<1> c
versions are perl​: v5.18.0 DBI​: 1.633 DBD​::mysql​: 4.029
PostingID is 3
about to commit...
panic​: attempt to copy freed scalar 12db760 to d534b0 at /home/kgoess/perl5/perlbrew/perls/perl-5.18.0/lib/5.18.0/perl5db.pl line 4197.
at /home/kgoess/perl5/perlbrew/perls/perl-5.18.0/lib/5.18.0/perl5db.pl line 4197.

  DB<1> c
versions are perl​: v5.20.1 DBI​: 1.633 DBD​::mysql​: 4.029
PostingID is 5
about to commit...
panic​: attempt to copy freed scalar 1f1ba58 to 19ca9b0 at /home/kgoess/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/perl5db.pl line 4204.
at /home/kgoess/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/perl5db.pl line 4204.

FWIW there's an open ticket that mentions this problem (but was opened with a different problem in the subject line) filed under DBD​::mysql https://rt.cpan.org/Public/Bug/Display.html?id=47874 . Should this be a perl bug or a DBD​::mysql bug?

@p5pRT
Copy link
Author

p5pRT commented Jan 16, 2015

From [Unknown Contact. See original ticket]

Haven't tried it yet with perl 5.16, I'll see if I can do that.

Verified with 5.16.3, 5.18.0, 5.20.1​:

  DB<1> c
versions are perl​: v5.16.3 DBI​: 1.627 DBD​::mysql​: 4.023
PostingID is 4
about to commit...
panic​: attempt to copy freed scalar 13dca08 to e0b548 at /usr/share/perl5/perl5db.pl line 3545.
at /usr/share/perl5/perl5db.pl line 3545.

  DB<1> c
versions are perl​: v5.18.0 DBI​: 1.633 DBD​::mysql​: 4.029
PostingID is 3
about to commit...
panic​: attempt to copy freed scalar 12db760 to d534b0 at /home/kgoess/perl5/perlbrew/perls/perl-5.18.0/lib/5.18.0/perl5db.pl line 4197.
at /home/kgoess/perl5/perlbrew/perls/perl-5.18.0/lib/5.18.0/perl5db.pl line 4197.

  DB<1> c
versions are perl​: v5.20.1 DBI​: 1.633 DBD​::mysql​: 4.029
PostingID is 5
about to commit...
panic​: attempt to copy freed scalar 1f1ba58 to 19ca9b0 at /home/kgoess/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/perl5db.pl line 4204.
at /home/kgoess/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/perl5db.pl line 4204.

FWIW there's an open ticket that mentions this problem (but was opened with a different problem in the subject line) filed under DBD​::mysql https://rt.cpan.org/Public/Bug/Display.html?id=47874 . Should this be a perl bug or a DBD​::mysql bug?

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2015

From @jkeenan

On Fri Jan 16 10​:13​:12 2015, cpan@​goess.org wrote​:

Haven't tried it yet with perl 5.16, I'll see if I can do that.

Verified with 5.16.3, 5.18.0, 5.20.1​:

[snip]

FWIW there's an open ticket that mentions this problem (but was opened
with a different problem in the subject line) filed under DBD​::mysql
https://rt.cpan.org/Public/Bug/Display.html?id=47874 . Should this be
a perl bug or a DBD​::mysql bug?

The problem is probably some interaction between the Perl debugger and the XS guts of DBI or DBD​::mysql -- which makes it difficult to diagnose and which may explain why this ticket and the rt.cpan.org ticket you cited have remained open for so long. In practical terms, to diagnose someone needs to have both perl and mysql set up and be familiar with both.

You could try posting on a more DBI-specific list such as dbi-users. Subscription info available at​:

http​://lists.perl.org/list/dbi-users.html

Hope that helps.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2015

From @cpansprout

On Fri Jan 16 10​:13​:12 2015, cpan@​goess.org wrote​:

FWIW there's an open ticket that mentions this problem (but was opened
with a different problem in the subject line) filed under DBD​::mysql
https://rt.cpan.org/Public/Bug/Display.html?id=47874 . Should this be
a perl bug or a DBD​::mysql bug?

Until someone has the tuits (round ones, mind you) to investigate which project is to blame, it should probably be both.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Apr 22, 2016

From @timbunce

FYI I'm looking into this via https://rt.cpan.org/Ticket/Display.html?id=102791

@p5pRT
Copy link
Author

p5pRT commented Apr 22, 2016

From @timbunce

I think this is now fixed. I call_method(..., G_DISCARD) to G_VOID instead.

@p5pRT p5pRT closed this as completed Jun 20, 2016
@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2016

@iabyn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant