Ich bin mit Laufzeitfehlern in meiner Qt-Anwendung festgefahren. Dies ist Teil meiner Valgrind-Ausgabe. Es gibt mehr davor, aber es ist viel zu posten.Valgrind ungültiger Lese- und Segmentierungsfehler mit QApplication
==13659== Invalid read of size 8
==13659== at 0x75E4085: QCoreApplication::arguments() (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x1B4E0114: ??? (in /usr/local/Qt/5.2.1/gcc_64/plugins/platforms/libqxcb.so)
==13659== by 0x1B4E10E8: ??? (in /usr/local/Qt/5.2.1/gcc_64/plugins/platforms/libqxcb.so)
==13659== by 0x1B9C0D2E: _SmcProcessMessage (in /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1)
==13659== by 0x1BBD48A5: IceProcessMessages (in /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0)
==13659== by 0x76096B0: QMetaObject::activate(QObject*, int, int, void**) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x767B1FD: QSocketNotifier::activated(int, QSocketNotifier::QPrivateSignal) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x7616840: QSocketNotifier::event(QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x65D20F3: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Widgets.so.5.2.1)
==13659== by 0x65D56AD: QApplication::notify(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Widgets.so.5.2.1)
==13659== by 0x75E0733: QCoreApplication::notifyInternal(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x7630A55: ??? (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== Address 0x178ddfb0 is 0 bytes after a block of size 16 alloc'd
==13659== at 0x4C28147: operator new[](unsigned long) (vg_replace_malloc.c:348)
==13659== by 0x4FAD41: GUIApp::init() (GUIApp.cpp:73)
==13659== by 0x423009: main (main.cpp:121)
==13659==
==13659== Invalid read of size 1
==13659== at 0x4C294E2: strlen (mc_replace_strmem.c:390)
==13659== by 0x75E409B: QCoreApplication::arguments() (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x1B4E0114: ??? (in /usr/local/Qt/5.2.1/gcc_64/plugins/platforms/libqxcb.so)
==13659== by 0x1B4E10E8: ??? (in /usr/local/Qt/5.2.1/gcc_64/plugins/platforms/libqxcb.so)
==13659== by 0x1B9C0D2E: _SmcProcessMessage (in /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1)
==13659== by 0x1BBD48A5: IceProcessMessages (in /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0)
==13659== by 0x76096B0: QMetaObject::activate(QObject*, int, int, void**) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x767B1FD: QSocketNotifier::activated(int, QSocketNotifier::QPrivateSignal) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x7616840: QSocketNotifier::event(QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x65D20F3: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Widgets.so.5.2.1)
==13659== by 0x65D56AD: QApplication::notify(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Widgets.so.5.2.1)
==13659== by 0x75E0733: QCoreApplication::notifyInternal(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== Address 0x50 is not stack'd, malloc'd or (recently) free'd
==13659==
==13659==
==13659== Process terminating with default action of signal 11 (SIGSEGV)
==13659== Access not within mapped region at address 0x50
==13659== at 0x4C294E2: strlen (mc_replace_strmem.c:390)
==13659== by 0x75E409B: QCoreApplication::arguments() (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x1B4E0114: ??? (in /usr/local/Qt/5.2.1/gcc_64/plugins/platforms/libqxcb.so)
==13659== by 0x1B4E10E8: ??? (in /usr/local/Qt/5.2.1/gcc_64/plugins/platforms/libqxcb.so)
==13659== by 0x1B9C0D2E: _SmcProcessMessage (in /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1)
==13659== by 0x1BBD48A5: IceProcessMessages (in /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0)
==13659== by 0x76096B0: QMetaObject::activate(QObject*, int, int, void**) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x767B1FD: QSocketNotifier::activated(int, QSocketNotifier::QPrivateSignal) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x7616840: QSocketNotifier::event(QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== by 0x65D20F3: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Widgets.so.5.2.1)
==13659== by 0x65D56AD: QApplication::notify(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Widgets.so.5.2.1)
==13659== by 0x75E0733: QCoreApplication::notifyInternal(QObject*, QEvent*) (in /usr/local/Qt/5.2.1/gcc_64/lib/libQt5Core.so.5.2.1)
==13659== If you believe this happened as a result of a stack
==13659== overflow in your program's main thread (unlikely but
==13659== possible), you can try to increase the size of the
==13659== main thread stack using the --main-stacksize= flag.
==13659== The main thread stack size used in this run was 8388608.
Ich bin porting code Qt3 to Qt5 and from 32-bit to 64-bit.
Linie 73 in meinem Code ist unter test = new char*[2];
.
Mein Programm scheint mit Segmentierung Fehler auf dem showFullScreen()
Anruf abstürzen.
Könnte die Verwendung der Variablen test
die Ursache der Valgrind-Ausgabe und des Programmabsturzes sein? Ist die Form von Argc und Argv auf 64-Bit-Linux die gleiche wie 32-Bit?
void GUIApp::init()
{
QApplication::setStyle("motif");
int nbrparams=1;
test = new char*[2];
test[0] = new char[100];
test[1] = new char[100];
printf(" Test : %d\n", (int)sizeof test); // Test : 8
printf(" *Test : %d\n", (int)sizeof *test); // *Test : 8
printf("**Test : %d\n", (int)sizeof **test); // **Test : 1
strcpy(test[0], "gv_GUI");
go_app = new QApplication(nbrparams,test);
translator = new QTranslator(0);
// load translation file, make sure that this symbolic link points to the desired translation file
if (translator->load("tt2_go.qm")) {
go_app->installTranslator(translator);
}
gaw = new GO_QT_Application_Widget(GO_GUI_MODE, mytalkbackptr, NULL, "QTApp");
gaw->init();
gaw->startup();
gaw->move(0,0);
gaw->setFixedSize(3200,1200);
gaw->showFullScreen();
init_done = true;
}
Dies funktioniert immer noch nicht - QApplication nimmt argc als Referenz und erwartet, dass es immer gültig ist. – peppe
Vorgeschlagene Umschreibungsänderungen Valgrind-Ausgabe, Programm stürzt jedoch ab. Ich neige dazu zu glauben, dass argv nicht die Ursache meines Problems ist. Außerdem: warning: Konvertierung von Zeichenfolgenliteral in 'char *' ist veraltet [-Wrepreced-writable-strings] char * progName = "gvs_GUI"; –