473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Debugging core file?

I compiled a game client and it crashed (segmentation fault) resulting
in a core file being generated. I'm trying to find out exactly what
caused it to crash. Any ideas how I can do this with gdb? In the
Makefile can I just add a "-g" flag to have the binary produced with
debugging symbols? The source is written in ANSI C.

This is what I have now:
"CC = gcc"

The client binary is 433680 and the core file produced when it crashed
is almost double that, it's 860160.

Here is what I've done so far:
1]+ Segmentation fault (core dumped) ./netrek

zu22@netrek:~/netrek/cow/build$ file core
core: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-
style

zu22@netrek:~/netrek/cow/build$ gdb ./netrek core
GNU gdb 6.6.90.20070912-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/
gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /usr/lib/libmp.so.3...done.
Loaded symbols for /usr/lib/libmp.so.3
Reading symbols from /usr/lib/libgmp.so.3...done.
Loaded symbols for /usr/lib/libgmp.so.3
Reading symbols from /usr/lib/libXpm.so.4...done.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so.6...done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/lib/libXau.so.6...done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libXdmcp.so.6...done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_mdns4_minimal.so.2...done.
Loaded symbols for /lib/libnss_mdns4_minimal.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/lib/libXcursor.so.1...done.
Loaded symbols for /usr/lib/libXcursor.so.1
Reading symbols from /usr/lib/libXrender.so.1...done.
Loaded symbols for /usr/lib/libXrender.so.1
Reading symbols from /usr/lib/libXfixes.so.3...done.
Loaded symbols for /usr/lib/libXfixes.so.3
Reading symbols from /lib/libnss_compat.so.2...done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Core was generated by `./netrek'.
Program terminated with signal 11, Segmentation fault.
#0 0x0805cc99 in map ()
(gdb) run
Starting program: /home/zu22/netrek/cow/build/netrek
Failed to read a valid object file image from memory.
Reading defaults file /home/zu22/.netrekrc

Program exited normally.
(gdb) bt
#0 0x0805cc99 in map ()
#1 0x08083757 in redraw ()
#2 0x080838bc in intrupt ()
#3 0x08051d08 in input ()
#4 0x08082289 in cowmain ()
#5 0x0804b787 in main ()
(gdb) quit

I used cscope to check map() and it's a pretty big function with
different uses depending on the context so I'm still not sure exactly
why the client is crashing.

Zach

Nov 3 '07 #1
2 3667
On Nov 4, 3:24 am, Zach <net...@gmail.comwrote:
I compiled a game client and it crashed (segmentation fault) resulting
in a core file being generated. I'm trying to find out exactly what
caused it to crash. Any ideas how I can do this with gdb? In the
Makefile can I just add a "-g" flag to have the binary produced with
debugging symbols? The source is written in ANSI C.

This is what I have now:
"CC = gcc"

The client binary is 433680 and the core file produced when it crashed
is almost double that, it's 860160.

Here is what I've done so far:
1]+ Segmentation fault (core dumped) ./netrek

zu22@netrek:~/netrek/cow/build$ file core
core: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-
style

zu22@netrek:~/netrek/cow/build$ gdb ./netrek core
GNU gdb 6.6.90.20070912-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/
gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /usr/lib/libmp.so.3...done.
Loaded symbols for /usr/lib/libmp.so.3
Reading symbols from /usr/lib/libgmp.so.3...done.
Loaded symbols for /usr/lib/libgmp.so.3
Reading symbols from /usr/lib/libXpm.so.4...done.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so.6...done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/lib/libXau.so.6...done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libXdmcp.so.6...done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_mdns4_minimal.so.2...done.
Loaded symbols for /lib/libnss_mdns4_minimal.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/lib/libXcursor.so.1...done.
Loaded symbols for /usr/lib/libXcursor.so.1
Reading symbols from /usr/lib/libXrender.so.1...done.
Loaded symbols for /usr/lib/libXrender.so.1
Reading symbols from /usr/lib/libXfixes.so.3...done.
Loaded symbols for /usr/lib/libXfixes.so.3
Reading symbols from /lib/libnss_compat.so.2...done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Core was generated by `./netrek'.
Program terminated with signal 11, Segmentation fault.
#0 0x0805cc99 in map ()
(gdb) run
Starting program: /home/zu22/netrek/cow/build/netrek
Failed to read a valid object file image from memory.
Reading defaults file /home/zu22/.netrekrc

Program exited normally.
(gdb) bt
#0 0x0805cc99 in map ()
#1 0x08083757 in redraw ()
#2 0x080838bc in intrupt ()
#3 0x08051d08 in input ()
#4 0x08082289 in cowmain ()
#5 0x0804b787 in main ()
(gdb) quit

I used cscope to check map() and it's a pretty big function with
different uses depending on the context so I'm still not sure exactly
why the client is crashing.
1)Can you try step debugging and analyse variables/memory w.r.t
reaching till 'map' and inside map .

You have tried backtrace which shows a(one) line per frame, for many
frames, starting with the currently executing frame (frame zero),
followed by its caller (frame one), and on up the stack.
But, we are not aware of your design flow. Is the design flow correct
as you have thought ?

