Public bug reported:

What?
--------

You will get SEGFAULT in mysqld with any custom plugin you built with
default configuration with build-ps/build-binary.sh

How to repeat?
---------------------

I take vagrant ubuntu 12.04.4 - precise
I take binary release 
http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.36-34.2/binary/debian/precise/x86_64/
I take sources 
http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.36-34.2/source/tarball/
I take custom engine plugin (i need sphinx/mysqlse) from 
http://sphinxsearch.com/files/sphinx-2.1.7-release.tar.gz

1) Build plugin.
- place sphinx/mysqlse/* into storage/sphinx/
- use build-ps/build-binary.sh to do cmake configuration
- go storage/sphinx/ && make && cp ha_sphinx.so 
/usr/lib/mysql/plugin/ha_sphinx.so

2) Install it.
- mysql -e 'INSTALL PLUGIN sphinx SONAME "ha_sphinx.so"'

3) CREATE TABLE ... ENGINE=SPHINX;

4) Catch SEGFAULT

Why is it happens?
-------------------------

Sources have OPTION(WITH_FAST_MUTEXES "" ON) for UNIX in 
cmake/build_configurations/mysql_release.cmake.
mysql_release.cmake is used to configure mysql release build system at 
build-ps/build-binary.sh (see cmake call).
Someone built and published Percona-Server-5.5.36-34.2 without this option - 
WITH_FAST_MUTEXES. 

So mysql_mutex_t struct became shorter for 8 bytes, because of
pthread_mutex_t not redefined in include/my_pthread.h

How to fix?
---------------

If you think release builds should not use WITH_FAST_MUTEXES - remove it from 
your build system configuration!
If you think this WITH_FAST_MUTEXES must be enabled - rebuild, republish this 
and check how you are building.

Anyway, your build scripts and configuration must be in sync, to what
you are publishing.

What to add more?
--------------------------

Why are you stripping .comment section from binary?
Where can i found actual version of compiler you use? (mysqlbug good?)

How to debug?
--------------------

gdb -p {mysqld}
create table ... engine=sphinx
you will catch segfault
check in gdb: table.s.LOCK_ha_data, and sizeof (mysql_mutex_t), 
all further fields will be shifted by 8 bytes

Sample SEGFAULT?
-------------------------

#0  __memcpy_sse2_unaligned () at 
../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:140
#1  0x00007fc764bb1023 in memcpy (__len=1, __src=0x22, __dest=0x7fc75c008340) 
at /usr/include/x86_64-linux-gnu/bits/string3.h:51
#2  sphDup (iLen=<optimized out>, sSrc=0x22 <error: Cannot access memory at 
address 0x22>) at 
/home/vagrant/percona-server-5.5.36-34.2/storage/sphinx/ha_sphinx.cc:921
#3  ParseUrl (share=share@entry=0x7fc7783ac780, 
table=table@entry=0x7fc7783ac930, bCreate=bCreate@entry=true) at 
/home/vagrant/percona-server-5.5.36-34.2/storage/sphinx/ha_sphinx.cc:1020
#4  0x00007fc764bb1440 in ha_sphinx::create (this=<optimized out>, 
name=0x7fc7783ae720 "./test/sphinx_heroes", table=0x7fc7783ac930) at 
/home/vagrant/percona-server-5.5.36-34.2/storage/sphinx/ha_sphinx.cc:3328
#5  0x00007fc77e62810b in ha_create_table(THD*, char const*, char const*, char 
const*, st_ha_create_information*, bool) ()
#6  0x00007fc77e5ba319 in rea_create_table(THD*, char const*, char const*, char 
const*, st_ha_create_information*, List<Create_field>&, unsigned int, st_key*, 
handler*) ()
#7  0x00007fc77e59274d in ?? ()
#8  0x00007fc77e592fcc in mysql_create_table(THD*, TABLE_LIST*, 
st_ha_create_information*, Alter_info*) ()
#9  0x00007fc77e536dea in mysql_execute_command(THD*) ()
#10 0x00007fc77e537d6a in mysql_parse(THD*, char*, unsigned int, Parser_state*) 
()
#11 0x00007fc77e539dea in dispatch_command(enum_server_command, THD*, char*, 
unsigned int) ()
#12 0x00007fc77e5cdbca in do_handle_one_connection(THD*) ()
#13 0x00007fc77e5cdc60 in handle_one_connection ()
#14 0x00007fc77d7c5182 in start_thread (arg=0x7fc7783b1700) at 
pthread_create.c:312
#15 0x00007fc77c26930d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Sample TABLE_SHARE?
-------------------------------

(gdb) x/70a 0x7fc7783ad200
0x7fc7783ad200: 0x2     0x0
0x7fc7783ad210: 0x0     0x0
0x7fc7783ad220: 0x0     0x0
0x7fc7783ad230: 0x0     0x0
0x7fc7783ad240: 0x0     0x0
0x7fc7783ad250: 0x0     0x0
0x7fc7783ad260: 0x0     0x0
0x7fc7783ad270: 0x7fc75c002900  0x7fc75c002d40
0x7fc7783ad280: 0x0     0x20
0x7fc7783ad290: 0x3e0   0x100000007
0x7fc7783ad2a0:         0x7fc77e5b36f0 <sql_alloc_error_handler>        0x1
0x7fc7783ad2b0: 0x0     0x7fc75c002b50
0x7fc7783ad2c0:         0x0     0x3
0x7fc7783ad2d0: 0x0     0x7fc75c002b30
0x7fc7783ad2e0: 0x0     0x0
--> start of LOCK_ha_data
0x7fc7783ad2f0:         0x0     0x0
0x7fc7783ad300: 0x0     0x0
0x7fc7783ad310: 0x0     0x0
--> must end here (without fast mutex)
0x7fc7783ad320: 0x0     (ends here with fast mutexes) 0x0
0x7fc7783ad330: 0x0     0x0
0x7fc7783ad340: 0x7fc75c002b10  0x0
0x7fc7783ad350: 0x0     0x7fc75c002910
0x7fc7783ad360: 0x0     0x7fc75c0029d0
0x7fc7783ad370: 0x7fc75c002b08  0x0
0x7fc7783ad380: 0x7fc77ef6ac00 <my_charset_utf8_general_ci>     0x7fc75c002c80
0x7fc7783ad390: 0xfffffff800000003      0x7fc75c002c80
0x7fc7783ad3a0:         0x0     0x7fc75c011b30
0x7fc7783ad3b0: 0x0     0x7fc75c011b30
0x7fc7783ad3c0:         0x4     0x7fc75c0115c0
0x7fc7783ad3d0: 0xd     0x7fc7783ae720
0x7fc7783ad3e0: 0x14    0x7fc7783ae720
0x7fc7783ad3f0:         0x14    0x7fc75c0029a8
0x7fc7783ad400: 0x22    0x1
0x7fc7783ad410: 0x0     0x0
0x7fc7783ad420: 0x0     0x0

** Affects: percona-server
     Importance: Undecided
         Status: New


** Tags: api build plugin segfault sources

** Also affects: ubuntu
   Importance: Undecided
       Status: New

** No longer affects: ubuntu

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1304470

Title:
  SEGFAULT with custom plugins >= 5.5.36-rel34.*

To manage notifications about this bug go to:
https://bugs.launchpad.net/percona-server/+bug/1304470/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to