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

DBD::mysql::st DESTROY failed on OpenBSD #120

Closed
glasswalk3r opened this issue Apr 13, 2017 · 27 comments

Comments

Projects
None yet
5 participants
@glasswalk3r
Copy link

commented Apr 13, 2017

Some tests from DBD::mysql fail on OpenBSD with different perl versions (5.024001 and 5.020003). Here there are two different reports:

Both failed with the same errors:

DBD::mysql::st DESTROY failed: ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß

And this "beta" character goes on in very long lines.

It is important to note that MySQL is not indeed available on OpenBSD 6.0 by default, but MariaDB is installed instead:

# mysql_clientinfo is: 10.0.25-MariaDB
# mysql_clientversion is: 100025
# mysql_serverversion is: 100025
# mysql_hostinfo is: Localhost via UNIX socket
# mysql_serverinfo is: 10.0.25-MariaDB
# mysql_stat is: Uptime: 1806  Threads: 1  Questions: 7763  Slow queries: 0  Opens: 430  Flush tables: 1  Open tables: 62  Queries per second avg: 4.298
# mysql_protoinfo is: 10
# SQL_DBMS_VER is 10.0.25-MariaDB
# Default storage engine is: InnoDB

I also have reports from this same CPAN Smoker with PASS and UNKNOWN results, but in both cases the tests were skipped.

@pali

This comment has been minimized.

Copy link
Contributor

commented Apr 14, 2017

Hi! Look at output from test t/40server_prepare_crash.t:

# Your libmysqlclient.so is vulnerable to CVE 2017-3302 and can crash perl

CVE 2017-3302 is about use-after-free in libmysqlclient.so in function called from mysql_close(). As some garbage comes from perl DESTROY, I bet it is because of that use-after-free in mysql_close(). Use-after-free does not have to crash process, but something other undefined can happen (based on implementation of malloc or operating system)...

I tried to create test t/cve-2017-3302.t which sometimes can trigger CVE 2017-3302 problem and I see that it failed too in your report. CVE 2017-3302 is not related to DBD::mysql and DBD::mysql cannot do nothing with broken underlaying libmysqlclient.so. Just failed tests (if trigger this problem) can inform users about problems.

So fix CVE 2017-3302 in your system, as any application which uses libmysqlclient.so can randomly crash at cleanup time.

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 14, 2017

Thanks!
Release 6.1 of OpenBSD was released, let me check if there is a newer version of libmysqlclient and test against it, might be necessary to open a bug for them instead.

@pali

This comment has been minimized.

Copy link
Contributor

commented Apr 15, 2017

Yes, for CVE 2017-3302 you should open bug to OpenBSD if they distribute vulnerable library which crashes perl.

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 15, 2017

Tested on OpenBSD 6.1:

-bash-4.3$ make test
"/home/foo/perl5/perlbrew/perls/perl-5.20.3/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
PERL_DL_NONLAZY=1 "/home/foo/perl5/perlbrew/perls/perl-5.20.3/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .............................. 1/6 perl:/usr/lib/libcrypto.so.41.1: undefined symbol 'recallocarray'
perl:/usr/lib/libssl.so.43.2: undefined symbol 'recallocarray'
perl:/usr/lib/libpthread.so.23.0: undefined symbol '_malloc_init'
# Driver version is 4.042
t/00base.t .............................. ok   
t/05dbcreate.t .......................... perl:/usr/lib/libcrypto.so.41.1: undefined symbol 'recallocarray'
perl:/usr/lib/libssl.so.43.2: undefined symbol 'recallocarray'
perl:/usr/lib/libpthread.so.23.0: undefined symbol '_malloc_init'
t/05dbcreate.t .......................... 1/2 # Database 'test' accessible
t/05dbcreate.t .......................... ok   
t/10connect.t ........................... perl:/usr/lib/libcrypto.so.41.1: undefined symbol 'recallocarray'
perl:/usr/lib/libssl.so.43.2: undefined symbol 'recallocarray'
perl:/usr/lib/libpthread.so.23.0: undefined symbol '_malloc_init'
t/10connect.t ........................... 1/? # mysql_clientinfo is: 10.0.30-MariaDB
# mysql_clientversion is: 100030
# mysql_serverversion is: 100030
# mysql_hostinfo is: Localhost via UNIX socket
# mysql_serverinfo is: 10.0.30-MariaDB
# mysql_stat is: Uptime: 1051  Threads: 2  Questions: 5194  Slow queries: 0  Opens: 288  Flush tables: 1  Open tables: 62  Queries per second avg: 4.941
# mysql_protoinfo is: 10
# SQL_DBMS_VER is 10.0.30-MariaDB
# Default storage engine is: InnoDB
t/10connect.t ........................... ok    
t/15reconnect.t ......................... perl:/usr/lib/libcrypto.so.41.1: undefined symbol 'recallocarray'
perl:/usr/lib/libssl.so.43.2: undefined symbol 'recallocarray'
perl:/usr/lib/libpthread.so.23.0: undefined symbol '_malloc_init'
t/15reconnect.t ......................... 1/26 DBD::mysql::st DESTROY failed: ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ��q6.
t/15reconnect.t ......................... ok     
# and goes on with warnings about "undefined symbol 'recallocarray'"
t/version.t ............................. perl:/usr/lib/libcrypto.so.41.1: undefined symbol 'recallocarray'
perl:/usr/lib/libssl.so.43.2: undefined symbol 'recallocarray'
perl:/usr/lib/libpthread.so.23.0: undefined symbol '_malloc_init'
t/version.t ............................. ok   
All tests successful.
Files=74, Tests=3070, 41 wallclock secs ( 0.41 usr  0.80 sys +  6.74 cusr  2.99 csys = 10.94 CPU)
Result: PASS

All tests PASSed, but I'm not sure about this error with DESTROY coming up.

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 15, 2017

Another thing I noticed, but I'm not sure it the instructions are wrong or I did something incorrect:

PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'foo' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.

mysql> grant all privileges on test.* to 'foo'@'localhost' identified by 's3kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.PL --testuser=username

I will use the following settings for compiling and testing:

  cflags        (mysql_config) = -I/usr/local/include/mysql -I/usr/local/include/mysql/..
  embedded      (mysql_config) = 
  ldflags       (guessed     ) = 
  libs          (mysql_config) = -L/usr/local/lib/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto
  mysql_config  (guessed     ) = mysql_config
  nocatchstderr (default     ) = 0
  nofoundrows   (default     ) = 0
  nossl         (default     ) = 0
  testdb        (default     ) = test
  testhost      (default     ) = 
  testpassword  (default     ) = 
  testport      (default     ) = 
  testsocket    (default     ) = 
  testuser      (guessed     ) = foo

If I setup the user at Mysql with mysql> grant all privileges on test.* to 'foo'@'localhost' identified by 's3kr1t';, all tests will be skipped because connection will fail). If I setup the user without a password (removing identified by 's3kr1t'), everything works as expected.

@pali

This comment has been minimized.

Copy link
Contributor

commented Apr 15, 2017

Those error messages undefined symbol does not seem to be OK...

And you need to specify username and password via --testuser and --testpassword to match what you set in MySQL.

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 15, 2017

I'm not a C programmer myself, but if I would have to guess, those two first warnings:

perl:/usr/lib/libcrypto.so.41.1: undefined symbol 'recallocarray'
perl:/usr/lib/libssl.so.43.2: undefined symbol 'recallocarray'
perl:/usr/lib/libpthread.so.23.0: undefined symbol '_malloc_init'

Might be related to the fact that OpenBSD doesn't use OpenSSL (they created LibreSSL to replace it).
Can't say anything about the __malloc_init although...
Hmm... I didn't specify the user with --testuser but it worked the same way...
Let me know if you want me to run more tests... I'm still have to check how to open a bug for OpenBSD 6.0

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 15, 2017

New batch of tests executed, this time with:

-bash-4.3$ perl -v
This is perl 5, version 25, subversion 11 (v5.25.11) built for OpenBSD.amd64-openbsd

This time I tried to enable all tests, including optional dependencies. You will notice that the both tests t/15reconnect.t and t/rt86153-reconnect-fail-memory.t fails with DESTROY, but Test::Harness only identified a problem with the later (probably because of Proc::ProcessTable::Process).

I tested this once inside the CPAN shell, it presented an error with test t/15reconnect.t. I went out and back of CPAN shell and repeated the test, this time with a PASS.

I executed the following test from a Bash shell, not using CPAN or cpanm:

-bash-4.3$ perl Makefile.PL


PLEASE NOTE:

For 'make test' to run properly, you must ensure that the
database user 'foo' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.

mysql> grant all privileges on test.* to 'foo'@'localhost' identified by 's3kr1t';

You can also optionally set the user to run 'make test' with:

perl Makefile.PL --testuser=username

I will use the following settings for compiling and testing:

  cflags        (mysql_config) = -I/usr/local/include/mysql -I/usr/local/include/mysql/..
  embedded      (mysql_config) = 
  ldflags       (guessed     ) = 
  libs          (mysql_config) = -L/usr/local/lib/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto
  mysql_config  (guessed     ) = mysql_config
  nocatchstderr (default     ) = 0
  nofoundrows   (default     ) = 0
  nossl         (default     ) = 0
  testdb        (default     ) = test
  testhost      (default     ) = 
  testpassword  (default     ) = 
  testport      (default     ) = 
  testsocket    (default     ) = 
  testuser      (guessed     ) = foo

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Looks good.

Checking if your kit is complete...
Looks good
Using DBI 1.636 (for perl 5.025011 on OpenBSD.amd64-openbsd) installed in /home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/site_perl/5.25.11/OpenBSD.amd64-openbsd/auto/DBI/
Generating a Unix-style Makefile
Writing Makefile for DBD::mysql
Writing MYMETA.yml and MYMETA.json
-bash-4.3$ 

-bash-4.3$ make
cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
Running Mkbootstrap for mysql ()
chmod 644 "mysql.bs"
"/home/foo/perl5/perlbrew/perls/perl-5.25.11/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
cc -c  -I/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/site_perl/5.25.11/OpenBSD.amd64-openbsd/auto/DBI -I/usr/local/include/mysql -I/usr/local/include/mysql/.. -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_IS_GOOD -g   -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -O2    -DVERSION=\"4.042\"  -DXS_VERSION=\"4.042\" -DPIC -fPIC  "-I/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/5.25.11/OpenBSD.amd64-openbsd/CORE"   dbdimp.c
dbdimp.c: In function 'alloc_param':
dbdimp.c:289: warning: comparison is always false due to limited range of data type
dbdimp.c: In function 'alloc_bind':
dbdimp.c:307: warning: comparison is always false due to limited range of data type
dbdimp.c: In function 'alloc_fbind':
dbdimp.c:323: warning: comparison is always false due to limited range of data type
dbdimp.c: In function 'alloc_fbuffer':
dbdimp.c:338: warning: comparison is always false due to limited range of data type
"/home/foo/perl5/perlbrew/perls/perl-5.25.11/bin/perl" -p -e "s/~DRIVER~/mysql/g" /home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/site_perl/5.25.11/OpenBSD.amd64-openbsd/auto/DBI/Driver.xst > mysql.xsi
"/home/foo/perl5/perlbrew/perls/perl-5.25.11/bin/perl" "/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/5.25.11/ExtUtils/xsubpp"  -typemap '/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/5.25.11/ExtUtils/typemap'  mysql.xs > mysql.xsc
Warning: duplicate function definition 'do' detected in mysql.xs, line 273
Warning: duplicate function definition 'rows' detected in mysql.xs, line 689
mv mysql.xsc mysql.c
cc -c  -I/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/site_perl/5.25.11/OpenBSD.amd64-openbsd/auto/DBI -I/usr/local/include/mysql -I/usr/local/include/mysql/.. -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_IS_GOOD -g   -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -O2    -DVERSION=\"4.042\"  -DXS_VERSION=\"4.042\" -DPIC -fPIC  "-I/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/5.25.11/OpenBSD.amd64-openbsd/CORE"   mysql.c
mysql.xs: In function 'XS_DBD__mysql__db_do':
mysql.xs:407: warning: comparison is always false due to limited range of data type
cc -c  -I/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/site_perl/5.25.11/OpenBSD.amd64-openbsd/auto/DBI -I/usr/local/include/mysql -I/usr/local/include/mysql/.. -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_IS_GOOD -g   -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -O2    -DVERSION=\"4.042\"  -DXS_VERSION=\"4.042\" -DPIC -fPIC  "-I/home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/5.25.11/OpenBSD.amd64-openbsd/CORE"   socket.c
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/usr/local/lib/mysql:/usr/lib" cc  -shared -fPIC  -L/usr/local/lib -fstack-protector-strong dbdimp.o  mysql.o  socket.o  -o blib/arch/auto/DBD/mysql/mysql.so    -L/usr/local/lib/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto    
chmod 755 blib/arch/auto/DBD/mysql/mysql.so
-bash-4.3$ 

