Results 1 to 5 of 5

Thread: weird segmentation fault on startup

  1. #1
    Join Date
    May 2015
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default weird segmentation fault on startup

    Hi there,

    I'm currently experiencing a strange behaviour.

    Qt Code:
    1. DEFINES += QT_NO_DEBUG_OUTPUT
    2. CONFIG += release
    3. TARGET = myProg
    4. TEMPLATE = app
    To copy to clipboard, switch view to plain text mode 

    When built as realease it leads to a segmentation error on startup insight the IDE.

    I switch to debug mode using modified pro file

    Qt Code:
    1. #DEFINES += QT_NO_DEBUG_OUTPUT
    2. #CONFIG += release
    3. TARGET = myProg
    4. TEMPLATE = app
    To copy to clipboard, switch view to plain text mode 

    It runs fine.

    sigsegv.jpg

    When it occurs, it compiles and starts. On startup it runs into the error. The strange thing now is: I can press the "resume"-button, and it works. Program starts after hitting this button twice. Furthermore I can deploy the resulting *.exe and it works without any problems.

    However I'm not a pro-programmer. I'm more or less coming from the "user"-side and I used Qt as a substitute for Matlab. That's why I'm not to familiar with debugging methods. I debugged algorithms and functions, observed incrementors and condition. But this seems to be beyond my horizon. Looks like it involves system-functions and -libraries. I would be glad if somebody could give me a hint on how to start finding out all about this.

    I did an update to latest Qt5-version. No effect.

    version.png

    Thanks in advance, Lars
    Last edited by mustermann.klaus@gmx.de; 28th February 2021 at 15:32. Reason: spelling corrections

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,943
    Thanks
    276
    Thanked 804 Times in 793 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: weird segmentation fault on startup

    A lot of times you will see errors like this where the program runs fine in the debugger but crashes in release mode, and it is generally due to an uninitialized variable or a variable that is out of range (like an index or a pointer). In debug mode, the debugger usually sets all variable values to a known but illegal value (like 0xdcdcdcdc for pointers) so when your program crashes in the debugger you can immediately see the problem when you inspect the variables.

    This doesn't happen in release mode. Uninitialized variables have whatever random value the memory contains when the program starts. Sometimes the program runs OK but produces weird results because an index has a random but valid value. Other times it simply crashes.

    So I would start by checking for that. If you raise the "complaint" level for your compiler output, it will tell you about uninitialized variables, and if you set the complaint level high enough it will turn those warnings into errors so you can't ignore them.

    Furthermore I can deploy the resulting *.exe and it works without any problems.
    Might be just luck, or it might be a difference in the libraries on your development system vs. the deployment system. "Dependency Walker" (depends.exe) might help you determine if there are any significant differences between the libraries pulled in at runtime on your system vs. the other.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    May 2015
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: weird segmentation fault on startup

    Hey d_stranz,

    thanks so much for that reply. What puzzled me is that I run the deployed *.exe on the very same machine without any problem.

    I'm afraid it is actually going deeper. I figured out that since I updated VMWare-Horizon-Agent on this machine I got this error.
    I'll try to rollback and see.

    But to come back to your advice (helpfull as always): how would I raise the "complainement factor" of my compiler? Sounds interesting, never done this.

    Regards, Lars

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,943
    Thanks
    276
    Thanked 804 Times in 793 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: weird segmentation fault on startup

    how would I raise the "complainement factor" of my compiler?
    What compiler are you using?

    For Microsoft Visual C++, you add "/W4" for the highest level of warnings, and "/WX" to treat warnings as errors.

    For MinGW/gcc, "-Wall" is the highest level, and "-Werror" turns warnings into errors.

    These are added to the command-line specification for the compiler. In Visual Studio, you add it on the "C/C++ -> General" section of the project's Property Pages dialog. I don't use Qt Creator so I don't know where to put it on that.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    May 2015
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: weird segmentation fault on startup

    Thanks. In this case I use mingw32. I think in creators project setting page you can specify commandline option. I'll try and come back.

    Cheers.

Similar Threads

  1. Crash at startup giving segmentation fault
    By Tanu@123 in forum Qt Programming
    Replies: 0
    Last Post: 20th June 2018, 06:57
  2. Very slow startup by the first run
    By denizlitr in forum Qt for Embedded and Mobile
    Replies: 14
    Last Post: 2nd November 2016, 07:30
  3. QT app crash at startup
    By pl01 in forum Newbie
    Replies: 4
    Last Post: 5th June 2013, 10:45
  4. weird weird mingw32-make
    By KillGabio in forum Qt Programming
    Replies: 19
    Last Post: 20th January 2012, 20:09
  5. QToolBar go away! On startup anyway.
    By bitChanger in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2006, 18:22

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.