Reputation: 47
One of our code is generating a core file While trying to analyse core using gdb with below commands gdb programe_name core
I am unable to retrieve the tarce with backtrace command getting below
#4 0x20202020 in ?? ()
#5 0x20202020 in ?? ()
#6 0x20202020 in ?? ()
#7 0x20202020 in ?? ()
#8 0x20202020 in ?? ()
#9 0x20202020 in ?? ()
#10 0x20202020 in ?? ()
#11 0x20202020 in ?? ()
#12 0x20202020 in ?? ()
#13 0x20202020 in ?? ()
#14 0x20202020 in ?? ()
#15 0x20202020 in ?? ()
#16 0x20202020 in ?? ()
#17 0x20202020 in ?? ()
#18 0x20202020 in ?? ()
#19 0x20202020 in ?? ()
do we have a command which I can use to get trace with function name and arguments
Upvotes: 0
Views: 331
Reputation: 386
It looks like your stack has been "crunched" -- that is, overwritten with some data that shouldn't be there.
0x20202020 is four spaces in ASCII, so the stack has been overwritten by a string of characters with a lot of spaces.
Look for an array (or variable) that you are reading into (or copying characters into); the chances are you are reading/copying more data than you expected into that array/variable.
To avoid this sort of thing in the future, use one of the forms that allows you to limit the amount read/copied to the size of the target area:
fread
fgets
strncpy
You might want to also take a look at the answers to Reading in a variable length string user input in C As relatively safe ways to protect yourself when reading data of unknown length into a buffer.
Upvotes: 3