[CONC-336] Repeated mysql_library_init()+mysql_library_end() calls do not work Created: 2018-05-29  Updated: 2018-06-25  Resolved: 2018-06-05

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: 3.0.5

Type: Bug Priority: Major
Reporter: Pali Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Attachments: File test-init.c    
Issue Links:
Relates
relates to MDEV-16578 Repeated mysql_library_init()+mysql_l... Closed

 Description   

When trying to call repeated mysql_library_init() and mysql_library_end() it fails on different error.

With MariaDB Connector/C 2.3.2 I can call

mysql_library_init(-1, NULL, NULL);
mysql_library_end();

above code only 1024 times. At 1025 step it fails with error:

Can't initialize threads: error 95

With client from MariaDB 10.3.6 above code can be called only one time. After second time it fails with error:

Plugin pvio_socket could not be loaded: not initialized

With client from MariaDB 10.1.26 everything is working fine and 10000 iteration passed without problem.

This problem was found while developing Perl DBI driver DBD::MariaDB:
http://github.com/gooddata/DBD-MariaDB

In attachment is a simple application to testing mysql_library_init() and mysql_library_end() calls. Compile it with gcc test-init.c -o test-init `mysql_config --cflags --libs`



 Comments   
Comment by Pali [ 2018-06-04 ]

And when above test-init.c is linked with `mysql_config --cflags --libmysqld-libs` then second run cause deadlock in inline_mysql_cond_destroy. Same reproducer, but third different error.

$ gcc -W -Wall -O2 -g test-init.c -o test-init `mysql_config --cflags --libmysqld-libs`
$ gdb --args ./test-init 2 127.0.0.1 3306 pali pali
...
(gdb) r
...
^C
Program received signal SIGINT, Interrupt.
__lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
95      ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Adresár alebo súbor neexistuje.
(gdb) bt
#0  __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
#1  0x00007ffff6184eb5 in __pthread_cond_destroy (cond=cond@entry=0x7ffff7568ae0 <COND_thread_count>) at pthread_cond_destroy.c:34
#2  0x00007ffff67436c0 in inline_mysql_cond_destroy (that=0x7ffff7568ae0 <COND_thread_count>) at ./include/mysql/psi/mysql_thread.h:1131
#3  clean_up_mutexes () at ./libmysqld/../sql/mysqld.cc:2264
#4  0x00007ffff6748974 in end_embedded_server () at ./libmysqld/lib_sql.cc:648
#5  0x00007ffff674c7ec in mysql_server_end () at ./libmysql/libmysql.c:213
#6  0x00005555555549e4 in main (argc=<optimized out>, argv=<optimized out>) at test-init.c:49
(gdb)

This is from MariaDB version 10.1.26, which is available in current Debian stable.

So it is not only problem of Connector/C, but also of MariaDB server itself.

Comment by Pali [ 2018-06-05 ]

Now bug is marked closed. Does it mean that both Connector/C and also libmysqld are fixed? As in "Fix Version/s" field is only 3.0.5 version. What is state with 2.3 series?

Comment by Georg Richter [ 2018-06-05 ]

Hi Pali,

we will not fix it in C/C 2.3 series.
Please also note that there is no need to initialize the client library multiple times. If you don't call mysql_library_init explicitly a call to mysql_init will automatically initialize the library.

Generated at Thu Feb 08 03:04:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.