473,583 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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...do ne.
Loaded symbols for /usr/lib/libmp.so.3
Reading symbols from /usr/lib/libgmp.so.3...d one.
Loaded symbols for /usr/lib/libgmp.so.3
Reading symbols from /usr/lib/libXpm.so.4...d one.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so.6...d one.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /lib/libnsl.so.1...d one.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...don e.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...don e.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/lib/libXau.so.6...d one.
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...do ne.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...do ne.
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_mi nimal.so.2...do ne.
Loaded symbols for /lib/libnss_mdns4_mi nimal.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.s o.2...done.
Loaded symbols for /lib/libnss_compat.s o.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 3688
On Nov 4, 3:24 am, Zach <net...@gmail.c omwrote:
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...do ne.
Loaded symbols for /usr/lib/libmp.so.3
Reading symbols from /usr/lib/libgmp.so.3...d one.
Loaded symbols for /usr/lib/libgmp.so.3
Reading symbols from /usr/lib/libXpm.so.4...d one.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so.6...d one.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /lib/libnsl.so.1...d one.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...don e.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...don e.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/lib/libXau.so.6...d one.
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...do ne.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...do ne.
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_mi nimal.so.2...do ne.
Loaded symbols for /lib/libnss_mdns4_mi nimal.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.s o.2...done.
Loaded symbols for /lib/libnss_compat.s o.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 - "segmentati on 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,prop er use of
pointers,typeca sting,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.c omwrote:
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...do ne.
Loaded symbols for /usr/lib/libmp.so.3
Reading symbols from /usr/lib/libgmp.so.3...d one.
Loaded symbols for /usr/lib/libgmp.so.3
Reading symbols from /usr/lib/libXpm.so.4...d one.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /usr/lib/libX11.so.6...d one.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /lib/libnsl.so.1...d one.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libm.so.6...don e.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...don e.
Loaded symbols for /lib/libc.so.6
Reading symbols from /usr/lib/libXau.so.6...d one.
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...do ne.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux.so.2...do ne.
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_mi nimal.so.2...do ne.
Loaded symbols for /lib/libnss_mdns4_mi nimal.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.s o.2...done.
Loaded symbols for /lib/libnss_compat.s o.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 - "segmentati on 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,prop er use of
pointers,typeca sting,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
1719
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 seems to happen :( Is there some way to simply check if the debug plugin for php is correctly installed
2
17540
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 program with a piece of code -lets call it function1() that gets called by different callers. This function is executed 1000 's of times as while the...
83
3921
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 memory due to which a subsequent malloc fails. When the application core is dumped I do not get any backtrace in the code (although the application is...
10
1959
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 the dotnet 1.1 framework. The program makes extensive use of Win32 API calls to help manage and track remote access sessions with out clients. I've...
4
2361
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 running a bunch of other programs through subprocess in multiple threads and writing its output in several files. So the only suspicious parts I can...
1
1193
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 environment If we are able to debug the core in the dev environment what and all the precaution measures we have to take. what and all the constraints...
4
3141
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 debugged by gdb, which can inspect PyObjects in a CPython core, for example, but it's not much fun)? If there is no way to do this today, are there...
4
2083
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 remotely, and it is receiving IPN (payment notifications) POST requests from Paypal. I've checked on google and irc and this is my last shot at solving...
0
379
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 created for .Net framework 1.0 and 1.1. I also activated the compatibility mode for Windows XP SP2 (Which it was the OS the programs were created for)....
0
7888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main...
0
7811
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8314
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7922
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8185
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.