-bash-4.3$ make test   
"/home/foo/perl5/perlbrew/perls/perl-5.25.11/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
PERL_DL_NONLAZY=1 "/home/foo/perl5/perlbrew/perls/perl-5.25.11/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .............................. 2/6 # Driver version is 4.042
t/00base.t .............................. ok   
t/05dbcreate.t .......................... 1/2 # Database 'test' accessible
t/05dbcreate.t .......................... ok   
t/10connect.t ........................... 1/? # mysql_clientinfo is: 10.0.30-MariaDB
# mysql_clientversion is: 100030
# mysql_serverversion is: 100030
# mysql_hostinfo is: Localhost via UNIX socket
# mysql_serverinfo is: 10.0.30-MariaDB
# mysql_stat is: Uptime: 35108  Threads: 1  Questions: 20651  Slow queries: 0  Opens: 1140  Flush tables: 1  Open tables: 62  Queries per second avg: 0.588
# mysql_protoinfo is: 10
# SQL_DBMS_VER is 10.0.30-MariaDB
# Default storage engine is: InnoDB
t/10connect.t ........................... ok    
t/15reconnect.t ......................... 1/26 DBD::mysql::st DESTROY failed: �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� at t/15reconnect.t line 21.
        (in cleanup) DBD::mysql::st DESTROY failed: �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� at t/15reconnect.t line 21.
t/15reconnect.t ......................... ok     
t/16dbi-get_info.t ...................... ok   
t/20createdrop.t ........................ ok   
t/25lockunlock.t ........................ ok     
t/29warnings.t .......................... ok     
t/30insertfetch.t ....................... ok    
t/31insertid.t .......................... ok     
t/32insert_error.t ...................... ok   
t/35limit.t ............................. ok       
t/35prepare.t ........................... ok     
t/40bindparam.t ......................... ok     
t/40bindparam2.t ........................ ok     
t/40bit.t ............................... ok     
t/40blobs.t ............................. ok     
t/40catalog.t ........................... ok     
t/40keyinfo.t ........................... ok   
t/40listfields.t ........................ ok     
t/40nulls.t ............................. ok     
t/40nulls_prepare.t ..................... ok    
t/40numrows.t ........................... ok     
t/40server_prepare.t .................... ok     
t/40server_prepare_crash.t .............. ok     
t/40server_prepare_error.t .............. ok   
t/40types.t ............................. ok     
t/41bindparam.t ......................... ok     
t/41blobs_prepare.t ..................... ok     
t/41int_min_max.t ....................... ok       
t/42bindparam.t ......................... ok     
t/43count_params.t ...................... ok     
t/50chopblanks.t ........................ ok     
t/50commit.t ............................ ok     
t/51bind_type_guessing.t ................ ok     
t/52comment.t ........................... ok     
t/53comment.t ........................... ok    
t/55utf8.t .............................. ok       
t/55utf8_jp.t ........................... ok     
t/55utf8mb4.t ........................... ok    
t/56connattr.t .......................... skipped: performance schema not enabled
t/60leaks.t ............................. 1/54 Can't access `size' field in class Proc::ProcessTable::Process at t/60leaks.t line 39.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle test at /home/foo/perl5/perlbrew/perls/perl-5.25.11/lib/5.25.11/Carp.pm line 167.
# Looks like your test exited with 25 just after 2.
t/60leaks.t ............................. Dubious, test returned 25 (wstat 6400, 0x1900)
Failed 52/54 subtests 
t/65segfault.t .......................... ok   
t/65types.t ............................. ok     
t/70takeimp.t ........................... ok     
t/71impdata.t ........................... ok     
t/75supported_sql.t ..................... ok     
t/76multi_statement.t ................... ok     
t/80procs.t ............................. ok     
t/81procs.t ............................. ok     
t/85init_command.t ...................... ok   
t/86_bug_36972.t ........................ ok     
t/87async.t ............................. ok     
t/88async-multi-stmts.t ................. ok   
t/89async-method-check.t ................ ok       
t/90utf8_params.t ....................... ok     
t/91errcheck.t .......................... ok   
t/99_bug_server_prepare_blob_null.t ..... ok     
t/cve-2017-3302.t ....................... ok   
t/magic.t ............................... ok       
t/manifest.t ............................ skipped: these tests are for release testing
t/pod.t ................................. ok   
t/rt110983-valid-mysqlfd.t .............. ok   
t/rt118977-zerofill.t ................... ok   
t/rt25389-bin-case.t .................... ok   
t/rt50304-column_info_parentheses.t ..... ok    
t/rt61849-bind-param-buffer-overflow.t .. ok   
t/rt75353-innodb-lock-timeout.t ......... ok   
t/rt83494-quotes-comments.t ............. ok   
t/rt85919-fetch-lost-connection.t ....... ok   
t/rt86153-reconnect-fail-memory.t ....... Can't access `size' field in class Proc::ProcessTable::Process at t/rt86153-reconnect-fail-memory.t line 33.
# Looks like your test exited with 25 before it could output anything.
t/rt86153-reconnect-fail-memory.t ....... Dubious, test returned 25 (wstat 6400, 0x1900)
Failed 3/3 subtests 
t/rt88006-bit-prepare.t ................. ok    
t/rt91715.t ............................. ok   
t/version.t ............................. ok   

