From kde-core-devel Fri Oct 16 07:43:59 2020 From: Albert Astals Cid Date: Fri, 16 Oct 2020 07:43:59 +0000 To: kde-core-devel Subject: Re: KPluginLoader UBSAN warnings (object has invalid vptr) Message-Id: <1660318.sNdzgxxGiN () xps> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=160283425017827 El dijous, 15 d=E2=80=99octubre de 2020, a les 16:22:59 CEST, Milian Wolff = va escriure: > Hey all, >=20 > I'm finally taking a bit of time to look after KDevelop again. I would mo= st=20 > notably like to make it ASAN/UBSAN clean. One thing I'm stumbling over ar= e the=20 > following reports: >=20 > ``` > /usr/include/KF5/KCoreAddons/kpluginfactory.h:545:24: runtime error: memb= er=20 > call on address 0x6030000f2d40 which does not point to an object of type= =20 > 'KPluginFactory' > 0x6030000f2d40: note: object has invalid vptr > 33 00 80 0f e0 31 d4 c3 5d 7f 00 00 a0 41 04 00 80 60 00 00 70 2d 0f = 00 30=20 > 60 00 00 00 00 00 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > invalid vptr > #0 0x7f5dede47d8c in KDevelop::IPlugin*=20 > KPluginFactory::create(QObject*, QList const= &) / > usr/include/KF5/KCoreAddons/kpluginfactory.h:545 > #1 0x7f5dede47d8c in=20 > KDevelop::PluginController::loadPluginInternal(QString const&) /home/mili= an/ > projects/kf5/src/extragear/kdevelop/kdevelop/kdevplatform/shell/ > plugincontroller.cpp:615 > ``` >=20 > Or this one: >=20 > ``` > /usr/include/qt/QtCore/qobject.h:524:12: runtime error: downcast of addre= ss=20 > 0x6060002922e0 which does not point to an object of type 'IPlugin' > 0x6060002922e0: note: object has invalid vptr > 36 00 80 24 b0 2f d4 c3 5d 7f 00 00 a0 42 04 00 80 60 00 00 b0 30 d4 = c3 5d=20 > 7f 00 00 80 fe 06 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > invalid vptr > #0 0x7f5dede47f20 in KDevelop::IPlugin*=20 > qobject_cast(QObject*) /usr/include/qt/QtCore/qobject= =2Eh: > 524 > #1 0x7f5dede47f20 in KDevelop::IPlugin*=20 > KPluginFactory::create(QObject*, QList const= &) / > usr/include/KF5/KCoreAddons/kpluginfactory.h:547 > ``` >=20 > I have the feeling that this might be a limitation of UBSAN? Or is this a= n=20 > actual problem - does anyone know? >=20 > Most notably, the kplugin* tests in kcoreaddons are UBSAN clean for me, w= hich=20 > is quite odd. I would expect them to raise similar warnings, but apparent= ly=20 > they don't. Or potentially it's simply that KDevelop plugins are way more= =20 > complex - we apparently are using multiple inheritance there for example: >=20 > ``` > class IPlugin : public QObject, public KXMLGUIClient > class AStylePlugin : public KDevelop::IPlugin, public=20 > KDevelop::ISourceFormatter > ``` >=20 > Maybe that's the problem? Does anyone know? I don't get any of those warnings (on starting kdevelop). What's your compile flags? I used cmake -DCMAKE_BUILD_TYPE=3DDebug -DECM_ENABLE_SANITIZERS=3D'address;undefin= ed' with gcc 10.2 About that warning i've seen it once and it was because the object i was ca= sting was still not totally created yet and thus wasn't of the target type = at that point. Cheers, Albert