Results 1 to 15 of 15

Thread: QSqlQuery segfault

  1. #1
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSqlQuery segfault

    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

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSqlQuery segfault

    Try replacing offending line with
    Qt Code:
    1. QSqlQuery query( QSqlDatabase::database( "your_connection_name" ) );
    To copy to clipboard, switch view to plain text mode 
    or even
    Qt Code:
    1. QSqlQuery query( QSqlDatabase::database( this->connAvl->db.connectionName() ) );
    To copy to clipboard, switch view to plain text mode 
    and see what happens.

    I've seen problems when using cached database objects with QSqlQuery() (no idea why though) but QSqlDatabase::database() always saved the day for me.

  3. The following user says thank you to Spitfire for this useful post:

    pdoria (13th March 2012)

  4. #3
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlQuery segfault

    That was a good tip, but still no joy

    App still crashes at query.prepare() (which in turn calls isForwardOnly --> this is where the segfault pops up)

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlQuery segfault

    Clean your project and completely rebuild. Does the problem persist?

  6. #5
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: QSqlQuery segfault

    yes unfortunately

    yes unfortunately

    Now posting modifications to code (still segfaulting btw... ) and trace

    Modified the code so that the class had its own database connection (was using calling class connection, via passed pointer to it)
    This is running in its own thread, btw...

    declarations, extract:

    Qt Code:
    1. class GarminFmi
    2. {
    3. protected:
    4. TeltonikaUnit * connAvl; // this holds the connected AVL unit
    5. QString dbConnectionName;
    6. char dbUnique[76]; // a placeholder for generating a db connection unique name
    7. }
    To copy to clipboard, switch view to plain text mode 

    Class constructor, extract:

    Qt Code:
    1. GarminFmi::GarminFmi( QByteArray & fmiPacket, TeltonikaUnit * avl )
    2. {
    3. this->debug = true;
    4.  
    5. sprintf ( dbUnique, "DB%08x%08x", rand(), rand() );
    6. dbConnectionName=dbUnique;
    7. db = QSqlDatabase::addDatabase ( "QPSQL", dbUnique );
    8. db.setHostName ( "localhost" );
    9. db.setDatabaseName ( "lalala" );
    10. db.setUserName ( "lalala" );
    11. db.setPassword ( "lalala" );
    12. if ( !db.open() ) {
    13. printf ( "***********************************************\r\n" );
    14. printf ( "* CRITICAL ERROR! Cannot connect to database! *\r\n" );
    15. printf ( "***********************************************\r\n" );
    16. return;
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 


    Code that segfaults (namely on query.prepare() )
    Qt Code:
    1. driver_status_d607_receipt_data_type GarminFmi::d607_driver_status_update(QDataStream& stream)
    2. {
    3. QDateTime dateTime;
    4. QDateTime dateTimeStart;
    5. QString humanDate;
    6. QSqlQuery query( QSqlDatabase::database( this->db.connectionName() ) );
    7.  
    8. driver_status_d607_data_type driver_status;
    9.  
    10. qDebug() << this->db.connectionName();
    11.  
    12. stream >> driver_status.change_id
    13. >> driver_status.change_time
    14. >> driver_status.driver_status
    15. >> driver_status.driver_idx
    16. >> driver_status.reserved[0]
    17. >> driver_status.reserved[1]
    18. >> driver_status.reserved[3];
    19.  
    20. //! \note Date/Time starts at 1989-12-31 00:00:00
    21. dateTimeStart = QDateTime::fromString ( "M12d31y8900:00:00", "'M'M'd'd'y'yyhh:mm:ss" );
    22. quint32 start = dateTimeStart.toTime_t();
    23. dateTime=QDateTime::fromTime_t ( driver_status.change_time + start );
    24. humanDate = dateTime.toString ( "yyyy-MM-dd hh:mm:ss" );
    25.  
    26. // a little check.... ;)
    27. printf("Time: %s\r\n", humanDate.toLatin1().data());
    28. printf("Imei: %s\r\n", this->connAvl->data.imei.data());
    29. printf("Packet: %04x\r\n", ID_FMI_PACKET );
    30. printf("FMI Packet: %04x\r\n", FMI_A607_DRIVER_STATUS_UPDATE);
    31. printf("Change id: %d\r\n", driver_status.change_id);
    32. printf("Driver idx: %d\r\n", driver_status.driver_idx);
    33. printf("Driver status: %d\r\n", driver_status.driver_status);
    34.  
    35. // update garmin_packets table.
    36. QString sql = "INSERT INTO garmin_packets (zulu_timestamp, unit_imei, packet_id, fmi_packet_id, unique_id, driver_idx, driver_status) VALUES (?, ?, ?, ?, ?, ?, ?)";
    37. query.prepare( sql );
    38. query.bindValue(0, humanDate.toLatin1().data());
    39. query.bindValue(1, this->connAvl->data.imei.data());
    40. query.bindValue(2, ID_FMI_PACKET);
    41. query.bindValue(3, FMI_A607_DRIVER_STATUS_UPDATE);
    42. query.bindValue(4, driver_status.change_id);
    43. query.bindValue(5, driver_status.driver_idx);
    44. query.bindValue(6, driver_status.driver_status);
    45. query.exec ();
    46. printf("GOT PAST THIS!\r\n");
    47.  
    48. // cleanup
    49. query.clear();
    50.  
    51. // prepare the receipt data for this packet
    52. driver_status_d607_receipt_data_type receipt_data;
    53. receipt_data.status_change_id = driver_status.change_id;
    54. receipt_data.result_code = true;
    55. receipt_data.driver_idx = driver_status.driver_idx;
    56. receipt_data.reserved[0] = 0x0;
    57. receipt_data.reserved[1] = 0x0;
    58.  
    59. return receipt_data;
    60. }
    To copy to clipboard, switch view to plain text mode 


    Trace:
    Qt Code:
    1. ==20045== Invalid read of size 4
    2. ==20045== at 0x4147ACE9: QSqlQuery::prepare(QString const&) (in /usr/lib/libQtSql.so.4.7.4)
    3. ==20045== by 0x806466F: GarminFmi::parseFmiPacket() (garminfmi.cpp:186)
    4. ==20045== by 0x8052D70: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
    5. ==20045== by 0x80529AF: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
    6. ==20045== by 0x8051FF0: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
    7. ==20045== by 0x8067B35: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cxx:86)
    8. ==20045== by 0x4EDD928D: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /usr/lib/libQtCore.so.4.7.4)
    To copy to clipboard, switch view to plain text mode 

    I'm getting a unique connection to the DB, no problems there...
    It seems as if the query object isn't getting properly initialized?
    Results exactly the same on 32 and 64 bit platforms... (note the QT version on the libraries)

    What on earth could be causing query.prepare(), query.exec() to segfault?!

    Sorry for the very long post

    Thx in advance for any insight
    Last edited by pdoria; 15th March 2012 at 15:47.

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlQuery segfault

    I am confused.

    The trace indicates that the failure is occurring in GarminFmi::parseFmiPacket() (garminfmi.cpp:186) ultimately reached after a slot call to TeltonikaUnit::incomingData().
    You are posting a different function GarminFmi::d607_driver_status_update() telling us it fails there. The trace makes no mention of the function you have posted.

  8. The following user says thank you to ChrisW67 for this useful post:

    pdoria (16th March 2012)

  9. #7
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlQuery segfault

    Thank you Chris for taking the time to look into this

    the trace isn't all there due to space limitation ... going to post the caller fx and the complete trace in the next msg


    Added after 8 minutes:


    Calling extract:
    Qt Code:
    1. case FMI_A607_DRIVER_STATUS_UPDATE: {
    2. printf("Garmin sent FMI_A607_DRIVER_STATUS_UPDATE\r\n");
    3. driver_status_d607_receipt_data_type receipt_data;
    4. receipt_data = d607_driver_status_update ( stream ); // LINE 186
    5. msg_receipt = d607_driver_status_update_receipt( receipt_data );
    6. receipt = createSerialPacket(ID_FMI_PACKET, msg_receipt);
    7. break;
    8. }
    To copy to clipboard, switch view to plain text mode 

    full trace:
    Qt Code:
    1. ==3540== Conditional jump or move depends on uninitialised value(s)
    2. ==3540== at 0x4147ACEE: QSqlQuery::prepare(QString const&) (in /usr/lib/libQtSql.so.4.7.4)
    3. ==3540== by 0x806466F: GarminFmi::parseFmiPacket() (garminfmi.cpp:186)
    4. ==3540== by 0x8052D70: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
    5. ==3540== by 0x80529AF: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
    6. ==3540== by 0x8051FF0: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
    7. ==3540== by 0x8067AED: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cxx:86)
    8. ==3540== by 0x4EDD928D: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /usr/lib/libQtCore.so.4.7.4)
    9. ==3540== by 0x4063B1F: ???
    10. ==3540== Uninitialised value was created by a heap allocation
    11. ==3540== at 0x4006865: operator new(unsigned int) (vg_replace_malloc.c:255)
    12. ==3540== by 0x4020AF6: ??? (in /usr/lib/qt4/plugins/sqldrivers/libqsqlpsql.so)
    13. ==3540== by 0x402205F: ??? (in /usr/lib/qt4/plugins/sqldrivers/libqsqlpsql.so)
    14. ==3540== by 0x806466F: GarminFmi::parseFmiPacket() (garminfmi.cpp:186)
    15. ==3540== by 0x8052D70: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
    16. ==3540== by 0x80529AF: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
    17. ==3540== by 0x8051FF0: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
    18. ==3540== by 0x8067AED: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cxx:86)
    19. ==3540== by 0x4EDD928D: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /usr/lib/libQtCore.so.4.7.4)
    20. ==3540== by 0x4063B1F: ???
    21. ==3540==
    22. ==3540== Invalid read of size 4
    23. ==3540== at 0x4147ADB8: QSqlQuery::prepare(QString const&) (in /usr/lib/libQtSql.so.4.7.4)
    24. ==3540== by 0x806466F: GarminFmi::parseFmiPacket() (garminfmi.cpp:186)
    25. ==3540== by 0x8052D70: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
    26. ==3540== by 0x80529AF: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
    27. ==3540== by 0x8051FF0: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
    28. ==3540== by 0x8067AED: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cxx:86)
    29. ==3540== by 0x4EDD928D: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /usr/lib/libQtCore.so.4.7.4)
    30. ==3540== by 0x4063B1F: ???
    31. ==3540== Address 0x6b is not stack'd, malloc'd or (recently) free'd
    32. ==3540==
    33. ==3540==
    34. ==3540== Process terminating with default action of signal 11 (SIGSEGV)
    35. ==3540== Access not within mapped region at address 0x6B
    36. ==3540== at 0x4147ADB8: QSqlQuery::prepare(QString const&) (in /usr/lib/libQtSql.so.4.7.4)
    37. ==3540== by 0x806466F: GarminFmi::parseFmiPacket() (garminfmi.cpp:186)
    38. ==3540== by 0x8052D70: TeltonikaUnit::parseDataField(unsigned char, QDataStream&) (teltonikaunit.cpp:467)
    39. ==3540== by 0x80529AF: TeltonikaUnit::parseData(QByteArray&) (teltonikaunit.cpp:408)
    40. ==3540== by 0x8051FF0: TeltonikaUnit::incomingData() (teltonikaunit.cpp:277)
    41. ==3540== by 0x8067AED: TeltonikaUnit::qt_metacall(QMetaObject::Call, int, void**) (moc_teltonikaunit.cxx:86)
    42. ==3540== by 0x4EDD928D: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /usr/lib/libQtCore.so.4.7.4)
    43. ==3540== by 0x4063B1F: ???
    To copy to clipboard, switch view to plain text mode 

    that query.prepare() mentioned at the 1st line of the trace lives in driver_status_d607_receipt_data_type GarminFmi::d607_driver_status_update(QDataStream& stream) as shown in previous msgs

    I sure I'm overlooking something altogether too obvious...

    Thx for the help mate
    Last edited by pdoria; 16th March 2012 at 00:48.

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlQuery segfault

    Address 0x6b is not stack'd
    You have a null pointer somewhere (this? or this->connAvl?).


    And please give us a backtrace from the debugger and not from valgrind.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #9
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlQuery segfault

    Hi wysota! long time no see!

    Now I know you're gonna crucify me for this .... but ... how do I get a backtrace from the debugger?
    BR m8!

    EDIT: pls disregard... already downloading the 546MB debuginfo packages... (qt-debuginfo==356MB?? omg!)

    Should post the backtrace momentarily...


    Added after 18 minutes:


    that's all what I got:

    Qt Code:
    1. Program received signal SIGSEGV, Segmentation fault.
    2. [Switching to Thread 0xb7c9ab70 (LWP 3951)]
    3. 0x41487754 in QSqlResult::isForwardOnly (this=0x0) at kernel/qsqlresult.cpp:553
    4. 553 return d->forwardOnly;
    To copy to clipboard, switch view to plain text mode 


    Added after 36 minutes:


    a more meaningful trace:

    Qt Code:
    1. Thread 2 (Thread 0xb7c9ab70 (LWP 4399)):
    2. #0 0x41487754 in QSqlResult::isForwardOnly (this=0x746565) at kernel/qsqlresult.cpp:553
    3. No locals.
    4. #1 0x4147a281 in QSqlQuery::isForwardOnly (this=0xb7c999ec) at kernel/qsqlquery.cpp:804
    5. No locals.
    6. #2 0x4147ad00 in QSqlQuery::prepare (this=0xb7c999ec, query=...) at kernel/qsqlquery.cpp:899
    7. fo = <optimized out>
    8. #3 0x080669ba in GarminFmi::d607_driver_status_update (this=0xb7c99b84, stream=...) at /home/pdoria/projects/teltonika_tcp_server3_garmin_support/garminfmi.cpp:648
    9. dateTimeStart = {d = {d = 0xb7329840}}
    10. humanDate = {static null = {<No data fields>}, static shared_null = {ref = {_q_value = 1}, alloc = 0, size = 0, data = 0x8075552, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {
    11. 0}}, static shared_empty = {ref = {_q_value = 1}, alloc = 0, size = 0, data = 0x4ef088de, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0xb732d5f0,
    12. static codecForCStrings = 0x0}
    13. driver_status = {change_id = 9, change_time = 700752930, driver_status = 2, driver_idx = 0 '\000', reserved = "\000\000"}
    14. dateTime = {d = {d = 0xb7329ec0}}
    15. query = {d = 0xb731bf00}
    16. start = 631065600
    17. [B]sql = {static null = {<No data fields>[/B]}, static shared_null = {ref = {_q_value = 1}, alloc = 0, size = 0, data = 0x8075552, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}},
    18. static shared_empty = {ref = {_q_value = 1}, alloc = 0, size = 0, data = 0x4ef088de, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0xb7325b90,
    19. static codecForCStrings = 0x0}
    To copy to clipboard, switch view to plain text mode 

    sql == null????
    after
    Qt Code:
    1. QString sql = "INSERT INTO garmin_packets (zulu_timestamp, unit_imei, packet_id, fmi_packet_id, unique_id, driver_idx, driver_status) VALUES (?, ?, ?, ?, ?, ?, ?)";
    To copy to clipboard, switch view to plain text mode 
    ??
    Last edited by pdoria; 16th March 2012 at 02:19.

  12. #10
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSqlQuery segfault

    null (notice lower case) is actually a variable in the string put there for some compatibility reasons. It's just an empty structure - that's why it has no data fields.
    If you look at humanDate - it has the same static null variable with no fields. Any other string will have this.
    Name is confusing but that's not a reason for your problem.

    Edit:
    Btw do you implement your own QSqlDriver?
    Last edited by Spitfire; 16th March 2012 at 09:27.

  13. The following user says thank you to Spitfire for this useful post:

    pdoria (16th March 2012)

  14. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlQuery segfault

    Please post a full backtrace, not only the first frame.

    From what you can see here:
    0x41487754 in QSqlResult::isForwardOnly (this=0x0) at kernel/qsqlresult.cpp:553
    "this" is null so the QSqlResult object is invalid. If you look at the full backtrace and find where the trace leaves your code and enters Qt's, you'll pinpoint the problem in your code that is causing the faulty behaviour.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #12
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlQuery segfault

    Ok. the full backtrace is attached. Thx for taking the time to look at it
    Attached Files Attached Files

  16. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlQuery segfault

    Show us code around garminfmi.cpp:648

    Your "this" pointer has changed its value which suggests the problem is with an uninitialized and not a null pointer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. The following user says thank you to wysota for this useful post:

    pdoria (16th March 2012)

  18. #14
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Lightbulb [SOLVED] QSqlQuery segfault

    As usual one's blindness comes into play...
    found the bug.

    Qt Code:
    1. driver_status.reserved[3];
    To copy to clipboard, switch view to plain text mode 
    overstepped struct's boundaries here... :S
    the typedef:
    Qt Code:
    1. typedef struct /* D607 */
    2. {
    3. quint32 change_id; /* unique identifier */
    4. quint32 change_time; /* timestamp of status change */
    5. quint32 driver_status; /* ID corresponding to the new driver status */
    6. quint8 driver_idx;
    7. quint8 reserved[3]; /* set to 0 */
    8. } driver_status_d607_data_type;
    To copy to clipboard, switch view to plain text mode 

    Thx to all that took the time to look at this with special thanks to ChrisW67, wysota, Spitfire and sry about the noise...

  19. #15
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: [SOLVED] QSqlQuery segfault

    Nice to see you found the culprit. I was only getting more confused because your full gdb.txt does not contain the "this=0x0" that Wysota picked up on. You gotta love it.

Similar Threads

  1. Replies: 1
    Last Post: 18th July 2011, 12:12
  2. Segfault openGL
    By qtnewb in forum Qt Programming
    Replies: 1
    Last Post: 27th November 2010, 11:32
  3. QwtPlotMarker segfault
    By viridis in forum Qwt
    Replies: 4
    Last Post: 17th September 2008, 13:22
  4. Segfault
    By Dumbledore in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 07:31
  5. segfault
    By conexion2000 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2006, 12:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.