MySQL Forums
Forum List  »  Connector/C++

Getting seg faults in SQLString
Posted by: Nandakumar Raghu
Date: June 07, 2012 07:25AM

The backtrace generally looks like this -

Program received signal SIGABRT, Aborted.
0x0012e416 in __kernel_vsyscall ()
(gdb) backtrace
#0 0x0012e416 in __kernel_vsyscall ()
#1 0x00528e71 in raise () from /lib/i386-linux-gnu/libc.so.6


#2 0x0052c34e in abort () from /lib/i386-linux-gnu/libc.so.6
#3 0x0055f577 in ?? () from /lib/i386-linux-gnu/libc.so.6
#4 0x00569961 in ?? () from /lib/i386-linux-gnu/libc.so.6
#5 0x0056b28b in ?? () from /lib/i386-linux-gnu/libc.so.6
#6 0x0056e41d in free () from /lib/i386-linux-gnu/libc.so.6
#7 0x0047b4d1 in operator delete(void*) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#8 0x0045dbad in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&) ()
from /usr/lib/i386-linux-gnu/libstdc++.so.6
#9 0x0045dc6c in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#10 0x080493e3 in sql::SQLString::~SQLString (this=0xbffff2f4, __in_chrg=<value optimized out>) at /usr/include/cppconn/sqlstring.h:46
#11 0x08048eba in main (argc=1, argv=0xbffff404) at mysqlexample.cc:71

Tried various things, using c++ string, using plain strings in quotes("string") etc, but this fault always seems to happen.

Try 1:
string column_name = "sample_text";
string result = "";
while(res->next())
{
result = res->getString(column_name);
cout<<res->getInt(1)<<"\t"<<result<<endl;
}
I am able to get the first column here, the fault occurs on the next iteration.
Try 2:
SQLString s("SELECT * FROM sample");
cout << "after sqlstring"<<endl;
res = stmt -> executeQuery (s);
cout << "after executequery"<<endl;
cout << "Retrieving the result set .." << endl;

the fault occurs in executeQuery as i do not get after executequery
Try 3:

string rc ="INSERT INTO sample(sample_id, sample_text) VALUES(?, ?)";
prep_stmt = con->prepareStatement(rc.c_str());

the fault occurs when prepareStatement returns.

Looks like mysql is trying to release the internally used SQLString and somehow causing this fault.

I have libc++ 6 installed by default, however I installed libc++ 5 to use libmysqlcppconn.

Anybody have any idea what this fault is and how to fix it?

Options: ReplyQuote


Subject
Views
Written By
Posted
Getting seg faults in SQLString
2942
June 07, 2012 07:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.