0

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

Alex
  • 1,047
  • 8
  • 21
  • What is `connection`? Is the `MYSQL` pointer valid? Is the `MYSQL` object shared between threads? There's no data-race? – Some programmer dude Jun 07 '17 at 16:23
  • I use mysqlpp library over libmysqlclient. Each thread has own mysqlpp::connection. So Mysql object is not shared. – Alex Jun 07 '17 at 16:25
  • As I looked up the problem on Google I found a lot of bug reports, reporting similar problems like you: [\[1\]](https://bugs.mysql.com/bug.php?id=74393) [\[2\]](https://bugs.mysql.com/bug.php?id=39594) [\[3\]](https://bugs.mysql.com/bug.php?id=36810) and so on. Which version do you use, maybe it has been fixed? Try to compile and link your program with debug information so that you will see the lines where it crashes. Another option would be to write a core file and debug it. Also you could try to run `valgrind --track-origins=yes program`, valgrind could point you in the right direction. – Andre Kampling Jun 08 '17 at 06:23

1 Answers1

0

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

Alex
  • 1,047
  • 8
  • 21