On Fri, Aug 22, 2014 at 05:53:56PM -0400, Brad Smith wrote: > On 22/08/14 5:46 PM, Stuart Henderson wrote: > >On 2014/08/22 22:06, Stuart Henderson wrote: > >>On 2014/08/19 17:15, Brad Smith wrote: > >>>Here is a diff to make attempt #2 at switching to MariaDB. > >>> > >>>Going through the various Makefile's I noticed bmf had a typo > >>>with its WANTLIB entry for MySQL. > >> > >>It seems that files moved between -server (on mysql) and -client (on > >>mariadb), > >> > >> /usr/local/bin/msql2mysql (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/bin/mysql_find_rows (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/bin/mysql_waitpid (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/bin/mysqlaccess (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/man/cat1/msql2mysql.0 (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/man/cat1/mysql_find_rows.0 (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/man/cat1/mysql_waitpid.0 (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> /usr/local/man/cat1/mysqlaccess.0 (mysql-server-5.1.73p0v0 and > >> mariadb-client-10.0.13) > >> > >>untested but perhaps adding "@conflict mysql-server-*" to > >>mariadb/pkg/PLIST-main > >>will let this update automatically.. > >> > > > >Not specific to mariadb (similar things happen with the standalone mytop) > >but noticed this while testing: > > heh. you're right. If I run mytop numerous times it varies between > what you have below and just... > > $ mytop > Segmentation fault (core dumped) > > >$ mytop > >Cannot connect to MySQL server. Please check the: > > > > * database you specified "test" (default is "test") > > * username you specified "root" (default is "root") > > * password you specified "" (default is "") > > * hostname you specified "localhost" (default is "localhost") > > * port you specified "3306" (default is 3306) > > * socket you specified "/var/run/mysql/mysql.sock" (default is "") > > > >The options my be specified on the command-line or in a ~/.mytop > >config file. See the manual (perldoc mytop) for details. > > > >Here's the exact error from DBI. It might help you debug: > > > >??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????! ?! > ??! > > > > ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? > > > >..... > > > >#0 0x0000065180fca864 in strlen (str=0x65276ff3897 '?' <repeats 200 > >times>...) at /usr/src/lib/libc/string/strlen.c:39 > >39 /usr/src/lib/libc/string/strlen.c: No such file or directory. > > in /usr/src/lib/libc/string/strlen.c > >(gdb) bt > >#0 0x0000065180fca864 in strlen (str=0x65276ff3897 '?' <repeats 200 > >times>...) at /usr/src/lib/libc/string/strlen.c:39 > >#1 0x00000651c30023cc in Perl_sv_setpv (sv=0x651857fa058, ptr=0x65276ff3897 > >'?' <repeats 200 times>...) at /usr/src/gnu/usr.bin/perl/sv.c:4596 > >#2 0x00000651e426c0d5 in mysql_dr_error (h=Variable "h" is not available. > >) at dbdimp.c:1441 > >#3 0x00000651e4270f01 in mysql_db_login (dbh=0x652687b47a8, > >imp_dbh=0x651962a4100, > > dbname=0x65243adb300 > > "database=test;mysql_read_default_group=mytop;mysql_socket=/var/run/mysql/mysql.sock", > > user=Variable "user" is not available. > >) at dbdimp.c:2096 > >#4 0x00000651e427ad40 in XS_DBD__mysql__db__login (cv=Variable "cv" is not > >available. > >) at mysql.xsi:104 > >#5 0x00000651c303f09d in Perl_pp_entersub () at > >/usr/src/gnu/usr.bin/perl/pp_hot.c:2888 > >#6 0x00000651c30631f3 in Perl_runops_standard () at > >/usr/src/gnu/usr.bin/perl/run.c:42 > >#7 0x00000651c3033ade in Perl_call_sv (sv=0x651fd180250, flags=2) at > >perl.c:2751 > >#8 0x0000065194537326 in XS_DBI_dispatch () from > >/usr/local/libdata/perl5/site_perl/amd64-openbsd/auto/DBI/DBI.so > >#9 0x00000651c303f09d in Perl_pp_entersub () at > >/usr/src/gnu/usr.bin/perl/pp_hot.c:2888 > >#10 0x00000651c30631f3 in Perl_runops_standard () at > >/usr/src/gnu/usr.bin/perl/run.c:42 > >#11 0x00000651c3034a3c in perl_run (my_perl=Variable "my_perl" is not > >available. > >) at perl.c:2467 > >#12 0x0000064f80c014e3 in main () from /usr/bin/perl > > > > > >(gdb) x/x str > >0x65276ff3897: 0xdfdfdfdf > > > > > >... so this looks like a use-after-free in DBD::MySQL error handling.
There was a use-after-free fix that went into .028 and a pending patch to add some additional changes to what was initially commited. Looking at the Perl RT ticket it looks like the bug is related to what we're seeing but it appears the code changes that have been done so far do not resolve the issue. Index: Makefile =================================================================== RCS file: /home/cvs/ports/databases/p5-DBD-mysql/Makefile,v retrieving revision 1.39 diff -u -p -u -p -r1.39 Makefile --- Makefile 11 Jul 2014 14:11:12 -0000 1.39 +++ Makefile 22 Aug 2014 23:27:16 -0000 @@ -4,7 +4,7 @@ SHARED_ONLY= Yes COMMENT= MySQL drivers for the Perl DBI -DISTNAME= DBD-mysql-4.027 +DISTNAME= DBD-mysql-4.028 CATEGORIES= databases MAINTAINER= Giovanni Bechis <[email protected]> Index: distinfo =================================================================== RCS file: /home/cvs/ports/databases/p5-DBD-mysql/distinfo,v retrieving revision 1.19 diff -u -p -u -p -r1.19 distinfo --- distinfo 11 Jul 2014 14:11:12 -0000 1.19 +++ distinfo 22 Aug 2014 23:02:49 -0000 @@ -1,2 +1,2 @@ -SHA256 (DBD-mysql-4.027.tar.gz) = LgDx61giqgl7MQID/2Ed1jX50ADbnffOHosEk8CCvkE= -SIZE (DBD-mysql-4.027.tar.gz) = 137476 +SHA256 (DBD-mysql-4.028.tar.gz) = WEKySv/avOixcSL5EM1bWyU78mbX5QhK9d9CSFI4Ee0= +SIZE (DBD-mysql-4.028.tar.gz) = 138614 Index: patches/patch-dbdimp_c =================================================================== RCS file: patches/patch-dbdimp_c diff -N patches/patch-dbdimp_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-dbdimp_c 22 Aug 2014 23:20:00 -0000 @@ -0,0 +1,34 @@ +$OpenBSD$ + +Fix a use-after-free crash. + +https://rt.cpan.org/Public/Bug/Display.html?id=97625 +https://github.com/perl5-dbi/DBD-mysql/pull/27 + +--- dbdimp.c.orig Fri Aug 22 19:16:08 2014 ++++ dbdimp.c Fri Aug 22 19:18:06 2014 +@@ -1996,6 +1996,7 @@ static int my_login(pTHX_ SV* dbh, imp_dbh_t *imp_dbh) + char* password; + char* mysql_socket; + int result; ++ int fresh = 0; + D_imp_xxh(dbh); + + /* TODO- resolve this so that it is set only if DBI is 1.607 */ +@@ -2044,12 +2045,15 @@ static int my_login(pTHX_ SV* dbh, imp_dbh_t *imp_dbh) + port ? port : "NULL"); + + if (!imp_dbh->pmysql) { ++ fresh = 1; + Newz(908, imp_dbh->pmysql, 1, MYSQL); + } + result = mysql_dr_connect(dbh, imp_dbh->pmysql, mysql_socket, host, port, user, + password, dbname, imp_dbh) ? TRUE : FALSE; +- if (!result) ++ if (fresh && !result) { ++ /* Prevent leaks, but do not free in case of a reconnect. See #97625 */ + Safefree(imp_dbh->pmysql); ++ } + return result; + } + -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
