Hi all,

In a bit of pickle here with app segfaulting whenever I use either prepare() or exec() methods of QSqlQuery .. :S

My app creates a unique database connection for each thread it spawns (working for everything else...)

The problematic code:

Qt Code:
  1. QSqlQuery query ( this->connAvl->db );
To copy to clipboard, switch view to plain text mode 
db is a pointer to the database object from another class so it should be passing the correct connection... As a matter of fact on another method of the class I use the exact same code with no problems! :S

whenever I use:
Qt Code:
  1. query.prepare("INSERT INTO garmin_packets (zulu_timestamp, unit_imei, packet_id, fmi_packet_id, unique_id, driver_idx, driver_status) "
  2. "VALUES (?, ?, ?, ?, ?, ?, ?)");
To copy to clipboard, switch view to plain text mode 

Application segfaults with
Qt Code:
  1. ==26283== Invalid read of size 8
  2. ==26283== at 0x4C288A0: QSqlResult::isForwardOnly() const (qsqlresult.cpp:551)
  3. ==26283== by 0x4C1A94F: QSqlQuery::isForwardOnly() const (qsqlquery.cpp:803)
  4. ==26283== by 0x4C1BC02: QSqlQuery::prepare(QString const&) (qsqlquery.cpp:895)
  5. ==26283== by 0x41D105: GarminFmi::d607_driver_status_update(QDataStream&) (garminfmi.cpp:613)
  6. ==26283== by 0x41F89D: GarminFmi::parseFmiPacket() (garminfmi.cpp:162)
  7. ==26283== by 0x418B6B: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
  8. ==26283== by 0x418FA2: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
  9. ==26283== by 0x419AE7: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
  10. ==26283== by 0x420B58: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cpp:86)
  11. ==26283== by 0x53089C9: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (qobject.cpp:3285)
  12. ==26283== by 0x4EF7D37: QAbstractSocketPrivate::canReadNotification() (qabstractsocket.cpp:626)
  13. ==26283== by 0x4EE6540: QReadNotifier::event(QEvent*) (qnativesocketengine.cpp:1094)
  14. ==26283== Address 0x8 is not stack'd, malloc'd or (recently) free'd
  15. ==26283==
  16. ==26283== Process terminating with default action of signal 11 (SIGSEGV)
  17. ==26283== Access not within mapped region at address 0x8
  18. ==26283== at 0x4C288A0: QSqlResult::isForwardOnly() const (qsqlresult.cpp:551)
  19. ==26283== by 0x4C1A94F: QSqlQuery::isForwardOnly() const (qsqlquery.cpp:803)
  20. ==26283== by 0x4C1BC02: QSqlQuery::prepare(QString const&) (qsqlquery.cpp:895)
  21. ==26283== by 0x41D105: GarminFmi::d607_driver_status_update(QDataStream&) (garminfmi.cpp:613)
  22. ==26283== by 0x41F89D: GarminFmi::parseFmiPacket() (garminfmi.cpp:162)
  23. ==26283== by 0x418B6B: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
  24. ==26283== by 0x418FA2: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
  25. ==26283== by 0x419AE7: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
  26. ==26283== by 0x420B58: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cpp:86)
  27. ==26283== by 0x53089C9: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (qobject.cpp:3285)
  28. ==26283== by 0x4EF7D37: QAbstractSocketPrivate::canReadNotification() (qabstractsocket.cpp:626)
  29. ==26283== by 0x4EE6540: QReadNotifier::event(QEvent*) (qnativesocketengine.cpp:1094)
To copy to clipboard, switch view to plain text mode 

Sorry for the long dump...

Now I've tested if the database was open ... no problems there...

Am I missing something altogether obvious?!

Any help appreciated