After talking with Tim, he suggested I send this here, since
there has been no response from the DBD::MySQL people
directly or the mysql lists that the various people who have
fallen foul of this have tried.
For OpenBSD 4,0-release, the DBD::MySQL has been reverted to
2.9004 which is the last version to work. Later versions
have all had this or other problems with segfaults due to
the memory protections OpenBSD uses.
The first report and backtrace is from Federico Giannici
the second is mine sent to the dbd-mysql list at mysql.com
and the DBD::MySQL developer after no response.
I'm happy to test patches ior give you access to a machine
which has this problem to help debugging.
Thanks
Sam
Federico Giannici:
It seems to me that there is some kind of memory access problem with DBI
or DBD-Mysql.
I'm using OpenBSD 3.9-stable amd64. On OpenBSD 3.3 i386 the problem
didn't appeared. As you may know, recent version of OpenBSD have a new
kind of memory handling that make the programs segfault when they try to
access no (longer) allocated memory.
I'm using DBI 1.45 and DBD-Mysql 2.9008. I tried DBI 1.52 and DBD-Mysql
3.0006, but the problems were more frequent, so I remained to the old
versions.
Here is the problem: frequently some "do" commands cause perl to crash
with signal 11. The crashes seems to depend on a lot of factors. For
example, loading more libraries could make the program to start working.
I think it depends on the structure of the memory allocated to the
program.
Here is the "bt" output of the core dump:
#0 0x000000005260a736 in mysql_st_internal_execute (h=0x4713b6e0,
statement=0x479b7140, attribs=0x4aa5fd40, numParams=0, params=0x0,
cdaPtr=0x7f7ffffc8610, svsock=0x43c90498, use_mysql_use_result=0)
at dbdimp.c:1654
#1 0x0000000052612da3 in XS_DBD__mysql__db_do (cv=0x40970b20) at
mysql.xs:222
#2 0x0000000050ddf07b in XS_DBI_dispatch () from
/usr/local/libdata/perl5/site_perl/amd64-openbsd/auto/DBI/DBI.so
#3 0x000000004a5a1c47 in Perl_pp_entersub () at
/usr/src/gnu/usr.bin/perl/pp_hot.c:2890
#4 0x000000004a60899e in Perl_runops_standard () at
/usr/src/gnu/usr.bin/perl/run.c:37
#5 0x000000004a5f744d in S_run_body (oldscope=1) at
/usr/src/gnu/usr.bin/perl/perl.c:1936
#6 0x000000004a5f7231 in perl_run (my_perl=0x45356258) at
/usr/src/gnu/usr.bin/perl/perl.c:1855
#7 0x0000000000401afe in main ()
I have found the problem is caused by accessing
"imp_dbh->bind_type_guessing" for the call to ParseParam() inside
mysql_st_internal_execute().
I have verified that "imp_dbh" is NOT null, but trying to access any
member make the program segfault. So maybe the pointer is a stale one?
I have not enough knowledge of DBI to make more debugging.
my test case for reproducable segfault. You're welcome to a
login on my box if you can't reproduce.
The below fragment of code either segfaults or gives the
following error when run on OpenBSD 4.0-beta:
FREE ERROR BIND!FREE ERROR FBIND!
__START__
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
my $dsn = 'DBI:mysql:glocaliser:localhost'; # DSN connection string
my $db_username= 'perl'; # database username
my $db_password= 'perl'; # database password
our $dbh= DBI->connect($dsn, $db_username, $db_password);
my $v= 8;
my $q= $dbh->prepare("select * from interests where tag=?")
$q->execute($v);
__END__
having the last line read $q->execute("$v") is a workaround.
tag is a varchar field.
A core of the more general case is:
(gdb) target core perl.core
Core was generated by `perl'.
Program terminated with signal 11, Segmentation fault.
bReading symbols from /usr/lib/libperl.so.10.1...tdone.
Loaded symbols for /usr/lib/libperl.so.10.1
Reading symbols from /usr/lib/libm.so.2.3...
done.
Loaded symbols for /usr/lib/libm.so.2.3
Reading symbols from /usr/lib/libutil.so.11.0...done.
Loaded symbols for /usr/lib/libutil.so.11.0
Reading symbols from /usr/lib/libc.so.39.2...done.
Loaded symbols for /usr/lib/libc.so.39.2
Reading symbols from /usr/libexec/ld.so...done.
Loaded symbols for /usr/libexec/ld.so
Reading symbols from
/usr/local/libdata/perl5/site_perl/i386-openbsd/auto/DBI/DBI.so...done.
Loaded symbols for
/usr/local/libdata/perl5/site_perl/i386-openbsd/auto/DBI/DBI.so
Reading symbols from
/usr/libdata/perl5/i386-openbsd/5.8.8/auto/List/Util/Util.so...done.
Loaded symbols for
/usr/libdata/perl5/i386-openbsd/5.8.8/auto/List/Util/Util.so
Reading symbols from
/usr/local/libdata/perl5/site_perl/i386-openbsd/auto/DBD/mysql/mysql.so...do
ne.
Loaded symbols for
/usr/local/libdata/perl5/site_perl/i386-openbsd/auto/DBD/mysql/mysql.so
Reading symbols from /usr/local/lib/mysql/libmysqlclient.so.16.0...done.
Loaded symbols for /usr/local/lib/mysql/libmysqlclient.so.16.0
Reading symbols from /usr/lib/libz.so.4.1...done.
Loaded symbols for /usr/lib/libz.so.4.1
Reading symbols from /usr/lib/libssl.so.10.0...done.
Loaded symbols for /usr/lib/libssl.so.10.0
Reading symbols from /usr/lib/libcrypto.so.12.1...done.
Loaded symbols for /usr/lib/libcrypto.so.12.1
Reading symbols from /usr/lib/libcrypto.so.13.0...done.
Loaded symbols for /usr/lib/libcrypto.so.13.0
Reading symbols from /usr/lib/libssl.so.11.0...done.
Loaded symbols for /usr/lib/libssl.so.11.0
#0 0x0461faa3 in mysql_st_prepare (sth=0x8315330c, imp_sth=0x7cd55100,
statement=0x811ad600 "select * from interests where tag =? and
site_hidden=0 and hidden=0 and confirmed=1",
attribs=0xfe) at dbdimp.c:2310
2310 col_type= (has_statement_fields ?
(gdb) bt
#0 0x0461faa3 in mysql_st_prepare (sth=0x8315330c, imp_sth=0x7cd55100,
statement=0x811ad600 "select * from interests where tag =? and
site_hidden=0 and hidden=0 and confirmed=1",
attribs=0xfe) at dbdimp.c:2310
#1 0x0462482c in XS_DBD__mysql__st__prepare (cv=0x7c166a74) at
mysql.xsi:427
#2 0x0d9f1d08 in Perl_pp_entersub () at
/usr/src/gnu/usr.bin/perl/pp_hot.c:2877
#3 0x0da1c5b9 in Perl_runops_standard () at
/usr/src/gnu/usr.bin/perl/run.c:37
#4 0x0da03008 in S_call_body (myop=0xcf7eb250, is_eval=0 '\0') at
/usr/src/gnu/usr.bin/perl/perl.c:2733
#5 0x0da02f2e in Perl_call_sv (sv=0x8315327c, flags=0) at
/usr/src/gnu/usr.bin/perl/perl.c:2609
#6 0x08b42d3e in XS_DBI_dispatch () from
/usr/local/libdata/perl5/site_perl/i386-openbsd/auto/DBI/DBI.so
#7 0x0d9f1d08 in Perl_pp_entersub () at
/usr/src/gnu/usr.bin/perl/pp_hot.c:2877
#8 0x0da1c5b9 in Perl_runops_standard () at
/usr/src/gnu/usr.bin/perl/run.c:37
#9 0x0da025df in S_run_body (oldscope=1) at
/usr/src/gnu/usr.bin/perl/perl.c:2368
#10 0x0da02533 in perl_run (my_perl=0x868a1030) at
/usr/src/gnu/usr.bin/perl/perl.c:2285
#11 0x1c0012a6 in main ()
(gdb)
mysql info:
mysql-client-5.0.22 multithreaded SQL database (client)
mysql-server-5.0.21 multithreaded SQL database (server)
p5-DBD-mysql-3.0006_1 MySQL drivers for the Perl DBI
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=openbsd, osvers=4.0, archname=i386-openbsd
uname='openbsd'
config_args='-dsE -Dopenbsd_distribution=defined'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -fno-delete-null-pointer-checks
-pipe -I/usr/local/include',
optimize='-O2',
cppflags='-fno-strict-aliasing -fno-delete-null-pointer-checks -pipe
-I/usr/local/include'
ccversion='', gccversion='3.3.5 (propolice)', gccosandvers='openbsd4.0'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags ='-Wl,-E '
libpth=/usr/lib
libs=-lm -lutil -lc
perllibs=-lm -lutil -lc
libc=/usr/lib/libc.a, so=so, useshrplib=true, libperl=libperl.so.10.1
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-Wl,-R/usr/libdata/perl5/i386-openbsd/5.8.8/CORE'
cccdlflags='-DPIC -fPIC ', lddlflags='-shared -fPIC '
Characteristics of this binary (from libperl):
Compile-time options: PERL_MALLOC_WRAP USE_LARGE_FILES USE_PERLIO
Built under openbsd
@INC:
/usr/libdata/perl5/i386-openbsd/5.8.8
/usr/local/libdata/perl5/i386-openbsd/5.8.8
/usr/libdata/perl5
/usr/local/libdata/perl5
/usr/local/libdata/perl5/site_perl/i386-openbsd
/usr/libdata/perl5/site_perl/i386-openbsd
/usr/local/libdata/perl5/site_perl
/usr/libdata/perl5/site_perl
/usr/local/lib/perl5/site_perl
.
--
Irresponsibility: No single raindrop believes it is to blame for the flood