Results 1 to 13 of 13

Thread: !!!A Strange Crash

  1. #1
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default !!!A Strange Crash

    bad luck I forgot my qtcentre account,
    these days I am stuck over a Qt problem , I tried whatsoever I can do and hence I surrendered.
    my projects built successfully on Ubuntu , but when I ran it , it crashed at the very beginning.

    here is the backtrace from gdb:

    Program received signal SIGSEGV, Segmentation fault.
    0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
    (gdb) bt
    #0 0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
    #1 0x035364ff in XSetCommand () from /usr/lib/libX11.so.6
    #2 0x0353af51 in XSetWMProperties () from /usr/lib/libX11.so.6
    #3 0x0100f134 in QWidgetPrivate::create_sys (this=0x8313fb0, window=0,
    initializeWindow=true, destroyOldWindow=true)
    at /var/tmp/qt-src/src/gui/kernel/qwidget_x11.cpp:795
    #4 0x00fc7b21 in QWidget::create (this=0xbffff1cc, window=0, initializeWindow=true,
    destroyOldWindow=true) at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:1319
    #5 0x00fca7b1 in QWidget::setVisible (this=0xbffff1cc, visible=true)
    at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:7353
    #6 0x081c7e53 in main ()


    I asked google for help and checked all the result items thoroughly,
    Martin Sander added a comment - 28/Jan/10 04:42 PM
    I got the same crash.
    Suprisingly it is not only the argv causing the problem.
    It's the "design" of QCoreApplication: it stores the argc as reference.
    In the example in QappRun the argv AND argc have to be static.
    Very nasty: if you subclass from QCoreApplication or QApplication and then forget the & in the subclass constructor.


    [ Permalink | « Hide ]
    Zeno Albisser added a comment - 08/Feb/10 03:29 PM
    I wonder what exactly should be the use case of this implementation.
    It of course crashes because argv is not valid anymore after leaving QappRun.
    Further the documentation of QApplication mentions:
    "Warning: The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string."
    Qt Version? the two arguments ,argc? argv?
    many people got the same crash , but there was no solution found ,
    so . if you met the same problem before, be nice to give me tips, thank you...

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: !!!A Strange Crash

    1. post your main()
    2. run in debugger and tell us which line in main() is crashing.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    hhf (10th March 2010)

  4. #3
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: !!!A Strange Crash

    Qt Code:
    1. //I did not have right to expose the code , hence I replace some word that maybe make me in trouble with XXX.
    2. int main(int argc, char *argv[])
    3. {
    4. Q_INIT_RESOURCE(xxx);
    5. QCoreApplication::setOrganizationName("xxx System");
    6. QCoreApplication::setOrganizationDomain("xxx.com");
    7. QCoreApplication::setApplicationName("xxx Design");
    8. QCoreApplication::setApplicationVersion("5.0.0");
    9.  
    10. int result = -1;
    11.  
    12. XXXInit::instance().nextStage();
    13. XXXApplication app(argc, argv);
    14. app.setLanguage();
    15.  
    16. XXXSplashScreen splash; //XXXSplashScreen encapsulate the QSplashScreen
    17. splash.show(); //the program crash right here
    18. app.setWindowIcon(QIcon());
    19.  
    20. XXXInit::instance().nextStage();
    21.  
    22. Initialisationer initer;
    23.  
    24. XXXMainWindow mainwindow;
    25. mainwindow.show();
    26.  
    27. splash.finish(&mainwindow);
    28.  
    29. app.setMainWindow(&mainwindow);
    30.  
    31. XXXInit::instance().nextStage();
    32. result = app.exec();
    33.  
    34. XXXInit::instance().nextStage();
    35.  
    36. return result;
    37. }
    To copy to clipboard, switch view to plain text mode 

    Program received signal SIGSEGV, Segmentation fault.
    0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
    (gdb) bt
    #0 0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
    #1 0x035364ff in XSetCommand () from /usr/lib/libX11.so.6
    #2 0x0353af51 in XSetWMProperties () from /usr/lib/libX11.so.6
    #3 0x0100f134 in QWidgetPrivate::create_sys (this=0x8313fb0, window=0,
    initializeWindow=true, destroyOldWindow=true)
    at /var/tmp/qt-src/src/gui/kernel/qwidget_x11.cpp:795
    #4 0x00fc7b21 in QWidget::create (this=0xbffff1cc, window=0, initializeWindow=true,
    destroyOldWindow=true) at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:1319
    #5 0x00fca7b1 in QWidget::setVisible (this=0xbffff1cc, visible=true)
    at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:7353
    #6 0x081c7e53 in main ()
    the job will not be done on time ... so depressing ........
    Last edited by wysota; 9th March 2010 at 13:58.

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: !!!A Strange Crash

    it looks your are doing something wrong in the QSplashScreen wrapper...
    If its not a lot of code, post it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. The following user says thank you to high_flyer for this useful post:

    hhf (10th March 2010)

  7. #5
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default

    at a Qt internal function QWidgetPrivate::create_sys

    XSetWMProperties(dpy, id, 0, 0,
    qApp->d_func()->argv, qApp->d_func()->argc,
    &size_hints, &wm_hints, &class_hint);

    splash.show(); //the program crash right here
    Last edited by wysota; 9th March 2010 at 14:01.

  8. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: !!!A Strange Crash

    we cross posted... see my post before yours.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. The following user says thank you to high_flyer for this useful post:

    hhf (10th March 2010)

  10. #7
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default

    all the code can run perfectly on win32 platform , crazy me !

    Qt Code:
    1. XXXSplashScreen::XXXSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowFlags f)
    2. : QSplashScreen(parent, pixmap, f)
    3. {
    4. setWindowOpacity(0.9);
    5. }
    6.  
    7. XXXSplashScreen::XXXSplashScreen(QWidget *parent)
    8. : QSplashScreen(parent, QPixmap(":/images/splashscreen.png"), Qt::WindowStaysOnTopHint)
    9. {
    10. setWindowOpacity(0.9);
    11. }
    12.  
    13. void
    14. XXXSplashScreen::drawContents(QPainter *painter)
    15. {
    16. int left = 180;
    17. int top = 15;
    18. int bottomLimit = 75;
    19. int rightLimit = width();
    20. QRect rect(left, top, rightLimit - left, bottomLimit - top);
    21. QFont titleFont = QApplication::font();
    22. titleFont.setBold(true);
    23. titleFont.setPointSize(titleFont.pointSize() + 1);
    24. painter->setFont(titleFont);
    25. painter->drawText(rect, Qt::AlignLeft, app().fullName());
    26. }
    27.  
    28. void
    29. XXXSplashScreen::show()
    30. {
    31. QSplashScreen::show();
    32. showMessage(QString());
    33. }
    To copy to clipboard, switch view to plain text mode 

    more nasty , it run fine in debug mode , but get a 'Segmentation fault' in release mode.
    Last edited by wysota; 9th March 2010 at 14:00.

  11. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: !!!A Strange Crash

    it could be that due to configuration issues, your image is not found, and thus you get a null pixmap.
    Try this:
    Qt Code:
    1. XXXSplashScreen splash; //XXXSplashScreen encapsulate the QSplashScreen
    2. if(splsh.pixmap().isNull()){
    3. qDebug()<<"nuill pixmap";
    4. }
    5.  
    6. splash.show(); //the program crash right here
    7. app.setWindowIcon(QIcon());
    To copy to clipboard, switch view to plain text mode 

    and see if the debug message comes out, or you can set a break point on the debug message.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  12. The following user says thank you to high_flyer for this useful post:

    hhf (10th March 2010)

  13. #9
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: !!!A Strange Crash

    the debug message didn't come out, the image can be found..

  14. #10
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: !!!A Strange Crash

    since it crash only in release mode, breakpoints set in the code can not work.
    how to make the program debug-able in release mode?

  15. #11
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: !!!A Strange Crash

    how to make the program debug-able in release mode?
    you can put a debug message in all the methods at the beginning, and at the end, this way you will see which method started but didn't complete.
    It will help narrow down where the problem is.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  16. The following user says thank you to high_flyer for this useful post:

    hhf (10th March 2010)

  17. #12
    Join Date
    Mar 2010
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: !!!A Strange Crash

    thank you so much .
    boss passed this job back to the author already .
    but now I face to a bigger challenge, a man came back to Canada, leaving a 'mess' for me, he use french to name all the variables ,macros and things like that ...I don't know french at all, the code seem unfriendly to me, nightmare

  18. #13
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: !!!A Strange Crash

    Well, that is not something I can help you with, I am afraid...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Crash on removing a row
    By inktomi in forum Qt Programming
    Replies: 10
    Last Post: 17th June 2010, 13:59
  2. dll crash on Windows XP
    By radith in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 03:28
  3. crash in emit()
    By mhoover in forum Qt Programming
    Replies: 9
    Last Post: 27th August 2009, 08:36
  4. Unexplained Crash
    By jbkc85 in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2009, 20:06
  5. Crash in QTableWidget
    By ghorwin in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2007, 17:57

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.