Problems with [Q]GpgME and Qt6
-
(Crossposting to gnupg-users mailing list)
I have an app that works fine in Qt5. I use QGpgME to encrypt/decrypt messages and handle key usage. I'm trying to upgrade the app to Qt6, and, naturally, expected problems, but this one beats me.
Here, for example, is the code I use to retrieve my secret key list:
QGpgME::KeyListJob *job = QGpgME::openpgp()->keyListJob(false, false, false); // Prepare result vector std::vector<GpgME::Key> keys; // Execute it synchronously GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral(""), // No pattern: get all true, keys); // Only secret keys delete job;
Now, this is straight out of the "t-keylist.cpp" test file that comes with the GpgME source. It works perfectly well under Qt5. but under Qt6, it segfaults at the "job->exec" line.
Anyone have a clue why it crashes under Qt6?
Thanks,
--
Ron Murray rjmx@rjmx.net
PGP Fingerprint: 4D99 70E3 2317 334B 141E 7B63 12F7 E865 B5E2 E761 -
@rjmx said in Problems with [Q]GpgME and Qt6:
it segfaults at the "job->exec" line.
Where does your code verify the return result from
job = QGpgME::openpgp()->keyListJob(false, false, false);
fornullptr
?
Look at the stack trace in debugger when it segfaults. Are you saying it does on thejob->exec(...)
call or somewhere inside theexec()
function? -
@JonB Thanks for the reply.
The code doesn't check for a nullptr reply to the keyListJob() call (although I agree that it should), but I'd checked (stepping through the code) that the result was non-zero. Checking now, it comes back with a value of "job @0x555555dbf5d0", which seems reasonable.I'd looked at the stack trace before, but it didn't seem to tell me much. This time, it gets
1 QString::toUtf8_helper(QString const&) 0x7ffff5b63496 2 ?? 0x7ffff7ef6325 3 ?? 0x7ffff7eb9a60 4 ?? 0x7ffff7eba58f 5 ?? 0x7ffff7ebb67a 6 Cryptography::getKeyNames cryptography.cpp 53 0x55555557a082
Cryptography::getKeyNames() is the function I wrote that contains the code in question. It crashed immediately upon executing the job->exec() call.
Now I guess I need to figure out why it crashes on the QString::toUtf8_helper() call.
.....Ron
-
@rjmx @JonB
Further to this, this happens with all three occasions in this code, where I call QGpgME (finding secret keys, encryption and decryption), but the failing functions differ.Here's what happens with the decrypting function. The relevant code is
// Create the job QGpgME::DecryptJob *decryptjob = QGpgME::openpgp()->decryptJob(); // Execute it synchronously // decryptjob->exec: const QByteArray &cipherText, QByteArray &plainText GpgME::DecryptionResult decryptresult; decryptresult = decryptjob->exec(ciphertext, plaintext);
and the stack trace becomes
For the encryption task, the 1 QByteArray::operator=(QByteArray const&) 0x7ffff5b33540 2 ?? 0x7ffff7e9b10d 3 Cryptography::decrypt cryptography.cpp 203 0x55555557b1b2
For the encryption task, the code is
// encryptJob(/*ASCII Armor */false, /* Textmode */ false); // If 'recipient' is entry, GpgME does password encryption QGpgME::EncryptJob *encryptjob = QGpgME::openpgp()->encryptJob(true, true); QByteArray ciphertext, plaintext; plaintext = content.toUtf8(); GpgME::EncryptionResult encryptresult = encryptjob->exec(recipient, plaintext, false, ciphertext);
and the stack trace is
1 QString::toUtf8_helper(QString const&) 0x7ffff5b63496 2 ?? 0x7ffff7ef6325 3 ?? 0x7ffff7eb9a60 4 ?? 0x7ffff7eba58f 5 ?? 0x7ffff7ebb67a 6 Cryptography::encrypt cryptography.cpp 125 0x55555557a86c
Looks like there's a problem handling text, but not in the same function.
-
My guess is that you mix debug and release libraries which you should not do when using msvc.
-
@Christian-Ehrlicher Perhaps I should have said this earlier, but I’m doing this on Linux with gcc. All I can say is that I’ve changed nothing in the switch from Qt5 to Qt6 other than changing the kit (and fixing issues caused by a change in the calling arguments for QCalendarWidget::paintCell()).
Tomorrow, I’ll delve into the source code for QGpgME and see if I can see anything obvious. -
Ok, then are you sure QGpgME is compiled and linked against Qt6? Check with ldd.
-
@Christian-Ehrlicher
Good point. I'd checked with the Debian maintainers of gpgme, and they replied they were Qt6-compatible (at least, that was my understanding). Taking your advice to try ldd, however, I getron:~/$ ldd /usr/lib/x86_64-linux-gnu/libqgpgme.so.15 .. .. .. libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f8bcf600000)
So, Qt5Core but no mention of Qt6Core? That doesn't look good.
I'll look into rebuilding it myself, I think.