How to check memory leaks in simple Qt Widget application using Valgrind?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I never use Valgrind before and today I tried to check memory leaks in simple Qt Widget application generated by Qt Creator. I created project by following steps:
- I've got Qt Creator v4.8.1 based on Qt 5.12.0. In Qt Creator I chose following menu item: File -> New File or Project... -> Application -> Qt Widgets Application. Then I pressed Choose... -> Next -> ... -> Finish. Qt Creator generated following source code:
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"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.ui
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
untitled.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-06T15:14:11
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES +=
main.cpp
mainwindow.cpp
HEADERS +=
mainwindow.h
FORMS +=
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
- I compiled this project by GCC 8.2.0 toolchain in 'Debug mode' on Ubuntu 18.10.
Then i tried to run compiled program by following command:
$ valgrind ./untitled
Result of this operations on Ubuntu 18.10 is:
==12228== Memcheck, a memory error detector
==12228== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12228== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==12228== Command: ./untitled
==12228==
==12228==
==12228== Process terminating with default action of signal 11 (SIGSEGV)
==12228== General Protection Fault
==12228== at 0x15C006A7: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DBC5: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DFEB: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x154B3172: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x159AF457: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587E5B1: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587984D: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x14F8BD3D: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F63C52: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5F323: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5FD3C: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14CFECF1: QXcbGlxWindow::createVisual() (in /opt/Software/Qt/5.12.0/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so)
==12228==
==12228== HEAP SUMMARY:
==12228== in use at exit: 3,561,397 bytes in 44,679 blocks
==12228== total heap usage: 347,392 allocs, 302,713 frees, 29,095,722 bytes allocated
==12228==
==12228== LEAK SUMMARY:
==12228== definitely lost: 14,216 bytes in 80 blocks
==12228== indirectly lost: 4,334 bytes in 203 blocks
==12228== possibly lost: 28,587 bytes in 457 blocks
==12228== still reachable: 3,448,988 bytes in 43,405 blocks
==12228== of which reachable via heuristic:
==12228== length64 : 3,376 bytes in 61 blocks
==12228== newarray : 2,048 bytes in 48 blocks
==12228== suppressed: 0 bytes in 0 blocks
==12228== Rerun with --leak-check=full to see details of leaked memory
==12228==
==12228== For counts of detected and suppressed errors, rerun with: -v
==12228== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 4)
Segmentation fault (core dumped)
What am I doing wrong?
c++ qt segmentation-fault valgrind
migrated from superuser.com Feb 6 at 13:28
This question came from our site for computer enthusiasts and power users.
|
show 9 more comments
I never use Valgrind before and today I tried to check memory leaks in simple Qt Widget application generated by Qt Creator. I created project by following steps:
- I've got Qt Creator v4.8.1 based on Qt 5.12.0. In Qt Creator I chose following menu item: File -> New File or Project... -> Application -> Qt Widgets Application. Then I pressed Choose... -> Next -> ... -> Finish. Qt Creator generated following source code:
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"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.ui
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
untitled.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-06T15:14:11
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES +=
main.cpp
mainwindow.cpp
HEADERS +=
mainwindow.h
FORMS +=
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
- I compiled this project by GCC 8.2.0 toolchain in 'Debug mode' on Ubuntu 18.10.
Then i tried to run compiled program by following command:
$ valgrind ./untitled
Result of this operations on Ubuntu 18.10 is:
==12228== Memcheck, a memory error detector
==12228== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12228== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==12228== Command: ./untitled
==12228==
==12228==
==12228== Process terminating with default action of signal 11 (SIGSEGV)
==12228== General Protection Fault
==12228== at 0x15C006A7: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DBC5: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DFEB: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x154B3172: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x159AF457: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587E5B1: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587984D: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x14F8BD3D: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F63C52: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5F323: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5FD3C: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14CFECF1: QXcbGlxWindow::createVisual() (in /opt/Software/Qt/5.12.0/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so)
==12228==
==12228== HEAP SUMMARY:
==12228== in use at exit: 3,561,397 bytes in 44,679 blocks
==12228== total heap usage: 347,392 allocs, 302,713 frees, 29,095,722 bytes allocated
==12228==
==12228== LEAK SUMMARY:
==12228== definitely lost: 14,216 bytes in 80 blocks
==12228== indirectly lost: 4,334 bytes in 203 blocks
==12228== possibly lost: 28,587 bytes in 457 blocks
==12228== still reachable: 3,448,988 bytes in 43,405 blocks
==12228== of which reachable via heuristic:
==12228== length64 : 3,376 bytes in 61 blocks
==12228== newarray : 2,048 bytes in 48 blocks
==12228== suppressed: 0 bytes in 0 blocks
==12228== Rerun with --leak-check=full to see details of leaked memory
==12228==
==12228== For counts of detected and suppressed errors, rerun with: -v
==12228== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 4)
Segmentation fault (core dumped)
What am I doing wrong?
c++ qt segmentation-fault valgrind
migrated from superuser.com Feb 6 at 13:28
This question came from our site for computer enthusiasts and power users.
The program is crashing:Process terminating with default action of signal 11 (SIGSEGV)
. Do you know why? If so, fix it first.
– user3132457
Feb 6 at 16:15
I use the default template of a QWidget application that Qt Creator creates. Without Valgrind it works normally and don't receive SIGSEGV.
– Dmitry Jakovlev
Feb 7 at 8:17
Show the code you're using (update the post).
– user3132457
Feb 7 at 16:59
I've updated original post. Thank you for your advice and efforts to help me :)
– Dmitry Jakovlev
Feb 8 at 9:32
1
I've built your code with the usualqmake
followed bymake
and then run Valgrind and didn't get SIGSEGV. Try to clean the directory from the generated files and build again. Also, what exact commands are you using to build the program?
– user3132457
Feb 9 at 7:20
|
show 9 more comments
I never use Valgrind before and today I tried to check memory leaks in simple Qt Widget application generated by Qt Creator. I created project by following steps:
- I've got Qt Creator v4.8.1 based on Qt 5.12.0. In Qt Creator I chose following menu item: File -> New File or Project... -> Application -> Qt Widgets Application. Then I pressed Choose... -> Next -> ... -> Finish. Qt Creator generated following source code:
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"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.ui
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
untitled.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-06T15:14:11
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES +=
main.cpp
mainwindow.cpp
HEADERS +=
mainwindow.h
FORMS +=
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
- I compiled this project by GCC 8.2.0 toolchain in 'Debug mode' on Ubuntu 18.10.
Then i tried to run compiled program by following command:
$ valgrind ./untitled
Result of this operations on Ubuntu 18.10 is:
==12228== Memcheck, a memory error detector
==12228== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12228== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==12228== Command: ./untitled
==12228==
==12228==
==12228== Process terminating with default action of signal 11 (SIGSEGV)
==12228== General Protection Fault
==12228== at 0x15C006A7: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DBC5: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DFEB: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x154B3172: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x159AF457: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587E5B1: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587984D: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x14F8BD3D: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F63C52: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5F323: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5FD3C: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14CFECF1: QXcbGlxWindow::createVisual() (in /opt/Software/Qt/5.12.0/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so)
==12228==
==12228== HEAP SUMMARY:
==12228== in use at exit: 3,561,397 bytes in 44,679 blocks
==12228== total heap usage: 347,392 allocs, 302,713 frees, 29,095,722 bytes allocated
==12228==
==12228== LEAK SUMMARY:
==12228== definitely lost: 14,216 bytes in 80 blocks
==12228== indirectly lost: 4,334 bytes in 203 blocks
==12228== possibly lost: 28,587 bytes in 457 blocks
==12228== still reachable: 3,448,988 bytes in 43,405 blocks
==12228== of which reachable via heuristic:
==12228== length64 : 3,376 bytes in 61 blocks
==12228== newarray : 2,048 bytes in 48 blocks
==12228== suppressed: 0 bytes in 0 blocks
==12228== Rerun with --leak-check=full to see details of leaked memory
==12228==
==12228== For counts of detected and suppressed errors, rerun with: -v
==12228== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 4)
Segmentation fault (core dumped)
What am I doing wrong?
c++ qt segmentation-fault valgrind
I never use Valgrind before and today I tried to check memory leaks in simple Qt Widget application generated by Qt Creator. I created project by following steps:
- I've got Qt Creator v4.8.1 based on Qt 5.12.0. In Qt Creator I chose following menu item: File -> New File or Project... -> Application -> Qt Widgets Application. Then I pressed Choose... -> Next -> ... -> Finish. Qt Creator generated following source code:
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"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.ui
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
untitled.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-06T15:14:11
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES +=
main.cpp
mainwindow.cpp
HEADERS +=
mainwindow.h
FORMS +=
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
- I compiled this project by GCC 8.2.0 toolchain in 'Debug mode' on Ubuntu 18.10.
Then i tried to run compiled program by following command:
$ valgrind ./untitled
Result of this operations on Ubuntu 18.10 is:
==12228== Memcheck, a memory error detector
==12228== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12228== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==12228== Command: ./untitled
==12228==
==12228==
==12228== Process terminating with default action of signal 11 (SIGSEGV)
==12228== General Protection Fault
==12228== at 0x15C006A7: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DBC5: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x15C0DFEB: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x154B3172: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x159AF457: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587E5B1: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x1587984D: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==12228== by 0x14F8BD3D: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F63C52: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5F323: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14F5FD3C: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==12228== by 0x14CFECF1: QXcbGlxWindow::createVisual() (in /opt/Software/Qt/5.12.0/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so)
==12228==
==12228== HEAP SUMMARY:
==12228== in use at exit: 3,561,397 bytes in 44,679 blocks
==12228== total heap usage: 347,392 allocs, 302,713 frees, 29,095,722 bytes allocated
==12228==
==12228== LEAK SUMMARY:
==12228== definitely lost: 14,216 bytes in 80 blocks
==12228== indirectly lost: 4,334 bytes in 203 blocks
==12228== possibly lost: 28,587 bytes in 457 blocks
==12228== still reachable: 3,448,988 bytes in 43,405 blocks
==12228== of which reachable via heuristic:
==12228== length64 : 3,376 bytes in 61 blocks
==12228== newarray : 2,048 bytes in 48 blocks
==12228== suppressed: 0 bytes in 0 blocks
==12228== Rerun with --leak-check=full to see details of leaked memory
==12228==
==12228== For counts of detected and suppressed errors, rerun with: -v
==12228== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 4)
Segmentation fault (core dumped)
What am I doing wrong?
c++ qt segmentation-fault valgrind
c++ qt segmentation-fault valgrind
edited Feb 8 at 9:58
Dmitry Jakovlev
asked Feb 6 at 12:15
Dmitry JakovlevDmitry Jakovlev
62
62
migrated from superuser.com Feb 6 at 13:28
This question came from our site for computer enthusiasts and power users.
migrated from superuser.com Feb 6 at 13:28
This question came from our site for computer enthusiasts and power users.
The program is crashing:Process terminating with default action of signal 11 (SIGSEGV)
. Do you know why? If so, fix it first.
– user3132457
Feb 6 at 16:15
I use the default template of a QWidget application that Qt Creator creates. Without Valgrind it works normally and don't receive SIGSEGV.
– Dmitry Jakovlev
Feb 7 at 8:17
Show the code you're using (update the post).
– user3132457
Feb 7 at 16:59
I've updated original post. Thank you for your advice and efforts to help me :)
– Dmitry Jakovlev
Feb 8 at 9:32
1
I've built your code with the usualqmake
followed bymake
and then run Valgrind and didn't get SIGSEGV. Try to clean the directory from the generated files and build again. Also, what exact commands are you using to build the program?
– user3132457
Feb 9 at 7:20
|
show 9 more comments
The program is crashing:Process terminating with default action of signal 11 (SIGSEGV)
. Do you know why? If so, fix it first.
– user3132457
Feb 6 at 16:15
I use the default template of a QWidget application that Qt Creator creates. Without Valgrind it works normally and don't receive SIGSEGV.
– Dmitry Jakovlev
Feb 7 at 8:17
Show the code you're using (update the post).
– user3132457
Feb 7 at 16:59
I've updated original post. Thank you for your advice and efforts to help me :)
– Dmitry Jakovlev
Feb 8 at 9:32
1
I've built your code with the usualqmake
followed bymake
and then run Valgrind and didn't get SIGSEGV. Try to clean the directory from the generated files and build again. Also, what exact commands are you using to build the program?
– user3132457
Feb 9 at 7:20
The program is crashing:
Process terminating with default action of signal 11 (SIGSEGV)
. Do you know why? If so, fix it first.– user3132457
Feb 6 at 16:15
The program is crashing:
Process terminating with default action of signal 11 (SIGSEGV)
. Do you know why? If so, fix it first.– user3132457
Feb 6 at 16:15
I use the default template of a QWidget application that Qt Creator creates. Without Valgrind it works normally and don't receive SIGSEGV.
– Dmitry Jakovlev
Feb 7 at 8:17
I use the default template of a QWidget application that Qt Creator creates. Without Valgrind it works normally and don't receive SIGSEGV.
– Dmitry Jakovlev
Feb 7 at 8:17
Show the code you're using (update the post).
– user3132457
Feb 7 at 16:59
Show the code you're using (update the post).
– user3132457
Feb 7 at 16:59
I've updated original post. Thank you for your advice and efforts to help me :)
– Dmitry Jakovlev
Feb 8 at 9:32
I've updated original post. Thank you for your advice and efforts to help me :)
– Dmitry Jakovlev
Feb 8 at 9:32
1
1
I've built your code with the usual
qmake
followed by make
and then run Valgrind and didn't get SIGSEGV. Try to clean the directory from the generated files and build again. Also, what exact commands are you using to build the program?– user3132457
Feb 9 at 7:20
I've built your code with the usual
qmake
followed by make
and then run Valgrind and didn't get SIGSEGV. Try to clean the directory from the generated files and build again. Also, what exact commands are you using to build the program?– user3132457
Feb 9 at 7:20
|
show 9 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54554787%2fhow-to-check-memory-leaks-in-simple-qt-widget-application-using-valgrind%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54554787%2fhow-to-check-memory-leaks-in-simple-qt-widget-application-using-valgrind%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The program is crashing:
Process terminating with default action of signal 11 (SIGSEGV)
. Do you know why? If so, fix it first.– user3132457
Feb 6 at 16:15
I use the default template of a QWidget application that Qt Creator creates. Without Valgrind it works normally and don't receive SIGSEGV.
– Dmitry Jakovlev
Feb 7 at 8:17
Show the code you're using (update the post).
– user3132457
Feb 7 at 16:59
I've updated original post. Thank you for your advice and efforts to help me :)
– Dmitry Jakovlev
Feb 8 at 9:32
1
I've built your code with the usual
qmake
followed bymake
and then run Valgrind and didn't get SIGSEGV. Try to clean the directory from the generated files and build again. Also, what exact commands are you using to build the program?– user3132457
Feb 9 at 7:20