Bug #81868 pfs_instr-oom unit test fails on MySQL Server 5.7.13
Submitted: 15 Jun 2016 17:06 Modified: 17 Jun 2016 13:00
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:5.7.13 OS:Any
Assigned to: CPU Architecture:Any

[15 Jun 2016 17:06] Yura Sorokin
Description:
'pfs_instr-oom' unit test fails with the following output

*************************************************************************
./mysql-test/mtr --debug-server 1st --unit-tests
Logging: /home/yura/ws/mysql-server/mysql-test/mysql-test-run.pl  --debug-server 1st --unit-tests
MySQL Version 5.7.13
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/yura/ws/mysql-build/mysql-test/var'...
Installing system database...

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
main.1st                                 [ pass ]      5
unit_tests                               [ fail ]
        Test ended at 2016-06-15 19:47:06

ctest failed with exit code 2048, see result below

--------------------------------------------------------------------------

Unit tests: 98% tests passed, 1 tests failed out of 64
  The following tests FAILED:
          6 - pfs_instr-oom (Failed)
Report from unit tests in /home/yura/ws/mysql-build/mysql-test/var/ctest.log
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.005 of 27 seconds executing testcases

Completed: Failed 1/2 tests, 50.00% were successful.

Failing test(s): unit_tests

The log files in var/log may give you some hint of what went wrong.

If you want to report this error, please read first the documentation
at http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html

mysql-test-run: *** ERROR: there were failing test cases
*************************************************************************

Here is an excerpt from 'ctest.log'

*************************************************************************
 6/64 Test  #6: pfs_instr-oom ................................................................................................***Failed    0.06 sec
1..28
ok 1 - instances init
ok 2 - create mutex
ok 3 - oom (create mutex)
ok 4 - instances init
ok 5 - create rwlock
ok 6 - oom (create rwlock)
ok 7 - instances init
ok 8 - create cond
ok 9 - oom (create cond)
ok 10 - instances init
ok 11 - create file
Signal 11 thrown, attempting backtrace.
stack_bottom = 0 thread_stack 0x0
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x439681]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x4049cc]
/lib64/libc.so.6(+0x35670)[0x7f4f48e69670]
/lib64/libc.so.6(+0x15ef7b)[0x7f4f48f92f7b]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x44d31a]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x43bed8]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x43c43e]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x43cba6]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x420f5d]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x4039c6]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x404451]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x404487]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f4f48e55b15]
/home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t[0x402d59]

      Start  7: pfs_account-oom
 7/64 Test  #7: pfs_account-oom ..............................................................................................   Passed    0.05 sec
      Start  8: pfs_host-oom
*************************************************************************

Tested on CentOS 7.2 x64, GCC 4.8.5 with default debug build.

How to repeat:
git clone -b 5.7 https://github.com/mysql/mysql-server.git
mkdir mysql-build
cd mysql-build
cmake \
 ../mysql-server \
 -DCMAKE_BUILD_TYPE=Debug \
 -DMYSQL_MAINTAINER_MODE=ON \
 -DBUILD_CONFIG=mysql_release \
 -DFEATURE_SET=community \
 -DENABLE_DTRACE=OFF \
 -DWITH_SSL=system \
 -DWITH_ZLIB=system \
 -DENABLE_DOWNLOADS=1 \
 -DDOWNLOAD_BOOST=1 \
 -DWITH_BOOST=../deps
./mysql-test/mtr --debug-server 1st --unit-tests

