Segmentation fault while using QCA



  • I've been getting the following segmentation fault when compiling:

    "The inferior stopped because it received a signal from the Operating System.
    Signal name : SIGSEGV
    Signal meaning : Segmentation fault"

    Stacktrace:
    0 lockInline qmutex.h 187 0x7ffff7b3f33b
    1 QMutexLocker qmutex.h 109 0x7ffff7b3f33b
    2 QCA::init qca_core.cpp 185 0x7ffff7b3f33b
    3 RegistrationDialog::verifyKey registrationdialog.cpp 60 0x4b15e8

    following is the function:
    @bool RegistrationDialog::verifyKey(QString Registeredkey)
    {
    QString generated_key;
    QString mac_address = getMacAddress();

    // the Initializer object sets things up, and
    // also does cleanup when it goes out of scope
    QCA::Initializer init = QCA::Initializer();
    
    QString PassKey = "iXBv9TobQ545Fc4AB";
    QCA::SymmetricKey key(16);
    QCA::InitializationVector iv(PassKey.toLatin1());
    QCA::Cipher cipher(QString( "des" ), QCA::Cipher::CBC, QCA::Cipher::PKCS7, QCA::Encode, key, iv);
    
    
    // we use the first argument if provided, or
    // use "hello" if no arguments
    

    // QCA::SecureArray arg = (argc >= 2) ? argv[1] : "hello";
    QCA::SecureArray arg = mac_address.toUtf8();

    // DES testing
    if(!QCA::isSupported("des-cbc-pkcs7"))
        printf("DES-CBC not supported!\n");
    else {
    
        QCA::SecureArray u = cipher.update(arg);
    
        // We need to check if that update() call worked.
        if (!cipher.ok()) {
            qDebug()<<"Update failed";
        }
    
        QCA::SecureArray f = cipher.final();
    
        // Check if the final() call worked
        if (!cipher.ok()) {
            qDebug()<<"Final failed";
        }
    
        generated_key = qPrintable(QCA::arrayToHex(f.toByteArray()));
    
        if ( Registeredkey == generated_key ) {
            return true;
        } else {
            qDebug()<<"not true!";
            return false;
        }
    }
    
    return false;
    

    }@


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you building your program with Qt 5 and are you using QCA from your system ?



  • Thanks for the reply.
    Yes, I'm using Qt5. I'm using QCA from the system itself.


  • Lifetime Qt Champion

    Then you QCA is probably linked to Qt 4, which results in the crash (there was a "thread":http://qt-project.org/forums/viewthread/30218 about that not long ago)

    So you have two choices:

    • Build your application with Qt 4
    • Build your own version of QCA with Qt 5


  • I downloaded QCA source from the respective website. But, how to make it compile with Qt5?
    Or is this someway related to Qmutexlocker?


  • Lifetime Qt Champion

    No it's related to the fact that loading both Qt 4 and Qt 5 in the same address space is not supported.

    You'll have to follow the instructions provided, I have not yet built QCA with Qt 5


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.