FAQ
I'm using MySQL++ 3.1.0 library with my code and it has been working just
fine. libstdc++.so.6 updated this week and since the MySQL++ has not been
working. I'm running my code with valgrind and the result is as follows

==18713== Use of uninitialised value of size 8
==18713== at 0x54FE181: std::locale::operator=(std::locale const&) (in
/usr/lib/libstdc++.so.6.0.13)
==18713== by 0x54FCC6E: std::ios_base::_M_init() (in
/usr/lib/libstdc++.so.6.0.13)
==18713== by 0x55117C8: std::basic_ios<char, std::char_traits<char>
::init(std::basic_streambuf<char, std::char_traits<char> >*) (in
/usr/lib/libstdc++.so.6.0.13)
==18713== by 0x526D163: mysqlpp::Query::Query(mysqlpp::Connection*, bool,
char const*) (ostream:83)
==18713== by 0x525CA4F: mysqlpp::Connection::query(char const*)
(connection.cpp:264)

==18713== Invalid read of size 4
==18713== at 0x54FE181: std::locale::operator=(std::locale const&) (in
/usr/lib/libstdc++.so.6.0.13)
==18713== by 0x54FCC6E: std::ios_base::_M_init() (in
/usr/lib/libstdc++.so.6.0.13)
==18713== by 0x55117C8: std::basic_ios<char, std::char_traits<char>
::init(std::basic_streambuf<char, std::char_traits<char> >*) (in
/usr/lib/libstdc++.so.6.0.13)
==18713== by 0x526D163: mysqlpp::Query::Query(mysqlpp::Connection*, bool,
char const*) (ostream:83)
==18713== by 0x525CA4F: mysqlpp::Connection::query(char const*)
(connection.cpp:264)

The complain is coming from this line of my code:
mysqlpp::Query q = connection.query("SELECT * from Meter");
and the connection has been connected successfully earlier.

I asked about the problem at the #ubuntu irc channel and the answer was
pretty clear: the problem should be in the library I'm using. If I'm
correct, the problem is at the query.cpp file at the line 46.

I'm running 64bit Ubuntu Lucid Lynx 10.04
libstdc++ version is 6.0.13
g++ version is 4.4.3
MySQL++ version is 3.1.0

Anything I can do or shall I just wait the problem will be fixed?

-Ina

