Results 1 to 17 of 17

Thread: debugging problem : segmentation fault

  1. #1
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default debugging problem : segmentation fault

    hi

    My application compiles ok but when i run my code in debug mode i get this message and debugging stops

    Signal received:
    The inferior stopped because it received a signal from the operating system.
    signal name:sigsegv
    signal meaning: segmentation fault

    i am using windows 7 and using Qt 4.7.0

    Any sugestions how I can resolve this?

  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: debugging problem : segmentation fault

    Run it in a debugger, and you will see on which line it crashes.
    ==========================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. #3
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: debugging problem : segmentation fault

    Bad pointer. You're trying to use a pointer to an object that doesn't exist or something similar. Debug to find the line where it fails (sometimes the debugger shows you the call stack, other times you have to set breakpoints and step). Inspect the failing line to figure out which pointer is bad. Sometimes you have to insert separate statements to try each pointer when you have, eg, an a -> b -> c -> d situation.

    Debugging puts hair on your chest.

  4. #4
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    thanks for the reply
    i try to follow option 1 mentioned by user 'ad5xj' on this below website
    http://discussion.forum.nokia.com/fo...entation-Fault

    After following the instruction i get this line in the debug window
    0 ?? c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6 0 0x0002965c
    1 ?? c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6 0 0x000297ec

    And when i select full back trace option in return it gives me this thread
    _________________________
    Thread 7 (Thread 8875):
    #0 0x40f441e4 in sem_wait () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libpthread.so.0
    #1 0x00054830 in std::strstreambuf::strstreambuf(char*, int, char*) () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    #2 0x00054830 in std::strstreambuf::strstreambuf(char*, int, char*) () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

    Thread 6 (Thread 8874):
    #0 0x41084798 in poll () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libc.so.6
    #1 0x00058650 in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    #2 0x00058650 in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

    Thread 5 (Thread 8873):
    #0 0x410866ac in ioctl () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libc.so.6
    #1 0x00055650 in std:strstream:strstream() () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    #2 0x00055650 in std:strstream:strstream() () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

    Thread 4 (Thread 8869):
    #0 0x41084798 in poll () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libc.so.6
    #1 0x0005f1d4 in std::basic_fstream<wchar_t, std::char_traits<wchar_t> >::basic_fstream() () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    #2 0x0005f1d4 in std::basic_fstream<wchar_t, std::char_traits<wchar_t> >::basic_fstream() () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

    Thread 3 (Thread 8868):
    #0 0x40f441e4 in sem_wait () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libpthread.so.0
    #1 0x0002217c in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    #2 0x0002217c in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

    Thread 2 (Thread 8867):
    #0 0x0002965c in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    #1 0x000297ec in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)

    Thread 1 (Thread 8866):
    #0 0x40f451b4 in write () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libpthread.so.0
    #1 0x40f44bb8 in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libpthread.so.0
    #2 0x40f44bb8 in ?? () from c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/lib/libpthread.so.0
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    ---------------------------------------------------

    Any suggestions ? what could be the error
    thanks in advance!

    sorry i past the wrong website , here is the correct one

    http://www.qtforum.org/article/31937...t-creator.html

  5. #5
    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: debugging problem : segmentation fault

    Any suggestions ?
    Whats wrong with the suggestions given you in the previous two posts?
    If you'd tried them, you would know where the problem is in your code.
    ==========================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. #6
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    Nothing is wrong in previous post

    i did run my code in debug mode as you suggested
    As i am a beginner just trying to figure out what could be the error by running it in the debugging mode and i also sets break points as other suggested but it stops at the Disassembler "Dump of assembler code from 0x29654 to 0x296cc"(whom i am not totally familiar with)
    that is why i pasted the thread which i get in debug window to get further information about error

    thanks

    Thanks

  7. #7
    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: debugging problem : segmentation fault

    t it stops at the Disassembler "Dump of assembler code from 0x29654 to 0x296cc"(whom i am not totally familiar with)
    You should have a call stack at that stage.
    Look at the call stack and see which is the last line which is in your code.
    That line is the line that crashed your application.
    While in the debugger you can examine the various variables in that line, and you can then see which variable is the problem.
    ==========================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.

  8. #8
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    call stack does not show any line number as below is the output that i get

    level function file line address

    0 ?? c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6 0 0x000272b4
    1 ?? c:/nokiaqtsdk/maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/libstdc++.so.6 0 0x00027444

    knowing the above information how can i check which line creates error ?
    if i know the line where function crashes then i may check the variable

  9. #9
    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: debugging problem : segmentation fault

    Where in your code do you use streams?
    Can you post these code areas?
    ==========================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.

  10. #10
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: debugging problem : segmentation fault

    Are you running QtCreator or some other environment?

    Set some breakpoints early in your code (somewhere you know you'll get) and become familiar with the debugger. You should have a stack display, a variable display, and a code display, though how they're arranged depends on your environment. The line of code where you stop should be highlighted in the code display. (At least, that is, if you compiled the code with debug enabled.) The stack display should display the sequence of methods you called to get to the point where you put the breakpoint.

    When you take an exception or fault, usually the stack display will show gibberish for the top several stack entries, then you'll see your methods below those. Click on the top-most line that you recognize as your code, and the code display should show you the line in your code where that is. The data display should then display the variables for that method.

  11. #11
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    Hi

    thank you very much for the reply my problem has been solved already a while ago but i have one more question to ask

    I am using qt creator , and i have a binary file (.exe) along with some dll files generated by Microsoft Visual C++ 2005 SP1 .
    Now i want to use the functionality of binary file (.exe) in QT creator , please let me know how can i proceed ?

    Thanks in advance

    Thanks

  12. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: debugging problem : segmentation fault

    Sorry, your question does not make any sense.

  13. #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: debugging problem : segmentation fault

    I am using qt creator , and i have a binary file (.exe) along with some dll files generated by Microsoft Visual C++ 2005 SP1 .
    Now i want to use the functionality of binary file (.exe) in QT creator , please let me know how can i proceed ?
    You can extend QtCreators functionality by creating plugins for it.
    Google it.

    On the other hand, maybe you mean you want to link your application to an external lib.
    For this read the QtCreator documentation.
    ==========================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.

  14. #14
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    let me write in this way to make thing clear

    How to run .exe file from Qt creator ?

    I got a .exe file complied by visual C++. I have to run it with different input arguments (which I have to enter manually). I want to do this in Qt creator automatically. So my question is : How to call an executable in Qt creator ?
    It is simple to run executable file using command window (cmd.exe) but do not know how can i use in QT creator . Any hints would be helpful
    Last edited by qureshi; 8th June 2011 at 10:04. Reason: updated contents

  15. #15
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    why do you want to run an .exe in QtCreator?

  16. #16
    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: debugging problem : segmentation fault

    But what purpose would such an action have?
    I can understand if you want to run the application you are debugging in creator from creator, with argunents.
    For this you can set arguments in the debug settings.
    But what will you get by running an external application from creator?
    You can do it by specifying that exe in your debug settings and also the arguments.
    But I see no sense in doing this.
    Here you can see how to set run settings, there you can give your exe and arguments.
    http://doc.qt.nokia.com/qtcreator-2....-settings.html
    ==========================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.

  17. #17
    Join Date
    May 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: debugging problem : segmentation fault

    because my program in Qt creator return output (i.e some data), and i need to pass this output as an input to the .exe file , which returns data after some processing.
    At the moment i am using command windows separately for doing this (that means, first i obtained an output data from the Qt creator , then i open command window , passes my output data as an input to .exe file and finally get the final data after some processing(as processing is being done internally in the exe file and i have no access to the source code , but i have dll files available) ) so my goal is to combine this processing in QT creator so that i donot have to open command window each time separately.

Similar Threads

  1. Segmentation fault
    By impeteperry in forum Qt Programming
    Replies: 5
    Last Post: 29th December 2008, 18:59
  2. Segmentation fault
    By MarkoSan in forum Qt Programming
    Replies: 23
    Last Post: 19th October 2008, 22:40
  3. Segmentation Fault
    By Krish_ng in forum Qt Programming
    Replies: 8
    Last Post: 7th August 2007, 10:49
  4. Replies: 2
    Last Post: 19th May 2007, 18:25
  5. Segmentation Fault
    By merry in forum General Programming
    Replies: 4
    Last Post: 12th March 2007, 04:08

Tags for this Thread

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.