mysqlubuntumysql++

mysql++ query crashes on Ubuntu 15.04


Here I wrote simplest program to reproduce my crash inside mysqlpp::Connection::query():

#include <mysql++.h>

int main(int argc, char* argv[])
{
    mysqlpp::Connection conn(false);
    if (conn.connect("neutrino", "localhost", "root", "1"))
    {
        mysqlpp::Query query = conn.query("select 1;");
    }

    return 0;
}

And here is my CMakeLists.txt:

cmake_minimum_required (VERSION 3.2)
project (mysqlpptest)

add_executable(mysqlpptest main.cpp)

target_include_directories(mysqlpptest
    PRIVATE
        /usr/include/mysql
        /usr/include/mysql++
)

target_link_libraries(mysqlpptest
        -lmysqlclient
        -lmysqlpp
)

Everything is compiled and linked well, but query() crashes with segmentation fault.

Database is created, so connect() returns true. Here is also mysql terminal test:

glaz@glaz-linux:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 190
Server version: 5.6.25-0ubuntu0.15.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use neutrino;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0,00 sec)

Any ideas where to dig the crash?

Updated: Call stack is useless because libraries are without debuggin info:

?? ()
std::istreambuf_iterator<char, std::char_traits<char> > std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_M_extract_int<unsigned short>(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, unsigned short&) const ()
std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::do_get(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_Ios_Iostate&, unsigned short&) const ()
std::ostream::seekp(long, std::_Ios_Seekdir) ()
mysqlpp::Query::Query(mysqlpp::Connection*, bool, char const*) ()
mysqlpp::Connection::query(char const*) ()
main (argc=1, argv=0x7fffffffded8)

Solution

  • I had g++ updated from 4.9.2 to 5.1.1 at the system where the crash occurred. And for a some reason the code compiled by the later compiler was incompatible with mysql libraries (obviously compiled by 4.9.2 compiler). I reverted the compiler back to 4.9.2 (which originally comes with ubuntu 15.04) and everything became work well.