Search code examples
c++mysql++libmysql

mysql_ping causes SIGSEGV


I use c++ and mysql++ library. I have separate mysqlpp::Connection object on each thread. All mysqlpp options are default(ReconnectOption is disabled). Each thread keeps persistent connection to the MariaDB server. Before series of SQL queries I make following check:

try
{
    if (!connection.ping()) connection.connect(db_cfg.name.c_str(),
                                               db_cfg.server.c_str(),
                                               db_cfg.user.c_str(),
                                               db_cfg.password.c_str(),
                                               db_cfg.port);
}

This code produces following SIGSEGV rarely:

#0  0x00007fe0a625eb46 in ?? () from /usr/lib/x86_64-linux-  gnu/libmysqlclient.so.20
#1  0x00007fe0a6251b26 in mysql_ping () from /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20
#2  0x00007fe0ab6773b1 in mysqlpp::Connection::ping() () from /usr/lib/libmysqlpp.so.3

I tried to reproduce this bug by running test program with ping/connect calls in endless loops. During the execution I restarted MariaDB server manually. However I did not succeed with reproducing. Do you have any ideas how to fix it? Thank you.

OS: Ubuntu 64-bit


Solution

  • mysqlpp++ was rebuilt using libmariadbclient instead of libmysqldbclient. It solves the problem.