开发者

Crash with MySQL connector c++ in CentOS; Related to library conflict?

EDIT : I've since stopped using std::strings as arguments to these functions and the problems have gone away. It seems to be a serious error related to string lifetime and scope. I wish I understood wha开发者_StackOverflow社区t was going on a little better, but wanted to leave another breadcrumb for others who might be fighting with similar anomalies./Edit

So I'm trying to write a database access routine using the MySQL C++ connector (built from source) and am getting an anomalous termination at the following code location:

//Change the active table and populate the member TableInfo object
void DatabaseInterface::ChangeTable(string tableName)
{
    string sqlString;
    int numFields;
    int numRecords;
    //Crash in this call
    connection->setSchema(tableName);
//More after this, but we never get here anyway...

After the program terminates, the message in the console is:

   warning: .dynamic section for "/lib/libnsl.so.1" is not at the expected address
    warning: difference appears to be caused by prelink, adjusting expectations
    [Thread debugging using libthread_db enabled]
    [New Thread 0xb7fecb90 (LWP 23590)]
    [Thread 0xb7fecb90 (LWP 23590) exited]
    Traceback (most recent call last):
      File "/usr/share/gdb/python/libstdcxx/v6/printers.py", line 469, in to_string
        return self.val['_M_dataplus']['_M_p'].string (encoding, length = len)
    RuntimeError: Error reading string from inferior: Input/output error

That last RuntimeError seems like its indicating a nulled parameter being argued into the function, and stepping into the following code, I see that the address is not being allocated. The debugger sees a value, but the memory location doesn't seem to exist. In fact, attempting to view the location of the variable in the memory window results in an error.

bool ControlInterface::GenerateCmdSet()
{
    int nRecords;
    int nFields;
    string sqlString;

    string cardCmdTable;

    cardCmdTable = "card_command";

    dbInterface.ChangeTable(cardCmdTable);

Is it possible that I've got an issue with a library conflict, or a missing library? I'm relatively new to linux, and finding it hard to appreciate while fighting with distros, flavors, dependencies, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