GCC segfault with adding qmlRegisterType for a QAbstractVideoFilter
-
Hello All,
I am having a difficult time adding a C++ filter which will expose video frames. Please, help. I am developing on a desktop as a host and the target is an iMX6 board. The OS for both is Ubuntu. I have ported the qmlvideofx example provided by Qt as a base application. From here, I want to add a QAbstractVideoFilter so that I can access the frames in the QMediaPlayer. I have two kits with this project, the Desktop Qt GCC 64bit (host) and an apalis-imx6 (target). When I run the Desktop version, it works as expected and I can access the frames. When I run the exact same code on the imx6 remotely, the GCC debugger segfaults in dl-debug.c on line 46 dl_debug_initialize.
/* Initialize _r_debug if it has not already been done. The argument is the run-time load address of the dynamic linker, to be put in _r_debug.r_ldbase. Returns the address of _r_debug. */ struct r_debug * internal_function _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) { struct r_debug *r; if (ns == LM_ID_BASE) r = &_r_debug; else r = &GL(dl_ns)[ns]._ns_debug; if (r->r_map == NULL || ldbase != 0) <<<<<<<<<<------- segfault { /* Tell the debugger where to find the map of loaded objects. */ r->r_version = 1 /* R_DEBUG_VERSION XXX */; r->r_ldbase = ldbase ?: _r_debug.r_ldbase; r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded; r->r_brk = (ElfW(Addr)) &_dl_debug_state; } return r; }
I suspect that the issue is more of an environment issue or maybe a compile/linker issue. The segfault happens before the first line of main is even called.
main.cpp
... includes ... #include "VideoFilterToSatellite.h" int main(int argc, char *argv[]) { QGuiApplication app ( argc, argv ); qmlRegisterType<VideoFilterToSatellite>("VideoFilter.ToSatellite", 1, 0, "VideoFilterToSatellite" ); QQuickView viewer; ...init viewer code... viewer.setSource ( QUrl ( QLatin1String ( "qrc:/qml/qmlvideofx/Main.qml" ) ) ); viewer.show (); // Delay invocation of init until the event loop has started, to work around // a GL context issue on Harmattan: without this, we get the following error // when the first ShaderEffectItem is created: // "QGLShaderProgram::addShader: Program and shader are not associated with same context" QMetaObject::invokeMethod ( rootObject, "init", Qt::QueuedConnection ); return app.exec(); }
.pro
TEMPLATE = app TARGET = MCS_Host QT += qml quick multimedia network CONFIG += c++11 CONFIG += qml_debug SOURCES += main.cpp \ filereader.cpp \ NetworkServer.cpp \ NetworkThread.cpp \ VideoFilterToSatellite.cpp RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target HEADERS += \ filereader.h \ NetworkServer.h \ NetworkThread.h \ trace.h \ VideoFilterToSatellite.h
The filter itself is doing nothing at all right now other than existing for the sake of minimalizing the possible issues during debug of this. The qmlvideofx project has their qml code in the qrc file and is a couple of directories deep (./qml/qmlvideofx/*.qml). QtCreator shows the import VideoFilter.ToSatellite 1.0 line in my qml files as red which might be related or it might just be a Creator. Again, it works on the Desktop kit and not the apalis-imx6 kit. Any and all help is welcome as I'm a day into this supposedly easy addition and I'm feeling frustrated that this issue is happening. I can't find what I'm missing or doing wrong. Thanks for any suggestions.
Cheers,
Pete -
Hi,
Pull the stack trace from the remote debugging session and paste it here. As a side question, do you have any globals that are supposed to be initialized (that's what_dl_debug_initialize
usually does), any globalQObject
derived classes?Kind regards.
-
I was asked to provide the filter. As a small step, the filter does nothing at all in order to offer the smallest amount of code to trigger the issue.
.h
#ifndef VIDEOFILTERTOSATELLITE_H #define VIDEOFILTERTOSATELLITE_H #include <QObject> #include <QAbstractVideoFilter> #include <QVideoFilterRunnable> #include <QDebug> #include <QSize> class VideoFilterToSatellite; class VideoFilterToSatelliteRunnable : public QVideoFilterRunnable { public: VideoFilterToSatelliteRunnable ( VideoFilterToSatellite* parent = 0 ); ~VideoFilterToSatelliteRunnable (); QVideoFrame run ( QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags ) Q_DECL_OVERRIDE; private: VideoFilterToSatellite* m_filterParent; }; class VideoFilterToSatellite : public QAbstractVideoFilter { Q_OBJECT public: explicit VideoFilterToSatellite ( QAbstractVideoFilter *parent = 0 ); QVideoFilterRunnable* createFilterRunnable (); }; #endif // VIDEOFILTERTOSATELLITE_H
.cpp
#include "VideoFilterToSatellite.h" VideoFilterToSatellite::VideoFilterToSatellite ( QAbstractVideoFilter *parent ) : QAbstractVideoFilter ( parent ) {} QVideoFilterRunnable* VideoFilterToSatellite::createFilterRunnable () { return reinterpret_cast<QVideoFilterRunnable*>( new VideoFilterToSatelliteRunnable ( this ) ); } VideoFilterToSatelliteRunnable::VideoFilterToSatelliteRunnable ( VideoFilterToSatellite* parent ) : m_filterParent ( parent ) {} VideoFilterToSatelliteRunnable::~VideoFilterToSatelliteRunnable() {} QVideoFrame VideoFilterToSatelliteRunnable::run ( QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags ) { Q_UNUSED ( surfaceFormat ); Q_UNUSED ( flags ); if (!input->isValid()) return *input; // future work return *input; }
I was given the recommendation to upgrade glibc as there is a bug in GCC with this given the version I am using. https://bugreports.qt.io/browse/QTBUG-55057
The issue there is that upon trying to upgrade glibc inside of Qt's boot2qt environment setup scripts, many things have failed. I changed the script /opt/Qt/5.7/Boot2Qt/sources/meta-b2qt/scripts/manifest.xml to grab yocto's krogoth instead of jethro. This has caused about ten failures which are really getting into Qt's Boot2Qt setup and how things inter-operate. I kinda think this is a task for Qt to update it's version of yocto it uses for Boot2Qt. Me messing with hooks I don't know all of the internal reasons of doesn't seem like the right choice to make.
Meanwhile, my system is not setup and I will need to rebuild things in order to get a stack trace. Again, thank you for the reply.