Results 1 to 19 of 19

Thread: SIGSEGV Error: Very Strange

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default SIGSEGV Error: Very Strange

    MainWindow.h
    Qt Code:
    1. #include <QMainWindow>
    2.  
    3. class MainWindow : public QMainWindow
    4. {
    5. Q_OBJECT
    6. public:
    7. explicit MainWindow(QWidget *parent = 0);
    8. };
    To copy to clipboard, switch view to plain text mode 

    MainWindow.cpp
    Qt Code:
    1. #include "MainWindow.h"
    2.  
    3. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
    4. {
    5. #ifdef QT_DEBUG
    6. setWindowTitle("DEBUG");
    7. #else
    8. setWindowTitle("RELEASE");
    9. #endif
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

    Application.h
    Qt Code:
    1. #include <QApplication>
    2.  
    3. class MainWindow;
    4.  
    5. class Application : public QApplication
    6. {
    7. public:
    8. Application(int argc, char** argv);
    9. ~Application();
    10. MainWindow* mainWindow() const;
    11. private:
    12. MainWindow* _mainWindow;
    13. };
    To copy to clipboard, switch view to plain text mode 
    Application.cpp
    Qt Code:
    1. #include "Application.h"
    2. #include "MainWindow.h"
    3.  
    4. Application::Application(int argc, char** argv) : QApplication(argc, argv)
    5. {
    6. _mainWindow = new MainWindow;
    7. }
    8.  
    9. Application::~Application(){
    10. delete _mainWindow;
    11. _mainWindow = 0;
    12. }
    13.  
    14. MainWindow * Application::mainWindow() const
    15. {
    16. return _mainWindow;
    17. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include "Application.h"
    2. #include "MainWindow.h"
    3.  
    4. int main(int argc, char** argv)
    5. {
    6. Application app(argc, argv);
    7. app.mainWindow()->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 


    The code above run perfectly fine under release build, but will cause SIGSEGV Error everytime under debug build.
    My system is Ubuntu 11.04 64-bits, Qt 4.8/4.7.4

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: SIGSEGV Error: Very Strange

    When does SIGSEGV error occur?

    You need to have virtual destructor
    Qt Code:
    1. virtual ~Application()
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Re: SIGSEGV Error: Very Strange

    Quote Originally Posted by Santosh Reddy View Post
    When does SIGSEGV error occur?

    You need to have virtual destructor
    Qt Code:
    1. virtual ~Application()
    To copy to clipboard, switch view to plain text mode 
    Exact same thing happens even after I added virtual.
    The error occur in qwidget.h at line 494
    Qt Code:
    1. inline void show() { setVisible(true); }
    To copy to clipboard, switch view to plain text mode 

    basically when I call "app.mainWindow()->show();" in main.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SIGSEGV Error: Very Strange

    Does app.mainWindow() return a non-null pointer?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Re: SIGSEGV Error: Very Strange

    Quote Originally Posted by wysota View Post
    Does app.mainWindow() return a non-null pointer?
    Yes, it is not null.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SIGSEGV Error: Very Strange

    What does the backtrace say?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Re: SIGSEGV Error: Very Strange

    Quote Originally Posted by wysota View Post
    What does the backtrace say?
    Qt Code:
    1. Thread 1 (Thread 0x7ffff7fca7a0 (LWP 12791)):
    2. #0 0x00007ffff5d9b49f in ?? () from /lib/x86_64-linux-gnu/libc.so.6
    3. No symbol table info available.
    4. #1 0x00007ffff4310382 in XSetCommand () from /usr/lib/x86_64-linux-gnu/libX11.so.6
    5. No symbol table info available.
    6. #2 0x00007ffff4315169 in XSetWMProperties () from /usr/lib/x86_64-linux-gnu/libX11.so.6
    7. No symbol table info available.
    8. #3 0x00007ffff735420a in QWidgetPrivate::create_sys(unsigned long, bool, bool) () from /usr/local/Trolltech/Qt-4.8.0/lib/libQtGui.so.4
    9. No symbol table info available.
    10. #4 0x00007ffff73058e5 in QWidget::create(unsigned long, bool, bool) () from /usr/local/Trolltech/Qt-4.8.0/lib/libQtGui.so.4
    11. No symbol table info available.
    12. #5 0x00007ffff730f3d1 in QWidget::setVisible(bool) () from /usr/local/Trolltech/Qt-4.8.0/lib/libQtGui.so.4
    13. No symbol table info available.
    14. #6 0x0000000000402a5c in QWidget::show (this=0x609ab0) at /usr/local/Trolltech/Qt-4.8.0/include/QtGui/qwidget.h:494
    15. No locals.
    16. #7 0x00000000004029fd in main (argc=1, argv=0x7fffffffe6e8) at Main.cpp:7
    17. app = {<QApplication> = {<No data fields>}, _mainWindow = 0x609ab0}
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SIGSEGV Error: Very Strange

    Does it work if you use a stable version of Qt?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default Re: SIGSEGV Error: Very Strange

    Quote Originally Posted by wysota View Post
    Does it work if you use a stable version of Qt?
    Same result with Qt 4.7.4

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SIGSEGV Error: Very Strange

    It seems odd the application crashes when setting window properties. What window manager are you using? Does the program work if you rewrite it as:

    Qt Code:
    1. int main(int argc, char **argv) {
    2. QApplication app(argc, argv);
    3. mw.setWindowTitle("DEBUG");
    4. mw.show();
    5. return app.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt OpenCV SIGSEGV error help
    By bobo in forum Newbie
    Replies: 3
    Last Post: 13th June 2011, 20:03
  2. Strange Error
    By keeperofthegrove in forum Newbie
    Replies: 4
    Last Post: 22nd October 2008, 14:16
  3. strange QT error out of nowhere
    By Penut in forum Qt Programming
    Replies: 5
    Last Post: 14th August 2008, 01:46
  4. Strange error
    By joseph in forum General Programming
    Replies: 3
    Last Post: 8th February 2008, 13:32
  5. Strange Make Error: ld.exe?
    By Backslash in forum Newbie
    Replies: 2
    Last Post: 7th August 2007, 17:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.