Test Summary Report
-------------------
t/60leaks.t                           (Wstat: 6400 Tests: 2 Failed: 0)
  Non-zero exit status: 25
  Parse errors: Bad plan.  You planned 54 tests but ran 2.
t/rt86153-reconnect-fail-memory.t     (Wstat: 6400 Tests: 0 Failed: 0)
  Non-zero exit status: 25
  Parse errors: Bad plan.  You planned 3 tests but ran 0.
Files=74, Tests=3072, 42 wallclock secs ( 0.44 usr  0.85 sys +  7.20 cusr  3.28 csys = 11.77 CPU)
Result: FAIL
Failed 2/74 test programs. 0/3072 subtests failed.
*** Error 255 in /mnt/cpan_build_dir/foo/DBD-mysql-4.042-0 (Makefile:1178 'test_dynamic')
@pali

This comment has been minimized.

Copy link
Contributor

commented Apr 15, 2017

Tests t/60leaks.t and t/rt86153-reconnect-fail-memory.t fails because of error "Can't access `size' field in class Proc::ProcessTable::Process" from Proc::ProcessTable module.

According to readme file of that module, size field is really not supported on OpenBSD, but is required for those two tests

https://metacpan.org/source/JWB/Proc-ProcessTable-0.53/README.openbsd

Here is simple patch which check for support of size attribute and skip whole tests if is not supported:


diff --git a/t/60leaks.t b/t/60leaks.t
index aaa77ac..b1239ad 100644
--- a/t/60leaks.t
+++ b/t/60leaks.t
@@ -25,6 +25,11 @@ if ($@) {
 eval { require Storable };
 $have_storable = $@ ? 0 : 1;
 
+my $have_pt_size = grep { $_ eq 'size' } Proc::ProcessTable->new('cache_ttys' => $have_storable)->fields;
+if (!$have_pt_size) {
+        plan skip_all => "module Proc::ProcessTable does not support size attribute on current platform \n";
+}
+
 my ($dbh, $sth);
 $dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
                                             { RaiseError => 1, PrintError => 1, AutoCommit => 0 });
