PDA

View Full Version : debugging problem : segmentation fault



qureshi
17th May 2011, 12:58
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?

high_flyer
17th May 2011, 13:12
Run it in a debugger, and you will see on which line it crashes.

DanH
17th May 2011, 13:20
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.

qureshi
17th May 2011, 13:38
thanks for the reply
i try to follow option 1 mentioned by user 'ad5xj' on this below website
http://discussion.forum.nokia.com/forum/showthread.php?213672-Segmentation-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::ostrstream::ostrstream() () 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::ostrstream::ostrstream() () 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/error-when-debugging-with-qt-creator.html

high_flyer
17th May 2011, 13:42
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.

qureshi
17th May 2011, 14:01
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

high_flyer
17th May 2011, 14:06
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.

qureshi
17th May 2011, 15:51
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

high_flyer
17th May 2011, 15:56
Where in your code do you use streams?
Can you post these code areas?

DanH
18th May 2011, 01:27
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.

qureshi
7th June 2011, 16:51
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

ChrisW67
7th June 2011, 22:30
Sorry, your question does not make any sense.

high_flyer
8th June 2011, 08:43
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.

qureshi
8th June 2011, 10:03
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

FelixB
8th June 2011, 10:20
why do you want to run an .exe in QtCreator?

high_flyer
8th June 2011, 10:22
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.2/creator-run-settings.html

qureshi
8th June 2011, 11:21
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.