communi / libcommuni

A cross-platform IRC framework for Qt
https://communi.github.io
BSD 3-Clause "New" or "Revised" License
84 stars 37 forks source link

tst_IrcConnection::testSasl crashes on armv7hl #93

Closed pterjan closed 3 years ago

pterjan commented 3 years ago

It used to work fine but started crashing when we tried to rebuild it after Mageia got Qt 5.15.2, however this may not be the source of the problem as many other things changed since last time it was rebuilt 9 months earlier.

QWARN  : tst_IrcConnection::testSasl() QMetaObject::newInstance: type IrcCapabilityMessage does not inherit QObject

=== Received signal at function time: 1ms, total time: 134ms, dumping stack ===
=== End of stack trace ===
QFATAL : tst_IrcConnection::testSasl() Received signal 11
         Function time: 1ms Total time: 134ms
FAIL!  : tst_IrcConnection::testSasl() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 848 passed, 1 failed, 0 skipped, 0 blacklisted, 142ms
********* Finished testing of tst_IrcConnection *********
make[3]: *** [Makefile:299: check] Aborted (core dumped)
make[3]: Leaving directory '/home/iurt/rpmbuild/BUILD/libcommuni-3.5.0/tests/auto/ircconnection'
pterjan commented 3 years ago

I noticed a 3.6.0 was released 2 months ago, trying with it.

pterjan commented 3 years ago

Failure is the same with 3.6.0.

Thaodan commented 3 years ago

You should attach the backtrace that would help.

pterjan commented 3 years ago

I struggled to get a stack trace, after installing gdb it tries by itself to get one:

PASS   : tst_IrcConnection::testSocket(tcp)
PASS   : tst_IrcConnection::testSocket(ssl)
PASS   : tst_IrcConnection::testSecure()
QWARN  : tst_IrcConnection::testSasl() QMetaObject::newInstance: type IrcCapabilityMessage does not inherit QObject

=== Received signal at function time: 1ms, total time: 116ms, dumping stack ===
GNU gdb (GDB) 10.1-4.mga8 (Mageia release 8)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "armv7hl-mageia-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 16156
[New LWP 16164]
=== End of stack trace ===
QFATAL : tst_IrcConnection::testSasl() Received signal 11
         Function time: 1ms Total time: 116ms
FAIL!  : tst_IrcConnection::testSasl() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 848 passed, 1 failed, 0 skipped, 0 blacklisted, 486ms
********* Finished testing of tst_IrcConnection *********

And running tst_ircconnection under gdb causes it to exit early:

[iurt cauldron] iurtpktaa1~/rpmbuild/BUILD/libcommuni-3.6.0/tests/auto/ircconnection$ gdb ./tst_ircconnection 
GNU gdb (GDB) 10.1-4.mga8 (Mageia release 8)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "armv7hl-mageia-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./tst_ircconnection...
(gdb) run
Starting program: /home/iurt/rpmbuild/BUILD/libcommuni-3.6.0/tests/auto/ircconnection/tst_ircconnection 
[iurt cauldron] iurtpktaa1~/rpmbuild/BUILD/libcommuni-3.6.0/tests/auto/ircconnection$ echo $?
135

Running it in valgrind was more informative:

QWARN  : tst_IrcConnection::testSasl() QMetaObject::newInstance: type IrcCapabilityMessage does not inherit QObject
==30258== Invalid read of size 4
==30258==    at 0x48A135C: operator-> (qscopedpointer.h:118)
==30258==    by 0x48A135C: IrcMessage::fromData(QByteArray const&, IrcConnection*) (ircmessage.cpp:699)
==30258==    by 0x48BC04B: IrcProtocolPrivate::processLine(QByteArray const&) (ircprotocol.cpp:135)
==30258==    by 0x48BC963: IrcProtocolPrivate::readLines(QByteArray const&) (ircprotocol.cpp:117)
==30258==    by 0x48BCB3F: IrcProtocol::read() (ircprotocol.cpp:470)
==30258==    by 0x4D5F003: void doActivate<false>(QObject*, int, void**) (qobject.cpp:3898)
==30258==    by 0x49D112F: emitReadyRead (qabstractsocket.cpp:1323)
==30258==    by 0x49D112F: QAbstractSocketPrivate::canReadNotification() (qabstractsocket.cpp:748)
==30258==    by 0x49D3B3B: QAbstractSocket::waitForReadyRead(int) (qabstractsocket.cpp:2279)
==30258==    by 0x1DA9F: tst_IrcConnection::testSasl() (tst_ircconnection.cpp:434)
==30258==    by 0x4D333B3: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:2303)
==30258==    by 0x4A74787: invoke (qmetaobject.h:122)
==30258==    by 0x4A74787: QTest::TestMethods::invokeTestOnData(int) const (qtestcase.cpp:938)
==30258==    by 0x4A755EB: QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const (qtestcase.cpp:1166)
==30258==    by 0x4A760AF: QTest::TestMethods::invokeTests(QObject*) const (qtestcase.cpp:1507)
==30258==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
==30258== 
pterjan commented 3 years ago