diff --git a/t/rt86153-reconnect-fail-memory.t b/t/rt86153-reconnect-fail-memory.t
index aa331e1..bb1c293 100644
--- a/t/rt86153-reconnect-fail-memory.t
+++ b/t/rt86153-reconnect-fail-memory.t
@@ -23,6 +23,11 @@ if ($@) {
 eval { require Storable };
 $have_storable = $@ ? 0 : 1;
 
+my $have_pt_size = grep { $_ eq 'size' } Proc::ProcessTable->new('cache_ttys' => $have_storable)->fields;
+if (!$have_pt_size) {
+    plan skip_all => "module Proc::ProcessTable does not support size attribute on current platform \n";
+}
+
 plan tests => 3;
 
 sub size {

And about ����� message. It is really a problem despite fact that test passed. It looks like some memory corruption, but I have no idea now. Test t/40server_prepare_crash.t and also t/cve-2017-3302.t passed, so it is now not related to cve-2017-3302.

What seems to be problematic is that compile time warning: comparison is always false due to limited range of data type.

Do you have some memory checker tool available on OpenBSD? Like valgrind which is available for Linux. I have no other idea, just try to detect memory corruptions...

We have a big test coverage against different MariaDB and MySQL versions and also different Perl versions, but there was no fail for 4.042 version: https://travis-ci.org/perl5-dbi/DBD-mysql/builds/209109357 (at least not on Linux).

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 17, 2017

I'll need to search for memory corruption checking on OpenBSD, I have no idea.
Anyway, I got some help from the mailing list:

The local perl build that is showing "undefined symbol 'recallocarray'"
is broken.

The "DBD::mysql::st DESTROY failed: \xdf\xdf\xdf[...]" suggest a use-after-free
and I do reproduce this in -current. See the explanation of 'j "Less junking"
in http://man.openbsd.org/malloc.conf.

Not sure how I generated "broken" perls over there, but I'll check for documentation regarding compiling a perl on OpenBSD.

Regarding the malloc, I don't know if this clears out anything to you... I'm not a C programmer myself.

I tested that patch of your for Proc::ProcessTable... it worked, and it's looking fine now:

t/56connattr.t .......................... skipped: performance schema not enabled
t/60leaks.t ............................. skipped: module Proc::ProcessTable does not support size attribute on current platform
t/65segfault.t .......................... ok   
t/65types.t ............................. ok     
t/70takeimp.t ........................... ok     
t/71impdata.t ........................... ok     
t/75supported_sql.t ..................... ok     
t/76multi_statement.t ................... ok     
t/80procs.t ............................. ok     
t/81procs.t ............................. ok     
t/85init_command.t ...................... ok   
t/86_bug_36972.t ........................ ok     
t/87async.t ............................. ok     
t/88async-multi-stmts.t ................. ok   
t/89async-method-check.t ................ ok       
t/90utf8_params.t ....................... ok     
t/91errcheck.t .......................... ok   
t/99_bug_server_prepare_blob_null.t ..... ok     
t/cve-2017-3302.t ....................... ok   
t/magic.t ............................... ok       
t/manifest.t ............................ skipped: these tests are for release testing
t/pod.t ................................. ok   
t/rt110983-valid-mysqlfd.t .............. ok   
t/rt118977-zerofill.t ................... ok   
t/rt25389-bin-case.t .................... ok   
t/rt50304-column_info_parentheses.t ..... ok    
t/rt61849-bind-param-buffer-overflow.t .. ok   
t/rt75353-innodb-lock-timeout.t ......... ok   
t/rt83494-quotes-comments.t ............. ok   
t/rt85919-fetch-lost-connection.t ....... ok   
t/rt86153-reconnect-fail-memory.t ....... skipped: module Proc::ProcessTable does not support size attribute on current platform
t/rt88006-bit-prepare.t ................. ok    
@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 17, 2017

Based on the answer from OpenBSD MISC list, I tried using the standard perl with a new user with local::lib configured. I didn't installed anything but DBI and DBD::mysql (with required dependencies).

It not only fails with the same errors regarding DBD::mysql::st DESTROY, but also a test failed because lacking of having Test::Deep installed (undeclared dependency?).

Here are the details:

bash-4.3$ perl Makefile.PL --testuser=foo
I will use the following settings for compiling and testing:

  cflags        (mysql_config ) = -I/usr/local/include/mysql -I/usr/local/include/mysql/..
  embedded      (mysql_config ) = 
  ldflags       (guessed      ) = 
  libs          (mysql_config ) = -L/usr/local/lib/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto
  mysql_config  (guessed      ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  nossl         (default      ) = 0
  testdb        (User's choice) = test
  testhost      (default      ) = 
  testpassword  (default      ) = 
  testport      (default      ) = 
  testsocket    (default      ) = 
  testuser      (User's choice) = foo

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Looks good.

Checking if your kit is complete...
Looks good
Multiple copies of Driver.xst found in: /home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI/ /usr/local/libdata/perl5/site_perl/amd64-openbsd/auto/DBI/ at Makefile.PL line 859.
Using DBI 1.636 (for perl 5.024001 on amd64-openbsd) installed in /home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI/
Generating a Unix-style Makefile
Writing Makefile for DBD::mysql
Writing MYMETA.yml and MYMETA.json
bash-4.3$ make
cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm
Running Mkbootstrap for DBD::mysql ()
chmod 644 "mysql.bs"
cc -c  -I/home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI -I/usr/local/include/mysql -I/usr/local/include/mysql/.. -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_IS_GOOD -g   -DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2 -I/usr/local/include -O2    -DVERSION=\"4.042\"  -DXS_VERSION=\"4.042\" -DPIC -fPIC  "-I/usr/libdata/perl5/amd64-openbsd/CORE"   dbdimp.c
dbdimp.c: In function 'alloc_param':
dbdimp.c:289: warning: comparison is always false due to limited range of data type
dbdimp.c: In function 'alloc_bind':
dbdimp.c:307: warning: comparison is always false due to limited range of data type
dbdimp.c: In function 'alloc_fbind':
dbdimp.c:323: warning: comparison is always false due to limited range of data type
dbdimp.c: In function 'alloc_fbuffer':
dbdimp.c:338: warning: comparison is always false due to limited range of data type
"/usr/bin/perl" -p -e "s/~DRIVER~/mysql/g" /home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI/Driver.xst > mysql.xsi
"/usr/bin/perl" "/usr/libdata/perl5/ExtUtils/xsubpp"  -typemap "/usr/libdata/perl5/ExtUtils/typemap"  mysql.xs > mysql.xsc && mv mysql.xsc mysql.c
Warning: duplicate function definition 'do' detected in mysql.xs, line 273
Warning: duplicate function definition 'rows' detected in mysql.xs, line 689
cc -c  -I/home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI -I/usr/local/include/mysql -I/usr/local/include/mysql/.. -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_IS_GOOD -g   -DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2 -I/usr/local/include -O2    -DVERSION=\"4.042\"  -DXS_VERSION=\"4.042\" -DPIC -fPIC  "-I/usr/libdata/perl5/amd64-openbsd/CORE"   mysql.c
mysql.xs: In function 'XS_DBD__mysql__db_do':
mysql.xs:407: warning: comparison is always false due to limited range of data type
cc -c  -I/home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI -I/usr/local/include/mysql -I/usr/local/include/mysql/.. -DDBD_MYSQL_WITH_SSL -DDBD_MYSQL_INSERT_ID_IS_GOOD -g   -DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2 -I/usr/local/include -O2    -DVERSION=\"4.042\"  -DXS_VERSION=\"4.042\" -DPIC -fPIC  "-I/usr/libdata/perl5/amd64-openbsd/CORE"   socket.c
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/usr/local/lib/mysql:/usr/lib" cc  -shared -fPIC  -fstack-protector-strong -L/usr/local/lib dbdimp.o  mysql.o  socket.o  -o blib/arch/auto/DBD/mysql/mysql.so        -L/usr/local/lib/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto          
chmod 755 blib/arch/auto/DBD/mysql/mysql.so
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
Manifying 3 pod documents
bash-4.3$ make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .............................. 1/6 # Driver version is 4.042
t/00base.t .............................. ok   
t/05dbcreate.t .......................... 1/2 # Database 'test' accessible
t/05dbcreate.t .......................... ok   
t/10connect.t ........................... 1/? # mysql_clientinfo is: 10.0.30-MariaDB
# mysql_clientversion is: 100030
# mysql_serverversion is: 100030
# mysql_hostinfo is: Localhost via UNIX socket
# mysql_serverinfo is: 10.0.30-MariaDB
# mysql_stat is: Uptime: 358  Threads: 1  Questions: 5  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 63  Queries per second avg: 0.013
# mysql_protoinfo is: 10
# SQL_DBMS_VER is 10.0.30-MariaDB
# Default storage engine is: InnoDB
t/10connect.t ........................... ok    
t/15reconnect.t ......................... 1/26 DBD::mysql::st DESTROY failed: ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������`�8��� at t/15reconnect.t line 21.
        (in cleanup) DBD::mysql::st DESTROY failed: ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������`�8��� at t/15reconnect.t line 21.
t/15reconnect.t ......................... ok     
t/16dbi-get_info.t ...................... ok   
t/20createdrop.t ........................ ok   
t/25lockunlock.t ........................ ok     
t/29warnings.t .......................... ok     
t/30insertfetch.t ....................... ok    
t/31insertid.t .......................... ok     
t/32insert_error.t ...................... ok   
t/35limit.t ............................. ok       
t/35prepare.t ........................... ok     
t/40bindparam.t ......................... ok     
t/40bindparam2.t ........................ ok     
t/40bit.t ............................... ok     
t/40blobs.t ............................. ok     
t/40catalog.t ........................... ok     
t/40keyinfo.t ........................... ok   
t/40listfields.t ........................ ok     
t/40nulls.t ............................. ok     
t/40nulls_prepare.t ..................... ok    
t/40numrows.t ........................... ok     
t/40server_prepare.t .................... ok     
t/40server_prepare_crash.t .............. ok     
t/40server_prepare_error.t .............. ok   
t/40types.t ............................. ok     
t/41bindparam.t ......................... ok     
t/41blobs_prepare.t ..................... ok     
t/41int_min_max.t ....................... ok       
t/42bindparam.t ......................... ok     
t/43count_params.t ...................... ok     
t/50chopblanks.t ........................ ok     
t/50commit.t ............................ ok     
t/51bind_type_guessing.t ................ ok     
t/52comment.t ........................... ok     
t/53comment.t ........................... ok    
t/55utf8.t .............................. ok       
t/55utf8_jp.t ........................... ok     
t/55utf8mb4.t ........................... ok    
t/56connattr.t .......................... skipped: performance schema not enabled
t/60leaks.t ............................. skipped: Skip $ENV{EXTENDED_TESTING} is not set
t/65segfault.t .......................... ok   
t/65types.t ............................. ok     
t/70takeimp.t ........................... ok     
t/71impdata.t ........................... ok     
t/75supported_sql.t ..................... ok     
t/76multi_statement.t ................... ok     
t/80procs.t ............................. ok     
t/81procs.t ............................. ok     
t/85init_command.t ...................... ok   
t/86_bug_36972.t ........................ ok     
t/87async.t ............................. Can't locate Test/Deep.pm in @INC (you may need to install the Test::Deep module) (@INC contains: /home/harry/.cpan/build/DBD-mysql-4.042-9MNeq6/blib/lib /home/harry/.cpan/build/DBD-mysql-4.042-9MNeq6/blib/arch /home/harry/perl5/lib/perl5/5.24.1/amd64-openbsd /home/harry/perl5/lib/perl5/5.24.1/amd64-openbsd /home/harry/perl5/lib/perl5/5.24.1 /home/harry/perl5/lib/perl5/amd64-openbsd /home/harry/perl5/lib/perl5/5.24.1/amd64-openbsd /home/harry/perl5/lib/perl5/5.24.1 /home/harry/perl5/lib/perl5/amd64-openbsd /home/harry/perl5/lib/perl5 /home/harry/perl5/lib/perl5/5.24.1/amd64-openbsd /home/harry/perl5/lib/perl5/5.24.1 /home/harry/perl5/lib/perl5/amd64-openbsd /home/harry/perl5/lib/perl5 /usr/local/libdata/perl5/site_perl/amd64-openbsd /usr/local/libdata/perl5/site_perl /usr/libdata/perl5/amd64-openbsd /usr/libdata/perl5 .) at t/87async.t line 4.
BEGIN failed--compilation aborted at t/87async.t line 4.
t/87async.t ............................. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/88async-multi-stmts.t ................. ok   
t/89async-method-check.t ................ ok       
t/90utf8_params.t ....................... ok     
t/91errcheck.t .......................... ok   
t/99_bug_server_prepare_blob_null.t ..... ok     
t/cve-2017-3302.t ....................... ok   
t/magic.t ............................... ok       
t/manifest.t ............................ skipped: these tests are for release testing
t/pod.t ................................. skipped: Test::Pod 1.00 required for testing POD
t/rt110983-valid-mysqlfd.t .............. ok   
t/rt118977-zerofill.t ................... ok   
t/rt25389-bin-case.t .................... ok   
t/rt50304-column_info_parentheses.t ..... ok    
t/rt61849-bind-param-buffer-overflow.t .. ok   
t/rt75353-innodb-lock-timeout.t ......... ok   
t/rt83494-quotes-comments.t ............. ok   
t/rt85919-fetch-lost-connection.t ....... ok   
t/rt86153-reconnect-fail-memory.t ....... skipped: $ENV{EXTENDED_TESTING} is not set
t/rt88006-bit-prepare.t ................. ok    
t/rt91715.t ............................. ok   
t/version.t ............................. ok   

Test Summary Report
-------------------
t/87async.t                           (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
Files=74, Tests=2974, 23 wallclock secs ( 0.50 usr  0.89 sys +  4.99 cusr  3.64 csys = 10.02 CPU)
Result: FAIL
Failed 1/74 test programs. 0/2974 subtests failed.
*** Error 255 in /home/harry/.cpan/build/DBD-mysql-4.042-9MNeq6 (Makefile:1177 'test_dynamic')
@pali

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2017

I tested that patch of your for Proc::ProcessTable... it worked, and it's looking fine now:

Ok, I will create pull request with that patch.

Regarding the malloc, I don't know if this clears out anything to you... I'm not a C programmer myself.
The "DBD::mysql::st DESTROY failed: \xdf\xdf\xdf[...]" suggest a use-after-free and I do reproduce this in -current.

I think there is some memory problem too. But I cannot reproduce it on Linux, and our automated tests with MariaDB and MySQL on Travis-CI and AppVeyor (Windows) have not shown this problem. So it is hard for me to say where is problem if I have only above "garbage" output. Somebody with knowledge of your system needs to look deeply at it...

I didn't installed anything but DBI and DBD::mysql (with required dependencies).

Test::Deep is needed to run t/87async.t test and that module is specified in META.json/META.yml as test dependency. So you probably not installed all needed dependences.

pali added a commit to pali/DBD-mysql that referenced this issue Apr 17, 2017

Tests with Proc::ProcessTable module needs size attribute
Do needed check for size attribute at tests startup.

Fixes some tests failure on OpenBSD:

t/60leaks.t ............................. Can't access `size' field in class Proc::ProcessTable::Process at t/60leaks.t line 39.
t/60leaks.t ............................. Dubious, test returned 25 (wstat 6400, 0x1900)

t/rt86153-reconnect-fail-memory.t ....... Can't access `size' field in class Proc::ProcessTable::Process at t/rt86153-reconnect-fail-memory.t line 33.
t/rt86153-reconnect-fail-memory.t ....... Dubious, test returned 25 (wstat 6400, 0x1900)

See: perl5-dbi#120

pali added a commit to pali/DBD-mysql that referenced this issue Apr 17, 2017

Tests with Proc::ProcessTable module needs size attribute
Do needed check for size attribute at tests startup.

Fixes some tests failure on OpenBSD:

t/60leaks.t ............................. Can't access `size' field in class Proc::ProcessTable::Process at t/60leaks.t line 39.
t/60leaks.t ............................. Dubious, test returned 25 (wstat 6400, 0x1900)

t/rt86153-reconnect-fail-memory.t ....... Can't access `size' field in class Proc::ProcessTable::Process at t/rt86153-reconnect-fail-memory.t line 33.
t/rt86153-reconnect-fail-memory.t ....... Dubious, test returned 25 (wstat 6400, 0x1900)

See: perl5-dbi#120
@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Apr 17, 2017

I think there is some memory problem too. But I cannot reproduce it on Linux, and our automated tests with MariaDB and MySQL on Travis-CI and AppVeyor (Windows) have not shown this problem. So it is hard for me to say where is problem if I have only above "garbage" output. Somebody with knowledge of your system needs to look deeply at it...

I'll try to work further within the MISC mailing list. One good thing is that I'm not getting the "undefined symbol 'recallocarray'" errors anymore, they were happening due the fact I didn't recompile perl after the OpenBSD upgrade from 6.0 to 6.1.

Test::Deep is needed to run t/87async.t test and that module is specified in META.json/META.yml as test dependency. So you probably not installed all needed dependences.

True enough, it is included in the Makefile.PL as well:

-bash-4.3$ grep -B 4 Test::Deep Makefile.PL
        'zentooo <ankerasoy@gmail.com>',
      ],
    },
    TEST_REQUIRES => { 'Test::Simple' => '0.90',
                       'Test::Deep'   => 0,

Don't get a warning from running the Makefile.PL, but I guess this is the default behavior for TEST_REQUIRES dependencies:

-bash-4.3$ perl Makefile.PL --testuser=foo
I will use the following settings for compiling and testing:

  cflags        (mysql_config ) = -I/usr/local/include/mysql -I/usr/local/include/mysql/..
  embedded      (mysql_config ) = 
  ldflags       (guessed      ) = 
  libs          (mysql_config ) = -L/usr/local/lib/mysql -lmysqlclient -lpthread -lz -lm -lssl -lcrypto
  mysql_config  (guessed      ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  nossl         (default      ) = 0
  testdb        (User's choice) = test
  testhost      (default      ) = 
  testpassword  (default      ) = 
  testport      (default      ) = 
  testsocket    (default      ) = 
  testuser      (User's choice) = foo

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Looks good.

Checking if your kit is complete...
Looks good
Multiple copies of Driver.xst found in: /home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI/ /usr/local/libdata/perl5/site_perl/amd64-openbsd/auto/DBI/ at Makefile.PL line 859.
Using DBI 1.636 (for perl 5.024001 on amd64-openbsd) installed in /home/harry/perl5/lib/perl5/amd64-openbsd/auto/DBI/
Generating a Unix-style Makefile
Writing Makefile for DBD::mysql
Writing MYMETA.yml and MYMETA.json

Test pass after installing Test::Deep as expected:

t/87async.t ............................. ok     
t/88async-multi-stmts.t ................. ok   
t/89async-method-check.t ................ ok       
t/90utf8_params.t ....................... ok     
t/91errcheck.t .......................... ok   
t/99_bug_server_prepare_blob_null.t ..... ok     
t/cve-2017-3302.t ....................... ok   
t/magic.t ............................... ok       
t/manifest.t ............................ skipped: these tests are for release testing
t/pod.t ................................. skipped: Test::Pod 1.00 required for testing POD
t/rt110983-valid-mysqlfd.t .............. ok   
t/rt118977-zerofill.t ................... ok   
t/rt25389-bin-case.t .................... ok   
t/rt50304-column_info_parentheses.t ..... ok    
t/rt61849-bind-param-buffer-overflow.t .. ok   
t/rt75353-innodb-lock-timeout.t ......... ok   
t/rt83494-quotes-comments.t ............. ok   
t/rt85919-fetch-lost-connection.t ....... ok   
t/rt86153-reconnect-fail-memory.t ....... skipped: $ENV{EXTENDED_TESTING} is not set
t/rt88006-bit-prepare.t ................. ok    
t/rt91715.t ............................. ok   
t/version.t ............................. ok   
All tests successful.
Files=74, Tests=3066, 40 wallclock secs ( 0.38 usr  0.85 sys +  4.76 cusr  3.85 csys =  9.84 CPU)
Result: PASS
@pali

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2017

I'll try to work further within the MISC mailing list.

I sent you email to your address specified in your github profile https://github.com/glasswalk3r Please look at it

Don't get a warning from running the Makefile.PL, but I guess this is the default behavior for TEST_REQUIRES dependencies:

Makefile.PL does not warn or report any error about runtime or test dependences. It generates MYMETA.yml or MYMETA.json file where are all dependences (configure, runtime, test, ...) written and cpan software then can install them. See:

Writing MYMETA.yml and MYMETA.json

@pali

This comment has been minimized.

Copy link
Contributor

commented Jun 8, 2017

Now the issue is open to public. Discussion is at mailing list:
http://seclists.org/oss-sec/2017/q2/443

Problem is Oracle's documentation or implementation of mysql_stmt_close() which cause use-after-free defect. And then error described in the first post.

@pali

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2017

To move forward, I requested CVE for this issue.

@pali

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2017

Here is patch which fixes this problem for DBD::mysql:
0001-Fix-use-after-free-after-calling-mysql_stmt_close.patch

@pali

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2017

CVE-2017-10788 was assigned for this issue to DBD::mysql.

@pali

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2017

@agx

This comment has been minimized.

Copy link

commented Aug 28, 2017

@pali Your patch looks unapplied so far, any chance you turn this into PR?

@anarcat

This comment has been minimized.

Copy link

commented Aug 30, 2017

the patch looks right to me, according to the the advisory published on oss-sec, so I made a PR in #142. A question still open is whether e4d456e should be merged back in again, since it was reverted as part of the 4.043 release in 6fd72e5.

@pali

This comment has been minimized.

@anarcat

This comment has been minimized.

Copy link

commented Aug 30, 2017

@pali well i'd be happy to catchup with the fork, but i don't see any repository announced there... did i miss something?

@pali

This comment has been minimized.

Copy link
Contributor

commented Aug 31, 2017

@anarcat As I wrote in that email, maintaining fork is not a simple task and without supporting users and contributing developers it probably does not make sense. So I'm waiting what other people and MariaDB developers say. Anyway, this is now off-topic for this bug report, so move discussion about fork to that mailing list thread.

@mbeijen mbeijen closed this in #142 Sep 3, 2017

@zhouzhen1

This comment has been minimized.

Copy link

commented Nov 23, 2017

@mbeijen When do you expect a new release on CPAN? I am looking for a release with CVE-2017-10788 fixed. Thanks!

@glasswalk3r

This comment has been minimized.

Copy link
Author

commented Dec 14, 2017

Although this issue was closed, I see that both errors are still happening (mostly probably because @pali fork was not applied yet.

Here there are the two reports related to the current DBD::mysql version:

OpenBSD 6.0
OpenBSD 6.1

I suggest to at least separate the patch @pali wrote regarding the Proc::ProcessTable and apply it until there is a decision regarding the CVE-2017-10788:

diff --git a/t/60leaks.t b/t/60leaks.t
index aaa77ac..b1239ad 100644
--- a/t/60leaks.t
+++ b/t/60leaks.t
@@ -25,6 +25,11 @@ if ($@) {
 eval { require Storable };
 $have_storable = $@ ? 0 : 1;
 
+my $have_pt_size = grep { $_ eq 'size' } Proc::ProcessTable->new('cache_ttys' => $have_storable)->fields;
+if (!$have_pt_size) {
+        plan skip_all => "module Proc::ProcessTable does not support size attribute on current platform \n";
+}
+
 my ($dbh, $sth);
 $dbh = DbiTestConnect($test_dsn, $test_user, $test_password,
                                             { RaiseError => 1, PrintError => 1, AutoCommit => 0 });
diff --git a/t/rt86153-reconnect-fail-memory.t b/t/rt86153-reconnect-fail-memory.t
index aa331e1..bb1c293 100644
--- a/t/rt86153-reconnect-fail-memory.t
+++ b/t/rt86153-reconnect-fail-memory.t
@@ -23,6 +23,11 @@ if ($@) {
 eval { require Storable };
 $have_storable = $@ ? 0 : 1;
 
+my $have_pt_size = grep { $_ eq 'size' } Proc::ProcessTable->new('cache_ttys' => $have_storable)->fields;
+if (!$have_pt_size) {
+    plan skip_all => "module Proc::ProcessTable does not support size attribute on current platform \n";
+}
+
 plan tests => 3;
 
 sub size {

I can make a pull request with it if that's the case.

pali added a commit to pali/DBD-MariaDB that referenced this issue Jan 16, 2018

CVE-2017-10788: Fix use-after-free after calling mysql_stmt_close()
Ignore return value from mysql_stmt_close() and also its error message
because it points to freed memory after mysql_stmt_close() was called.

Fixes: perl5-dbi/DBD-mysql#120
@pali

This comment has been minimized.

Copy link
Contributor

commented Jan 23, 2018

@anarcat We finally decided to create a fork: https://github.com/gooddata/DBD-MariaDB which included also patch from this issue. Email with more details: https://www.nntp.perl.org/group/perl.dbi.users/2018/01/msg37584.html

bigio pushed a commit to bigio/DBD-mysql that referenced this issue Jan 9, 2019

Tests with Proc::ProcessTable module needs size attribute
Do needed check for size attribute at tests startup.

Fixes some tests failure on OpenBSD:

t/60leaks.t ............................. Can't access `size' field in class Proc::ProcessTable::Process at t/60leaks.t line 39.
t/60leaks.t ............................. Dubious, test returned 25 (wstat 6400, 0x1900)

t/rt86153-reconnect-fail-memory.t ....... Can't access `size' field in class Proc::ProcessTable::Process at t/rt86153-reconnect-fail-memory.t line 33.
t/rt86153-reconnect-fail-memory.t ....... Dubious, test returned 25 (wstat 6400, 0x1900)

See: perl5-dbi#120

bigio pushed a commit to bigio/DBD-mysql that referenced this issue Jan 9, 2019

Alceu Rodrigues de Freitas Junior Giovanni Bechis
Fixed tests that cannot be executed on OpenBSD
Due dependency on Proc::ProcessTable, the tests changed in this commit
cannot be executed successfully on OpenBSD, thus they will be disabled to
run on that platform until a workaround is available.

For more details, see perl5-dbi#120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.