Hello,

I have just migrated from a 32bit system to a new 64bit system, running Kubuntu Natty and Qt 4.7.2. I have recompiled an application that used to work perfectly on the 32bit system and now I am getting a crash while inserting rows into a Postgresql database.

The following is the code, it just reads a CSV file line by line and inserts each line into a Postgresql table. The database connection has been opened successfully at a different place in the application. The crash occurs at query.exec() inside the while() loop on line 51:

Qt Code:
  1. void TickerImportThread::run()
  2. {
  3. status = true;
  4.  
  5. QSqlQuery query;
  6. QFile file(filename);
  7.  
  8. if ( !file.open(QIODevice::Text | QIODevice::ReadOnly) )
  9. {
  10. status = false;
  11. return;
  12. }
  13.  
  14. QSqlDatabase::database().transaction();
  15.  
  16. if ( !query.exec("DELETE FROM \"bardata_M1\"") )
  17. {
  18. status = false;
  19. QSqlError error = query.lastError();
  20. qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
  21. QSqlDatabase::database().rollback();
  22. return;
  23. }
  24.  
  25. QByteArray line;
  26. QList<QByteArray> items;
  27. long filesize = file.size();
  28. long completed = 0;
  29. int percentage = 0;
  30.  
  31. if ( !query.prepare("INSERT INTO \"bardata_M1\" (symbol, \"time\", open, high, low, \"close\") VALUES ('EURUSD', :v_time, :v_open, :v_high, :v_low, :v_close)") )
  32. {
  33. status = false;
  34. QSqlError error = query.lastError();
  35. qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
  36. QSqlDatabase::database().rollback();
  37. return;
  38. }
  39.  
  40. while ( !file.atEnd() )
  41. {
  42. line = file.readLine();
  43. items = line.split(',');
  44.  
  45. query.bindValue(":v_time", QString(items[0]) + " " + QString(items[1]));
  46. query.bindValue(":v_open", items[2]);
  47. query.bindValue(":v_high", items[3]);
  48. query.bindValue(":v_low", items[4]);
  49. query.bindValue(":v_close", items[5]);
  50.  
  51. if ( !query.exec() )
  52. {
  53. status = false;
  54. QSqlError error = query.lastError();
  55. qDebug() << Q_FUNC_INFO << "SQL Error: " << error.databaseText() << error.driverText();
  56. QSqlDatabase::database().rollback();
  57. return;
  58. }
  59.  
  60. completed += line.length();
  61. double newpercentage = (double)completed / (double)filesize * 100;
  62. if ( round(newpercentage) > percentage )
  63. {
  64. percentage = round(newpercentage);
  65. emit importProgress(percentage);
  66. }
  67. }
  68.  
  69. emit importProgress(100);
  70.  
  71. QSqlDatabase::database().commit();
  72.  
  73. file.close();
  74. }
To copy to clipboard, switch view to plain text mode 

This is the backtrace:

Qt Code:
  1. *** glibc detected *** /home/till/forex-build-desktop/forex: double free or corruption (fasttop): 0x000000000094aa70 ***
  2. ======= Backtrace: =========
  3. /lib/x86_64-linux-gnu/libc.so.6(+0x78a8f)[0x7ffff5370a8f]
  4. /lib/x86_64-linux-gnu/libc.so.6(cfree+0x73)[0x7ffff53748e3]
  5. /lib/libcrypto.so.0.9.8(CRYPTO_free+0x1d)[0x7fffeb6b0efd]
  6. /lib/libssl.so.0.9.8(SSL_free+0x49)[0x7fffeba0e199]
  7. /usr/lib/libpq.so.5(+0x19e8d)[0x7fffebc45e8d]
  8. /usr/lib/libpq.so.5(+0x11bc9)[0x7fffebc3dbc9]
  9. /usr/lib/libpq.so.5(PQgetResult+0x9d)[0x7fffebc3bbcd]
  10. /usr/lib/libpq.so.5(+0xfe6b)[0x7fffebc3be6b]
  11. /usr/lib/qt4/plugins/sqldrivers/libqsqlpsql.so(+0xe327)[0x7fffebe62327]
  12. /usr/lib/libQtSql.so.4(_ZN9QSqlQuery4execEv+0xc5)[0x7ffff718cf15]
  13. /home/till/forex-build-desktop/forex[0x40fc0e]
  14. /usr/lib/libQtCore.so.4(+0x74175)[0x7ffff60bf175]
  15. /lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c)[0x7ffff5e33d8c]
  16. /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7ffff53de04d]
To copy to clipboard, switch view to plain text mode 

I'm not sure how to debug this, my guess is that it is libssl's fault, but I could not find anything related on the web. Is there any problem in my code? If not, any tips for debugging or even fixing this?