Search Discussions

  • Linda Messerschmidt at Aug 19, 2011 at 2:10 pm

    On Fri, Aug 19, 2011 at 7:18 AM, Ina J. wrote:
    The complain is coming from this line of my code:
    mysqlpp::Query q = connection.query("SELECT * from Meter");
    and the connection has been connected successfully earlier.
    I believe this is not correct. Assigning something with a basic_ios
    inside never works.

    Try:

    mysqlpp::Query q(connection.query("SELECT * from Meter"));
  • Jonathan Wakely at Aug 19, 2011 at 2:14 pm

    On 19 August 2011 15:10, Linda Messerschmidt wrote:
    On Fri, Aug 19, 2011 at 7:18 AM, Ina J. wrote:
    The complain is coming from this line of my code:
    mysqlpp::Query q = connection.query("SELECT * from Meter");
    and the connection has been connected successfully earlier.
    I believe this is not correct.  Assigning something with a basic_ios
    inside never works.
    That isn't an assignment, it's a copy construction.
    Try:

    mysqlpp::Query q(connection.query("SELECT * from Meter"));
    This is exactly equivalent.

    The error seems to indicate a race condition in the initialization of
    the std::ios_base base class. I've seen someone report a similar
    error in that libstdc++ code before, but I think it's correct (I can't
    see a problem anyway) so it could be user error, but I'm not sure.
  • Ina J. at Aug 21, 2011 at 8:56 am
    But the same code has been working without problems before the libstdc++6
    was updated. But any suggestions how to fix it?? Or avoid it?? Should I use
    the other constructor for a Query?? It's pretty obvious I have to create a
    query to get the data from the MySQL server.

    -Ina

    2011/8/19 Jonathan Wakely <[email protected]>
    On 19 August 2011 15:10, Linda Messerschmidt wrote:
    On Fri, Aug 19, 2011 at 7:18 AM, Ina J. wrote:
    The complain is coming from this line of my code:
    mysqlpp::Query q = connection.query("SELECT * from Meter");
    and the connection has been connected successfully earlier.
    I believe this is not correct. Assigning something with a basic_ios
    inside never works.
    That isn't an assignment, it's a copy construction.
    Try:

    mysqlpp::Query q(connection.query("SELECT * from Meter"));
    This is exactly equivalent.

    The error seems to indicate a race condition in the initialization of
    the std::ios_base base class. I've seen someone report a similar
    error in that libstdc++ code before, but I think it's correct (I can't
    see a problem anyway) so it could be user error, but I'm not sure.
  • Ina J. at Aug 22, 2011 at 9:03 am
    I reinstalled mysql++ and g++ and libstdc++, but no luck with those. Then I
    made a simple main program from the example simple1.cpp

    int main()
    {

    mysqlpp::Connection conn(false);
    if (conn.connect(DBNAME, DBADDRESS, DBUSER, DBPWD, DBPORT)) {
    // Retrieve a subset of the sample stock table set up by resetdb
    // and display it.
    mysqlpp::Query query = conn.query("SELECT * from Meter");
    } else {
    cerr << "DB connection failed: " << conn.error() << endl;
    return 1;
    }

    return 1;
    }


    And valgrind says this:

    ==24122== Use of uninitialised value of size 8
    ==24122== at 0x54FE181: std::locale::operator=(std::locale const&) (in
    /usr/lib/libstdc++.so.6.0.13)
    ==24122== by 0x54FCC6E: std::ios_base::_M_init() (in
    /usr/lib/libstdc++.so.6.0.13)
    ==24122== by 0x55117C8: std::basic_ios<char, std::char_traits<char>
    ::init(std::basic_streambuf<char, std::char_traits<char> >*) (in
    /usr/lib/libstdc++.so.6.0.13)
    ==24122== by 0x526D163: mysqlpp::Query::Query(mysqlpp::Connection*, bool,
    char const*) (ostream:83)
    ==24122== by 0x525CA4F: mysqlpp::Connection::query(char const*)
    (connection.cpp:264)
    ==24122== by 0x44152F: main (main.cc:29)
    ==24122== Uninitialised value was created by a stack allocation
    ==24122== at 0x4414AF: main (main.cc:22)
    ==24122==
    ==24122==
    ==24122== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- c
    ==24122==
    ==24122== Process terminating with default action of signal 11 (SIGSEGV)
    ==24122== Bad permissions for mapped region at address 0x441699
    ==24122== at 0x54FE181: std::locale::operator=(std::locale const&) (in
    /usr/lib/libstdc++.so.6.0.13)
    ==24122== by 0x54FCC6E: std::ios_base::_M_init() (in
    /usr/lib/libstdc++.so.6.0.13)
    ==24122== by 0x55117C8: std::basic_ios<char, std::char_traits<char>
    ::init(std::basic_streambuf<char, std::char_traits<char> >*) (in
    /usr/lib/libstdc++.so.6.0.13)
    ==24122== by 0x526D163: mysqlpp::Query::Query(mysqlpp::Connection*, bool,
    char const*) (ostream:83)
    ==24122== by 0x525CA4F: mysqlpp::Connection::query(char const*)
    (connection.cpp:264)
    ==24122== by 0x44152F: main (main.cc:29)
    ==24122==
    ==24122== HEAP SUMMARY:
    ==24122== in use at exit: 94,177 bytes in 69 blocks
    ==24122== total heap usage: 119 allocs, 50 frees, 117,895 bytes allocated

    I'd say this puts the error to the mysql++ side??

    -Ina

    2011/8/21 Ina J. <[email protected]>
    But the same code has been working without problems before the libstdc++6
    was updated. But any suggestions how to fix it?? Or avoid it?? Should I use
    the other constructor for a Query?? It's pretty obvious I have to create a
    query to get the data from the MySQL server.

    -Ina


    2011/8/19 Jonathan Wakely <[email protected]>
    On 19 August 2011 15:10, Linda Messerschmidt wrote:
    On Fri, Aug 19, 2011 at 7:18 AM, Ina J. wrote:
    The complain is coming from this line of my code:
    mysqlpp::Query q = connection.query("SELECT * from Meter");
    and the connection has been connected successfully earlier.
    I believe this is not correct. Assigning something with a basic_ios
    inside never works.
    That isn't an assignment, it's a copy construction.
    Try:

    mysqlpp::Query q(connection.query("SELECT * from Meter"));
    This is exactly equivalent.

    The error seems to indicate a race condition in the initialization of
    the std::ios_base base class. I've seen someone report a similar
    error in that libstdc++ code before, but I think it's correct (I can't
    see a problem anyway) so it could be user error, but I'm not sure.
  • Adrian Cornish at Aug 22, 2011 at 3:31 pm

    On Mon, Aug 22, 2011 at 3:02 AM, Ina J. wrote:

    I reinstalled mysql++ and g++ and libstdc++, but no luck with those. Then I
    made a simple main program from the example simple1.cpp


    I'd say this puts the error to the mysql++ side??
    Ina

    Can you provide the full code for your sample and the compile line that you
    are using. Please modify the sample to use one of the mysql++ example
    tables.

    I'll download Ubuntu to see if I can reproduce it.



    Adrian
  • Warren Young at Aug 22, 2011 at 5:14 pm

    On 8/22/2011 8:59 AM, Adrian Cornish wrote:
    I'll download Ubuntu to see if I can reproduce it.
    It may be important that this is on Ubuntu 10.4 LTS, and the current
    stable source release rather than what is in the Ubuntu package repo.

    That could also explain why no one else is complaining about this: I
    suspect most of our Ubuntu users aren't still on the LTS branch, and are
    either using the packaged MySQL++ (3.0.9 still) or svn.

    Ina: have you tried the svn version?
  • Adrian Cornish at Aug 22, 2011 at 7:47 pm

    On Mon, Aug 22, 2011 at 11:13 AM, Warren Young wrote:
    On 8/22/2011 8:59 AM, Adrian Cornish wrote:


    I'll download Ubuntu to see if I can reproduce it.
    It may be important that this is on Ubuntu 10.4 LTS, and the current stable
    source release rather than what is in the Ubuntu package repo.

    That could also explain why no one else is complaining about this: I
    suspect most of our Ubuntu users aren't still on the LTS branch, and are
    either using the packaged MySQL++ (3.0.9 still) or svn.

    Ina: have you tried the svn version?
    Ina,

    I cannot reproduce you issue - can you check the details below and see if I
    have missed anything?

    I downloaded and installed
    [email protected]:~$ uname -a
    Linux unbuntu 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011
    x86_64 GNU/Linux

    I tried mysqlpp 3.0.9 from ubuntu packages and its worked fine.

    I removed 3.0.9 and installed 3.1.0 from source and it worked fine as well

    Out of interest - what does this version code do on you box
    [email protected]:~$ g++ -o version version.cc -I/usr/local/include -lmysqlpp
    `mysql_config --include --libs`
    [email protected]:~$ ./version
    [email protected]:~$ cat version.cc
    #include <mysql++/mysql++.h>

    int main()
    {
    if(mysqlpp::get_library_version()!=MYSQLPP_HEADER_VERSION)
    {
    std::cout << "Library/header mismatch\n";
    }
    return 0;
    }


    Detailed results of my testings

    [email protected]:~$ g++ --version
    g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
    Copyright (C) 2009 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    [email protected]:~$ ls -l /usr/lib64/libstdc++.so.6.0.13
    -rw-r--r-- 1 root root 1044112 2010-03-26 18:16
    /usr/lib64/libstdc++.so.6.0.13
    [email protected]:~$ grep MYSQLPP_HEADER_VERSION /usr/include/mysql++/mysql++.h

    #define MYSQLPP_HEADER_VERSION MYSQLPP_VERSION(3, 0, 9)
    /// MYSQLPP_HEADER_VERSION constant in order to ensure that your
    [email protected]:~$ cat simple.cc
    #include <mysql++.h>
    #include <iostream>

    using namespace std;

    int main()
    {
    std::cout << "Version: " << mysqlpp::get_library_version() << std::endl;
    mysqlpp::Connection conn(false);
    if (conn.connect("mysql_cpp_data", "localhost", "adrian", "", 3306)) {
    // Retrieve a subset of the sample stock table set up by resetdb
    // and display it.
    mysqlpp::Query query = conn.query("SELECT * from stock");
    } else {
    cerr << "DB connection failed: " << conn.error() << endl;
    return 1;
    }

    return 1;
    }
    adri[email protected]:~$ g++ -o simple simple.cc -I/usr/include/mysql++
    `mysql_config --libs --include` -lmysqlpp
    [email protected]:~$ ./simple
    Version: 196617
    [email protected]:~$

    [email protected]:~$ sudo ldconfig -p | grep mysql
    libmysqlpp.so.3 (libc6,x86-64) => /usr/local/lib/libmysqlpp.so.3
    libmysqlpp.so (libc6,x86-64) => /usr/local/lib/libmysqlpp.so
    libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib/libmysqlclient_r.so.16
    libmysqlclient_r.so (libc6,x86-64) => /usr/lib/libmysqlclient_r.so
    libmysqlclient.so.16 (libc6,x86-64) => /usr/lib/libmysqlclient.so.16
    libmysqlclient.so (libc6,x86-64) => /usr/lib/libmysqlclient.so
    [email protected]:~$ grep MYSQLPP_HEADER_VERSION
    /usr/local/include/mysql++/mysql++.h
    #define MYSQLPP_HEADER_VERSION MYSQLPP_VERSION(3, 1, 0)
    /// MYSQLPP_HEADER_VERSION constant in order to ensure that your
    [email protected]:~$ g++ -o simple simple.cc -I/usr/local/include/mysql++
    `mysql_config --libs --include` -lmysqlpp
    [email protected]:~$ ./simple
    Version: 196864
    [email protected]:~$
  • Ina J. at Aug 23, 2011 at 6:21 am
    Warren: I haven't tried the SVN version out

    Adrian: The examples you provided work just fine so the error has to be in
    my code structure.

    -Ina

    2011/8/22 Adrian Cornish <[email protected]>
    On Mon, Aug 22, 2011 at 11:13 AM, Warren Young wrote:
    On 8/22/2011 8:59 AM, Adrian Cornish wrote:


    I'll download Ubuntu to see if I can reproduce it.
    It may be important that this is on Ubuntu 10.4 LTS, and the current stable
    source release rather than what is in the Ubuntu package repo.

    That could also explain why no one else is complaining about this: I
    suspect most of our Ubuntu users aren't still on the LTS branch, and are
    either using the packaged MySQL++ (3.0.9 still) or svn.

    Ina: have you tried the svn version?
    Ina,

    I cannot reproduce you issue - can you check the details below and see if I
    have missed anything?

    I downloaded and installed
    [email protected]:~$ uname -a
    Linux unbuntu 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011
    x86_64 GNU/Linux

    I tried mysqlpp 3.0.9 from ubuntu packages and its worked fine.

    I removed 3.0.9 and installed 3.1.0 from source and it worked fine as well

    Out of interest - what does this version code do on you box
    [email protected]:~$ g++ -o version version.cc -I/usr/local/include -lmysqlpp
    `mysql_config --include --libs`
    [email protected]:~$ ./version
    [email protected]:~$ cat version.cc
    #include <mysql++/mysql++.h>

    int main()
    {
    if(mysqlpp::get_library_version()!=MYSQLPP_HEADER_VERSION)
    {
    std::cout << "Library/header mismatch\n";
    }
    return 0;
    }


    Detailed results of my testings

    [email protected]:~$ g++ --version
    g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
    Copyright (C) 2009 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    [email protected]:~$ ls -l /usr/lib64/libstdc++.so.6.0.13
    -rw-r--r-- 1 root root 1044112 2010-03-26 18:16
    /usr/lib64/libstdc++.so.6.0.13
    [email protected]:~$ grep MYSQLPP_HEADER_VERSION
    /usr/include/mysql++/mysql++.h

    #define MYSQLPP_HEADER_VERSION MYSQLPP_VERSION(3, 0, 9)
    /// MYSQLPP_HEADER_VERSION constant in order to ensure that your
    [email protected]:~$ cat simple.cc
    #include <mysql++.h>
    #include <iostream>

    using namespace std;

    int main()
    {
    std::cout << "Version: " << mysqlpp::get_library_version() << std::endl;
    mysqlpp::Connection conn(false);
    if (conn.connect("mysql_cpp_data", "localhost", "adrian", "", 3306)) {
    // Retrieve a subset of the sample stock table set up by resetdb
    // and display it.
    mysqlpp::Query query = conn.query("SELECT * from stock");
    } else {
    cerr << "DB connection failed: " << conn.error() << endl;
    return 1;
    }

    return 1;
    }
    adri[email protected]:~$ g++ -o simple simple.cc -I/usr/include/mysql++
    `mysql_config --libs --include` -lmysqlpp
    [email protected]:~$ ./simple
    Version: 196617
    [email protected]:~$

    [email protected]:~$ sudo ldconfig -p | grep mysql
    libmysqlpp.so.3 (libc6,x86-64) => /usr/local/lib/libmysqlpp.so.3
    libmysqlpp.so (libc6,x86-64) => /usr/local/lib/libmysqlpp.so
    libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib/libmysqlclient_r.so.16
    libmysqlclient_r.so (libc6,x86-64) => /usr/lib/libmysqlclient_r.so
    libmysqlclient.so.16 (libc6,x86-64) => /usr/lib/libmysqlclient.so.16
    libmysqlclient.so (libc6,x86-64) => /usr/lib/libmysqlclient.so
    [email protected]:~$ grep MYSQLPP_HEADER_VERSION
    /usr/local/include/mysql++/mysql++.h
    #define MYSQLPP_HEADER_VERSION MYSQLPP_VERSION(3, 1, 0)
    /// MYSQLPP_HEADER_VERSION constant in order to ensure that your
    [email protected]:~$ g++ -o simple simple.cc -I/usr/local/include/mysql++
    `mysql_config --libs --include` -lmysqlpp
    [email protected]:~$ ./simple
    Version: 196864
    [email protected]:~$
  • Ina J. at Aug 23, 2011 at 7:45 am
    Found the problem! It was in my compile options.

    My makefile's compile section looked like this:

    #Compiler
    CC=g++
    #Compiler options
    CCFLAGS=-std=c++98 -Wall -pedantic -Wextra -g -D_GLIBCXX_DEBUG -pthread

    #MySQL libs
    MYSQL_INC = -I/usr/include/mysql -I/usr/include/mysql++
    MYSQL_LIB = -Bsymbolic-functions -rdynamic -L/usr/lib/mysql++ -lmysqlclient
    -lmysqlpp


    My makefile had an error in it and it didn't use the CCFLAGS at all at the
    beginning of the project. I corrected it during the project and then the
    problem occured. When I realized this, I started to cut down the options and
    found the 'D_GLIBCXX_DEBUG' will trigger the valgrind. I removed it from my
    makefile and everything works as it should now.

    Why does this option cause that kind of a problem?? Can't even remember
    where I found the option and why did I add it after all.

    -Ina

    PS. I haven't configured/compiled the MySQL++ library with threads enabled,
    but the library isn't used in the threads so can I continue like this or
    should I still compile it with the threads enabled flag?? Only the main
    program uses the library.
  • Jonathan Wakely at Aug 23, 2011 at 8:03 am

    On 23 August 2011 08:45, Ina J. wrote:
    Found the problem! It was in my compile options.

    My makefile's compile section looked like this:

    #Compiler
    CC=g++
    #Compiler options
    CCFLAGS=-std=c++98 -Wall -pedantic -Wextra -g -D_GLIBCXX_DEBUG -pthread

    #MySQL libs
    MYSQL_INC = -I/usr/include/mysql -I/usr/include/mysql++
    MYSQL_LIB = -Bsymbolic-functions -rdynamic -L/usr/lib/mysql++ -lmysqlclient
    -lmysqlpp


    My makefile had an error in it and it didn't use the CCFLAGS at all at the
    beginning of the project. I corrected it during the project and then the
    problem occured. When I realized this, I started to cut down the options and
    found the 'D_GLIBCXX_DEBUG' will trigger the valgrind. I removed it from my
    makefile and everything works as it should now.

    Why does this option cause that kind of a problem?? Can't even remember
    where I found the option and why did I add it after all.
    It turns on the libstdc++ debug mode, but you have to use it
    consistently for everything, you can't generally mix objects built
    with it and objects built without it.
  • Ina J. at Aug 23, 2011 at 10:06 am
    Okay. Thanks for the answer. Those compiler options are used in the whole
    project so leaving it out is not a problem. All the objects will be compiled
    without it.

    -Ina

    2011/8/23 Jonathan Wakely <[email protected]>
    On 23 August 2011 08:45, Ina J. wrote:
    Found the problem! It was in my compile options.

    My makefile's compile section looked like this:

    #Compiler
    CC=g++
    #Compiler options
    CCFLAGS=-std=c++98 -Wall -pedantic -Wextra -g -D_GLIBCXX_DEBUG -pthread

    #MySQL libs
    MYSQL_INC = -I/usr/include/mysql -I/usr/include/mysql++
    MYSQL_LIB = -Bsymbolic-functions -rdynamic -L/usr/lib/mysql++
    -lmysqlclient
    -lmysqlpp


    My makefile had an error in it and it didn't use the CCFLAGS at all at the
    beginning of the project. I corrected it during the project and then the
    problem occured. When I realized this, I started to cut down the options and
    found the 'D_GLIBCXX_DEBUG' will trigger the valgrind. I removed it from my
    makefile and everything works as it should now.

    Why does this option cause that kind of a problem?? Can't even remember
    where I found the option and why did I add it after all.
    It turns on the libstdc++ debug mode, but you have to use it
    consistently for everything, you can't generally mix objects built
    with it and objects built without it.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupplusplus @
categoriesmysql
postedAug 19, '11 at 11:19a
activeAug 23, '11 at 10:06a
posts12
users5
websitemysql.com
irc#mysql

People

Translate

site design / logo © 2023 Grokbase