I failed to enable debug output, but manually adding some logging the line being processed is ":irc.freenode.net CAP * LS :sasl".

I tried to dig further into the warning "QMetaObject::newInstance: type IrcCapabilityMessage does not inherit QObject" as the problem is qobject_cast<IrcMessage>(metaObject->newInstance(Q_ARG(IrcConnection, connection))); returning null. It is strange as IrcCapabilityMessage inherits from IrcMessage but I couldn't figure out what's going on (and being unfamiliar with Qt doesn't help).

jpnurmi commented 3 years ago

@pterjan Have you seen a similar warning for any other IrcMessage subclasses? IrcCapabilityMessage is certainly a QObject and the constructor is marked as Q_INVOKABLE.

jpnurmi commented 3 years ago

Is there by any chance a ready-made Mageia 8 image for Raspberry Pi?

pterjan commented 3 years ago

After disabling this test and testNoSasl I get a similar problem on IrcNoticeMessage in testStatus:

QWARN : tst_IrcConnection::testStatus() QMetaObject::newInstance: type IrcNoticeMessage does not inherit QObject

And unfortunately I am not aware of images, but if you have anything installed I have put a tar.gz that you can extract and chroot into at http://pkgsubmit.mageia.org/chroot_cauldron.armv7hl.0.20201227172138.tar.gz. The tar.gz is 422M and it takes 1.4G extacted.

pterjan commented 3 years ago

I added some debug logs confirming the metaObject is as expected: metaObject->className() is IrcCapabilityMessage metaObject->superClass()->className() is IrcMessage metaObject->superClass()->superClass()->className() is QObject

But at the following line it gives that warning that IrcCapabilityMessage does not inherit QObject

jpnurmi commented 3 years ago

For what it's worth, the problem doesn't occur with Qt 5.15.2 on x86_64. I'll try on ARM later.

pterjan commented 3 years ago

Yes the problem does not happen on aarch64, i586 or x86_64, I have only seen it on armv7

pterjan commented 3 years ago

After reading what triggers the warning I added some logging

https://github.com/qt/qtbase/blob/dev/src/corelib/kernel/qmetaobject.cpp#L244 https://github.com/qt/qtbase/blob/dev/src/corelib/kernel/qmetaobject.cpp#L350

I added:

        qCritical() << "&QObject::staticMetaObject: " << &QObject::staticMetaObject;
        qCritical() << "&metaObject->superClass()->superClass(): " << metaObject->superClass()->superClass();

And this doesn't make sense...

QSYSTEM: tst_IrcConnection::testSasl() &QObject::staticMetaObject:  0x6ea84
QSYSTEM: tst_IrcConnection::testSasl() &metaObject->superClass()->superClass():  0x6ea84
QWARN  : tst_IrcConnection::testSasl() QMetaObject::newInstance: type IrcCapabilityMessage does not inherit QObject

But whatever the problem is, it is very unlikely to be in communi...

jpnurmi commented 3 years ago

And unfortunately I am not aware of images, but if you have anything installed I have put a tar.gz that you can extract and chroot into at http://pkgsubmit.mageia.org/chroot_cauldron.armv7hl.0.20201227172138.tar.gz. The tar.gz is 422M and it takes 1.4G extacted.

Thanks, this helped me to setup an environment where I was able to reproduce the issue. I have pushed a fix: #94

pterjan commented 3 years ago

Thanks a lot for the fix!