Signal 11 - "segmentation fault" and as you might be aware that the
reason for this can be due to
accessing a memory location that was not assigned. So, Check for the
proper use of memory (Memory/Buffer management,proper use of
pointers,typecasting,string manipulation as APIs related
with it does not have proper buffer overflow / buffer management
checks)

Karthik Balaguru

Nov 4 '07 #2
On Nov 4, 3:51 pm, karthikbalaguru <karthikbalagur...@gmail.com>
wrote:
On Nov 4, 3:24 am, Zach <net...@gmail.comwrote:
I compiled a game client and it crashed (segmentation fault) resulting
in a core file being generated. I'm trying to find out exactly what
caused it to crash. Any ideas how I can do this with gdb? In the
Makefile can I just add a "-g" flag to have the binary produced with
debugging symbols? The source is written in ANSI C.
This is what I have now:
"CC = gcc"
The client binary is 433680 and the core file produced when it crashed
is almost double that, it's 860160.
Here is what I've done so far:
1]+ Segmentation fault (core dumped) ./netrek
zu22@netrek:~/netrek/cow/build$ file core
core: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-
style
zu22@netrek:~/netrek/cow/build$ gdb ./netrek core
GNU gdb 6.6.90.20070912-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/
gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /usr/lib/libmp.so.3...done.
Loaded symbols for /usr/lib/libmp.so.3
Reading symbols from /usr/lib/libgmp.so.3...done.
Loaded symbols for /usr/lib/libgmp.so.3
Reading symbols from /usr/lib/libXpm.so.4...done.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so.6...done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/lib/libXau.so.6...done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libXdmcp.so.6...done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_mdns4_minimal.so.2...done.
Loaded symbols for /lib/libnss_mdns4_minimal.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/lib/libXcursor.so.1...done.
Loaded symbols for /usr/lib/libXcursor.so.1
Reading symbols from /usr/lib/libXrender.so.1...done.
Loaded symbols for /usr/lib/libXrender.so.1
Reading symbols from /usr/lib/libXfixes.so.3...done.
Loaded symbols for /usr/lib/libXfixes.so.3
Reading symbols from /lib/libnss_compat.so.2...done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Core was generated by `./netrek'.
Program terminated with signal 11, Segmentation fault.
#0 0x0805cc99 in map ()
(gdb) run
Starting program: /home/zu22/netrek/cow/build/netrek
Failed to read a valid object file image from memory.
Reading defaults file /home/zu22/.netrekrc
Program exited normally.
(gdb) bt
#0 0x0805cc99 in map ()
#1 0x08083757 in redraw ()
#2 0x080838bc in intrupt ()
#3 0x08051d08 in input ()
#4 0x08082289 in cowmain ()
#5 0x0804b787 in main ()
(gdb) quit
I used cscope to check map() and it's a pretty big function with
different uses depending on the context so I'm still not sure exactly
why the client is crashing.

1)Can you try step debugging and analyse variables/memory w.r.t
reaching till 'map' and inside map .

You have tried backtrace which shows a(one) line per frame, for many
frames, starting with the currently executing frame (frame zero),
followed by its caller (frame one), and on up the stack.
But, we are not aware of your design flow. Is the design flow correct
as you have thought ?

Signal 11 - "segmentation fault" and as you might be aware that the
reason for this can be due to
accessing a memory location that was not assigned. So, Check for the
proper use of memory (Memory/Buffer management,proper use of
pointers,typecasting,string manipulation as APIs related
with it does not have proper buffer overflow / buffer management
checks)

Karthik Balaguru

>From the stack it seems that the -g flag didn't work. the stack looks
like a stack of non debug binary. Once you create the binary with
debugging symbols...you will see the line numbers.

Nov 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Job Kelderman | last post by:
Hi all! I'm trying to get remote debugging working with phpeclipse. I think i've installed everything correctly, and the debugger in eclipse starts, but breakpoints are ignored and nothing...
2
by: hpoliset | last post by:
I have a debugging question w.r.t core dumps with signal 4 Illegal instruction messages. I analyzed the core file through gdb. In simple english following is the pattern observed: I have an...
83
by: achintmehta | last post by:
I am working on MontaVista Linux on a PPC board. The compiler I am using is a gnu cross compiler cross compiler (ppc-82xx-gcc) The application/software that is being run, is messing up the...
10
by: Doug Robertson | last post by:
First off, I'm a hardware/OS guy. I just write code on the side and I'm completely self taught - so bear in mind my total lack of expertise. I have a program originally written in VB2003 using...
4
by: George Sakkis | last post by:
I have a pure python program (no C extensions) that occasionally core dumps in a non-reproducible way. The program is started by a (non- python) cgi script when a form is submitted. It involves...
1
by: sunil | last post by:
Hi, I am having certain queries in debugging the core in different environment. Suppose the core is generated in the production environment. Is it feasible to debug that core in development...
4
by: yossi.kreinin | last post by:
Hi! Is there a way to save the state of a Python process for later inspection with a debugger? One way to do this is to dump core, but is the result usable for debugging with pdb (it can be...
4
by: dbee | last post by:
Right. I've got a really, really annoying/difficult/time consuming problem with my development environment. I'm using django to build a web app with paypal integration. My server is hosted...
0
by: stimpy_cm | last post by:
Hi everyone, I’m not a programmer but have a little notion about how things work. I recently downloaded an emulator for my calculator (Texas Instruments Voyage 200), the program uses a library...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.