×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Unhappy SIGSEGV in QCoreApplication

    Scenario:
    Qt Creator
    4.6.1
    Qt Console application

    I get only a few lines into the code and I get the SIGSEGV out of a QList operation in QCoreApplication.

    main:
    Code:
    int main(int argc, char *argv[]) {
        QCoreApplication a(argc, argv);
        VPrepDataBase prep(&a);
        prep.doit();
        // return a.exec();
        return 0;
    }
    Constructor and "doit" up to the point of the error:
    Code:
    VPrepDataBase::VPrepDataBase(QCoreApplication *parent) : QObject(parent) {
        propTrace = TraceHigh;
    }
    
    void VPrepDataBase::doit() {
        QTextStream outputStream(stdout);
    
        propSummaryExerciseRows = 0;
        propSummaryExerciseKwic = 0;
        propSummaryExerciseNodes = 0;
        propSummaryExerciseRadix = 0;
        propSummaryExerciseMaxTextLength = 0;
        propSummaryFoodRows = 0;
        propSummaryFoodKwic = 0;
        propSummaryFoodNodes = 0;
        propSummaryFoodRadix = 0;
        propSummaryFoodMaxTextLength = 0;
    
        propSkipWords = " ";
        propMaxKwic = 6;
    
        openDataBase();
    openDataBase:
    Code:
    void VPrepDataBase::openDataBase() {
        QTextStream outputStream(stdout);
        propDb = QSqlDatabase::addDatabase("QSQLITE");
        QString dbName("C:/QtProjects/PrepDataBase/wdb35x.db");
        propDb.setDatabaseName(dbName);
        if (!propDb.open()) {
            outputStream << "Database error " << propDb.lastError().text() << endl;
            return;
        }
        QSqlError error = propDb.lastError();
        if (error.isValid()) {
            outputStream << "Open error " << error.text() << endl;
            return;
        }
        ....
    The error occurs on "addDatabase". A breakpoint set at the next line is never hit.

    The stack:
    Code:
    0	QListData::isEmpty	qlist.h	91	0x6a2b163a	
    1	QList<QTranslator*>::isEmpty	qlist.h	134	0x6a2acc7d	
    2	QCoreApplication::translate	qcoreapplication.cpp	1735	0x6a1fec49	
    3	QCoreApplication::translate	qcoreapplication.cpp	1655	0x6a1fe97e	
    4	QMetaObject::tr	qmetaobject.cpp	281	0x6a201898	
    5	QLibrary::tr	qlibrary.h	64	0x6a29eb52	
    6	QLibraryPrivate::isPlugin	qlibrary.cpp	740	0x6a1f1c68	
    7	QFactoryLoader::update	qfactoryloader.cpp	130	0x6a1ed707	
    8	QFactoryLoader	qfactoryloader.cpp	99	0x6a1ed125	
    9	loader	qsqldatabase.cpp	102	0x640031c5	
    10	QSqlDatabasePrivate::init	qsqldatabase.cpp	778	0x64004998	
    11	QSqlDatabase	qsqldatabase.cpp	675	0x6400471d	
    12	QSqlDatabase::addDatabase	qsqldatabase.cpp	480	0x6400434b	
    13	VPrepDataBase::openDataBase	vprepdatabase.cpp	113	0x00401dad	
    14	VPrepDataBase::doit	vprepdatabase.cpp	39	0x00401646	
    15	main	main.cpp	7	0x004013fc
    The failing QListData operation:
    Code:
        inline bool isEmpty() const { return d->end  == d->begin; }
    The QListData "this" object looks flaky -- the address is apparently 0x58.

    Going back a couple of steps in the stack the QCoreApplication::translate code is executing this:
    Code:
        if (self && !self->d_func()->translators.isEmpty()) {
    (Can't quite figure out what "self" means in this context.)

    The code is apparently trying to translate the string "The file '%1' is not a valid Qt plugin." out of QLibraryPrivate::isPlugin().

    Looking back, QSqlDatabasePrivate::init() was passed the string "QSQLITE". It fails trying to invoke "loader()" here:
    Code:
    #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
        if (!driver && loader()) {
            if (QSqlDriverFactoryInterface *factory = qobject_cast<QSqlDriverFactoryInterface*>(loader()->instance(type)))
                driver = factory->create(type);
        }
    #endif // QT_NO_LIBRARY
    I haven't done enough by the point of the error, it would seem, to have stomped on storage, but it still fails. Tried logging off and back on and it still fails. (Haven't tried rebooting yet.)

    It was working and I made some unrelated changes (added more print statements -- after the point of the failure) and then it broke.

    Does this make any sense to anyone?

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: SIGSEGV in QCoreApplication

    Sigh! Cleaned the project and now it's working again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×