Suggested fix:
Most probably this failure is connected with the fix to
Bug #22662621 "UNIT TEST PFS_INSTR_OOM-T LEAKS MEMORY"
commit e90a0e3 (https://github.com/mysql/mysql-server/commit/e90a0e3)
[15 Jun 2016 17:11] Yura Sorokin
Debugging with GDB reveals readable call stack

***************************************************************
[yura@localhost mysql-build]$ gdb ctest
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/ctest...Reading symbols from /usr/bin/ctest...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install cmake-2.8.11-5.el7.x86_64
(gdb) set follow-fork-mode child
(gdb) run -R pfs_instr-oom
Starting program: /usr/bin/ctest -R pfs_instr-oom
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Test project /home/yura/ws/mysql-build
    Start 6: pfs_instr-oom
[New process 18047]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
process 18047 is executing new program: /home/yura/ws/mysql-build/storage/perfschema/unittest/pfs_instr-oom-t
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7fdb840 (LWP 18047)]
0x00007ffff6d1df7b in __memcmp_sse4_1 () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-106.el7_2.6.x86_64 libgcc-4.8.5-4.el7.x86_64 libstdc++-4.8.5-4.el7.x86_64 zlib-1.2.7-15.el7.x86_64
(gdb) bt
#0  0x00007ffff6d1df7b in __memcmp_sse4_1 () from /lib64/libc.so.6
#1  0x000000000044d31a in my_strnncoll_binary (cs=0x954900 <my_charset_bin>,
    s=0x7ffff7f3a028 <Address 0x7ffff7f3a028 out of bounds>, slen=59,
    t=0x7fffffffc410 "/home/yura/ws/mysql-build/storage/perfschema/unittest/dummy", tlen=59,
    t_is_prefix=0 '\000') at /home/yura/ws/mysql-server/strings/ctype-bin.c:84
#2  0x000000000043bed8 in my_lfind (head=0x9f6628, cs=0x954900 <my_charset_bin>, hashnr=1930419929,
    key=0x7fffffffc410 "/home/yura/ws/mysql-build/storage/perfschema/unittest/dummy", keylen=59,
    cursor=0x7fffffffc170, pins=0x9f2600) at /home/yura/ws/mysql-server/mysys/lf_hash.c:113
#3  0x000000000043c43e in my_lsearch (head=0x9f6628, cs=0x954900 <my_charset_bin>, hashnr=1930419929,
    key=0x7fffffffc410 "/home/yura/ws/mysql-build/storage/perfschema/unittest/dummy", keylen=59,
    pins=0x9f2600) at /home/yura/ws/mysql-server/mysys/lf_hash.c:364
#4  0x000000000043cba6 in lf_hash_search (hash=0x9e50a0 <filename_hash>, pins=0x9f2600,
    key=0x7fffffffc410, keylen=59) at /home/yura/ws/mysql-server/mysys/lf_hash.c:589
#5  0x0000000000420f5d in find_or_create_file (thread=0x7fffffffd480, klass=0x7fffffffcc40,
    filename=0x4741f7 "dummy", len=5, create=true)
    at /home/yura/ws/mysql-server/storage/perfschema/pfs_instr.cc:844
#6  0x00000000004039c6 in test_oom ()
    at /home/yura/ws/mysql-server/storage/perfschema/unittest/pfs_instr-oom-t.cc:249
#7  0x0000000000404451 in do_all_tests ()
    at /home/yura/ws/mysql-server/storage/perfschema/unittest/pfs_instr-oom-t.cc:420
#8  0x0000000000404487 in main ()
    at /home/yura/ws/mysql-server/storage/perfschema/unittest/pfs_instr-oom-t.cc:427
***************************************************************
[16 Jun 2016 4:21] MySQL Verification Team
Hello Yura Sorokin,

Thank you for the report.

Thanks,
Umesh
[16 Jun 2016 4:22] MySQL Verification Team
test results

Attachment: 81868.results (application/octet-stream, text), 194.14 KiB.

[17 Jun 2016 12:11] Yura Sorokin
Re-initializing 'file_hash' for the second 'find_or_create_file()' call

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: pfs_instr-oom-5.7.13_crash_fix.patch (application/octet-stream, text), 957 bytes.

[17 Jun 2016 13:00] Erlend Dahl
This has been fixed in the upcoming 5.7.14 release under the heading of

Bug#23186653 PERFORMANCE SCHEMA UNIT TESTS PFS_INSTR-OOM & PFS_INSTR_CLASS FAIL REGULARLY