[MDEV-16478] mysql_real_connect() from libmariadbd.so always crash Created: 2018-06-13 Updated: 2018-06-25 Resolved: 2018-06-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Embedded Server |
| Affects Version/s: | 10.3.1, 10.3.2, 10.3.3, 10.3.4, 10.3.5, 10.3.6, 10.3.7, 10.3 |
| Fix Version/s: | 10.3.8 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Pali | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Function mysql_real_connect() from libmariadbd.so library always crash. In attachment is simple reproducer which tries to connect to MariaDB server via TCP from libmariadbd.so library. Compile steps:
And here is crash backtrace from gdb:
This problem was discovered while developing Perl DBI driver DBD::MariaDB: https://github.com/gooddata/DBD-MariaDB. First MariaDB version in which it was detected is 10.3.1 and it is present also in last 10.3.7 version. Versions 10.3.0 is working fine, also all versions from 10.2, 10.1, 10.0 and 5.5 series. Due to this problem, when DBD::MariaDB is compiled and linked with affected libmariadbd.so version, libmariadbd.so crashes and segfault whole perl process on every connection attempt. So it makes it fully unusable. Please, let us know what should we do with these crashes... If there is some workaround or something else. |
| Comments |
| Comment by Pali [ 2018-06-18 ] | ||||||||||||
|
For now we disabled compilation with MariaDB 10.3 series of libmariadbd.so library, see: I hope that you fix this problem in next MariaDB version, because libmariadbd.so library in this state is unusable. | ||||||||||||
| Comment by Elena Stepanova [ 2018-06-18 ] | ||||||||||||
|
Thanks for the report. Reproducible as described. 10.2 fails too, but quite differently:
| ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-20 ] | ||||||||||||
|
debugging binaries with safe mutex gave up the problem: there was no correct initialization of QC (maybe the whole server). | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-20 ] | ||||||||||||
|
It looks like MYSQL_OPT_USE_REMOTE_CONNECTION make correct cli_mysql_real_connect call but then version of net_real_write called that which build with MYSQL_SERVER and it call QC check which was not initialised of course. | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-20 ] | ||||||||||||
|
In 10.2 QC is off in embedded server, there is some problem also with not inited structures | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-21 ] | ||||||||||||
|
MYSQL_SERVER is not defined when compiled embedded net_serv.cc | ||||||||||||
| Comment by Vladislav Vaintroub [ 2018-06-21 ] | ||||||||||||
|
pali, is there a specific reason to use embedded library in (what seems to be strictly) client-server environment, i.e to access non-embedded server? | ||||||||||||
| Comment by Pali [ 2018-06-22 ] | ||||||||||||
|
It is for DBD::MariaDB, perl's DBI driver (as XS module). Previously it had nasty hack which produced copy of all source code files filtered by some sed script which added suffix "Emb" to driver name and then it compiled it and linked separately with libmysqld.so/libmariadbd.so library. This just complicated lot of things in building XS module, therefore I clean it up and now build process produce only one XS module: DBD::MariaDB. There is no copy/sed operation anymore and at configure time (when running Makefile.PL) it prefers to use libmysqld/libmariadbd if available. Code of driver was changed to fully support connecting to remote database even when compiled with libmysqld.so/libmariadbd.so so there is no functionality loss in DBD::MariaDB driver itself. And so it support also embedded server in DBI, like in "Emb" hack before. | ||||||||||||
| Comment by Vladislav Vaintroub [ 2018-06-22 ] | ||||||||||||
|
Thanks! You're aware that if you use embedded for remote connection, it is not the same as official C driver? Might also be of interest for you : https://mysqlserverteam.com/mysql-8-0-retiring-support-for-libmysqld/ or MDEV-16535 (this one is not scheduled yet, and is not certain when it will be scheduled, but still) . I'm not sure if I would chose embedded as default, given lack of focus in embedded. | ||||||||||||
| Comment by Pali [ 2018-06-22 ] | ||||||||||||
|
For DBD::MariaDB driver we have a large test suite with lot of different MySQL and MariaDB versions, see: https://travis-ci.org/gooddata/DBD-MariaDB It uses libmysqlclient.so, libmariadb.so, libmysqld.so, libmariadbd.so... whatever binary installation provides. And each job runs lot of driver tests, including all supported functionality and all tests pass. So I do not see any missing feature (yet). Just only one, reported in this bug: Since MariaDB 10.3.1 libmariadbd.so is unusable. DBD::MariaDB code had lot of problems with memory corruptions and it needed lot of fixed for proper initialization. And once this was done, usage of libmariadbd.so was simple, only one call for MYSQL_OPT_USE_REMOTE_CONNECTION on proper place. | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-23 ] | ||||||||||||
|
revision-id: 0882750fb5df5d4cf321ad4f8bc932a3c1248574 (mariadb-10.3.7-58-g0882750fb5d)
Returned accidentally removed undefinition of MYSQL_SERVER in net_serv.cc inside embedded server Prevented attempt to clean up embedded server if it was not initialized — | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-23 ] | ||||||||||||
|
Actually it is 2 bugs fixes, one is present in earlier versions (when library inited with -1 argc parameter then cleanup trying to clean uninitialized embedded server) but I am not sure if it has sens to move fix earlier if nobody complained about it. | ||||||||||||
| Comment by Pali [ 2018-06-23 ] | ||||||||||||
|
I spotted also that second bug. I planned to report it, but forgot... In DBD::MariaDB there is a workaround: does not call mysql_server_end()/mysql_library_end() when linked with libmariadbd.so and embedded server was not started. See: https://github.com/gooddata/DBD-MariaDB/commit/64f5c7a251b6fd85b939f08b193c00c5c8e911b3#diff-910bff34a0a9cc85c863b926e3fe02b9R2562 | ||||||||||||
| Comment by Pali [ 2018-06-23 ] | ||||||||||||
|
And maybe second bug is related to this comment: https://jira.mariadb.org/browse/CONC-336?focusedCommentId=111921&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-111921 | ||||||||||||
| Comment by Sergei Golubchik [ 2018-06-24 ] | ||||||||||||
|
ok to push | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-25 ] | ||||||||||||
|
pali, No it looks like other bug | ||||||||||||
| Comment by Pali [ 2018-06-25 ] | ||||||||||||
|
Ok, so then should I report it also for MDEV project? | ||||||||||||
| Comment by Oleksandr Byelkin [ 2018-06-25 ] | ||||||||||||
|
pali for me it looks like a server (even if it is embedded) bug so better report it to server | ||||||||||||
| Comment by Pali [ 2018-06-25 ] | ||||||||||||
|
Reported: |