TMySQLResult copy constructor dumps core


I am using TSQLServer to communication with a MySQL server in a multi-thread program. There is a mutex lock around the calls to MySQL so that only one call is made to the MySQL server at any given time. I have been getting segmentation violations inside the function MySQLServer::Query, right at the time when the function is making a copy of TMySQLResult in the return statement. This has been happening off and on for quite a while and I am note sure quite how to track this one down. Does anyone know how to track this problem down? Thanks.


Here goes the problem description.

ROOT version 4.04.02

OS: Linux 2.4.21-37.ELsmp #1 SMP Wed Sep 7 13:28:55 EDT 2005 i686 i686 i386 GNU/Linux

Listing produced by Totalview: it indicates that it has stop at line 113, which is the line starting with return.

TSQLResult *TMySQLServer::Query(const char *sql)
// Execute SQL command. Result object must be deleted by the user.
// Returns a pointer to a TSQLResult object if successful, 0 otherwise.
// The result object must be deleted by the user.

if (!IsConnected()) {
   Error("Query", "not connected");
   return 0;

if (mysql_query(fMySQL, sql) < 0) {
   Error("Query", mysql_error(fMySQL));
   return 0;

MYSQL_RES *res = mysql_store_result(fMySQL);
return new TMySQLResult(res);


Stack Trace
C++ TObject::not-in-charge TObject, FP=11a80338
C++ TSQLResult::not-in-charge TSQLResult, FP=11a80358
C++ TMySQLResult::TMySQLResult, FP=11a80388
C++ TMySQLServer::Query, FP=11a803c8
C++ GCA::FC::selectSource, FP=11a81498
C++ GCA::asyncTagHandler::selectSource, FP=11a81528
C++ GCA::asyncTagHandler::addFiles, FP=11a81728
C++ GCA::imp::fetch, FP=11a81838
C++ GCA::imp::fetchAndLoad, FP=11a81868
ZTv0_n100_N3GCA3imp12fetchAndLoadEPKcS2_S2, FP=11a81888
C++ POA_GC::tableI::_OB_op_fetchAndLoad, FP=11a81928
C++ POA_GC::coordinatorI::_OB_dispatch, FP=11a81948
C++ OBPortableServer::POA_impl::_OB_dispatch, FP=11a819a8
C++ OB::DispatchRequest_impl::invoke, FP=11a819c8
C++ OB::ThreadPoolDispatcher::run, FP=11a81a08
C++ JTCThread::entrance_hook, FP=11a81a68
C++ lsf_thread_adapter, FP=11a81a88
start_thread, FP=11a81b08

Hi John,

since you are using totalview which has very good thread debug capabilities did you check that another TMySQLResult is not accessed in another thread at the same time?

Cheers, Fons.