Reputation: 1
Creating a simple program with only a QMenuBar on top, I managed to get an issue detected by Valgring GBD.
Here is my program
main.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
mainwindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMenuBar>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QMenuBar *menuBar = new QMenuBar(this);
QMenu *menu = new QMenu(menuBar);
menu->setTitle("test");
menu->addAction("test1", this, SLOT(onTest1()));
menu->addAction("test2", this, SLOT(onTest2()));
menuBar->addMenu(menu);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onTest1()
{
qInfo("TEST1");
}
void MainWindow::onTest2()
{
qInfo("TEST2");
}
When I launch using "Valgrind Memory Analyzer with GBD", when clicking on the action "test1" or "test2", following error is detected :
==31965== Syscall param writev(vector[...]) points to uninitialised byte(s) ==31965== at 0x6BE040D: ??? (syscall-template.S:84) ==31965== by 0xBF97F28: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0) ==31965== by 0xBF9831C: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0) ==31965== by 0xBF98A76: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0) ==31965== by 0xBF98C43: xcb_flush (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0) ==31965== by 0xD573C2F: QXcbWindow::hide() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5XcbQpa.so.5.7.0) ==31965== by 0x578BE64: QWindow::setVisible(bool) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Gui.so.5.7.0) ==31965== by 0x4FC866E: QWidgetPrivate::hide_sys() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4FCE7AC: QWidgetPrivate::hide_helper() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4FD37E7: QWidget::setVisible(bool) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4FCEAE7: QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x50F3E3A: ??? (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x50F47DE: ??? (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x50F4AEB: ??? (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x50F87C5: QMenu::mouseReleaseEvent(QMouseEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4FD3B77: QWidget::event(QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x50F91CA: QMenu::event(QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4F8E52B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4F95807: QApplication::notify(QObject*, QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x60A2ADF: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Core.so.5.7.0) ==31965== by 0x4F947BE: QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer&, bool) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4FEF5FA: ??? (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4FF1512: ??? (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4F8E52B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x4F9521F: QApplication::notify(QObject*, QEvent*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== Address 0xcc97941 is 4,545 bytes inside a block of size 21,152 alloc'd ==31965== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==31965== by 0xBF978DB: xcb_connect_to_fd (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0) ==31965== by 0xBF9B610: xcb_connect_to_display_with_auth_info (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0) ==31965== by 0xB872809: _XConnectXCB (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0) ==31965== by 0xB863391: XOpenDisplay (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0) ==31965== by 0xD55F095: QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5XcbQpa.so.5.7.0) ==31965== by 0xD562AEA: QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5XcbQpa.so.5.7.0) ==31965== by 0xD31D3EA: ??? (in /home/lmartin/Qt/5.7/gcc_64/plugins/platforms/libqxcb.so) ==31965== by 0x577041A: QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Gui.so.5.7.0) ==31965== by 0x577D483: QGuiApplicationPrivate::createPlatformIntegration() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Gui.so.5.7.0) ==31965== by 0x577DF4C: QGuiApplicationPrivate::createEventDispatcher() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Gui.so.5.7.0) ==31965== by 0x60A89CC: QCoreApplicationPrivate::init() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Core.so.5.7.0) ==31965== by 0x577E8EB: QGuiApplicationPrivate::init() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Gui.so.5.7.0) ==31965== by 0x4F92988: QApplicationPrivate::init() (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0) ==31965== by 0x402B8D: main (main.cpp:6) ==31965== Uninitialised value was created by a stack allocation ==31965== at 0xD575DB0: non-virtual thunk to QXcbWindow::setVisible(bool) (in /home/lmartin/Qt/5.7/gcc_64/lib/libQt5XcbQpa.so.5.7.0) ==31965== ==31965== (action on error) vgdb me ... ==31965== Continuing ... { Memcheck:Param writev(vector[...])
obj:/lib/x86_64-linux-gnu/libc-2.23.so
obj:/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
obj:/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
obj:/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0 fun:xcb_flush
fun:_ZN10QXcbWindow4hideEv fun:_ZN7QWindow10setVisibleEb
fun:_ZN14QWidgetPrivate8hide_sysEv
fun:_ZN14QWidgetPrivate11hide_helperEv
fun:_ZN7QWidget10setVisibleEb
fun:_ZN14QWidgetPrivate12close_helperENS_9CloseModeE
obj:/home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0
obj:/home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0
obj:/home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0
fun:_ZN5QMenu17mouseReleaseEventEP11QMouseEvent
fun:_ZN7QWidget5eventEP6QEvent fun:_ZN5QMenu5eventEP6QEvent
fun:_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent
fun:_ZN12QApplication6notifyEP7QObjectP6QEvent
fun:_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent
fun:_ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_Eb obj:/home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0
obj:/home/lmartin/Qt/5.7/gcc_64/lib/libQt5Widgets.so.5.7.0
fun:_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent }
How could I proceed to fix that kind of issues?
Upvotes: 0
Views: 232