Skip to content

gdb core dump

7 messages · Paul Gilbert, Thomas Lumley, Peter Dalgaard

#
When I get a segmentation fault and core dump can I use gdb to examine the core
file and get any useful information about why and where things went wrong? Do I
need to compile R in a special way to do this? Obviously I'm a newbie at this.
Details would be appreciated.

Paul Gilbert

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On 16 Oct 1998, Peter Dalgaard BSA wrote:

            
In order for this to be as useful as possible you should do it before 
	make install
so that gdb can find the source files and display them for you.

Also, compilers vary in how useful their optimised output is for
debugging. I find that the Sun compiler loses line number information when
optimisation is specified, and just keeps track of which function you are
in. gcc keeps line number information, which makes it better for debugging
purposes.

	-thomas



Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Paul Gilbert <pgilbert@bank-banque-canada.ca> writes:
Just execute as

R -d gdb

(and type 'run')
#
The problem is that the segmentation faults do not happen in any reliable way,
and usually they occur in batch scripts I use for testing. I was wondering if
there is anyway, after they occur, to recover useful information from the core
file that is generated?
I'm confused. What do I do before make install?

Paul

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 16 Oct 1998, Paul Gilbert wrote:

            
make creates a working version of R locally, make install puts it in eg
/usr/local/, but without the source. Running the debugger on the local
version of R in the source tree can be more useful than running it on the
installed version. This may not be feasible in your set up, and it isn't
critical -- you can still get a stack trace of function calls.

You look at a core file in much the same way, by running gdb through R -d
gdb. The reason to do it that way is to get the environment variables
right.

gorn% R -d gdb
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.15.1 (sparc-sun-solaris2.5), 
Copyright 1995 Free Software Foundation, Inc...
(gdb) core-file core

You can now type 
(gdb) backtrace

to list the stack trace and find exactly where R was when it segfaulted.


	-thomas



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
...
Thanks. Now I guess that gets me to the hard part. Does the following point out
a problem in R 0.62.3?

Paul
______

[4] /home/res4/gilp/dse/pub/Rdse : R -d gdb
GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.6"...
(gdb) core-file core
Core was generated by `/home/res4/gilp/R-versions/R-0.62.3/bin/R.binary -v6
-n250000 --no-save'.
Program terminated with signal 11, Segmentation Fault.
Reading symbols from /usr/openwin/lib/libSM.so.6...done.
Reading symbols from /usr/openwin/lib/libICE.so.6...done.
Reading symbols from /usr/openwin/lib/libX11.so.4...done.
Reading symbols from /usr/lib/libsocket.so.1...done.
Reading symbols from /usr/lib/libnsl.so.1...done.
Reading symbols from /usr/lib/libdl.so.1...done.
Reading symbols from /usr/lib/libm.so.1...done.
Reading symbols from /usr/lib/libc.so.1...done.
Reading symbols from /usr/openwin/lib/libXext.so.0...done.
Reading symbols from /usr/lib/libmp.so.2...done.
Reading symbols from /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1...done.
Reading symbols from /usr/lib/locale/en_CA/en_CA.so.1...done.
Reading symbols from /home/res4/gilp/dse/pub/Rdse/rlibs/dse/libs/dse.so...done.
Reading symbols from
/home/res4/gilp/R-versions/R-0.62.3/library/mva/libs/mva.so...done.
#0  do_nextmethod (call=0x2c7f94, op=0x5cc014, args=0x2c7f08, env=0x110e44)
    at objects.c:302
302    if( (CAR(m) == CAR(t)) && !ARGUSED(s) ) {
(gdb) backtrace
#0  do_nextmethod (call=0x2c7f94, op=0x5cc014, args=0x2c7f08, env=0x110e44)
    at objects.c:302
#1  0x49bb4 in do_internal (call=0xe8950, op=0x10f288, args=0x2c7f08,
    env=0x110e44) at names.c:768
#2  0x3a8f8 in eval (e=0x2c7ff8, rho=0x110e44) at eval.c:156
#3  0x3ac4c in applyClosure (call=0x366464, op=0x2c8084, arglist=0x111420,
    rho=0x111c40, suppliedenv=0x107560) at eval.c:269
#4  0x3a974 in eval (e=0x366464, rho=0x111c40) at eval.c:165
#5  0x3bcf4 in do_set (call=0x3664a0, op=0x107d1c, args=0x36648c, rho=0x111c40)
    at eval.c:749
#6  0x3a8f8 in eval (e=0x3664a0, rho=0x111c40) at eval.c:156
#7  0x3b738 in do_begin (call=0x3664b4, op=0x107dbc, args=0x3664c8,
    rho=0x111c40) at eval.c:560
#8  0x3a8f8 in eval (e=0x3664b4, rho=0x111c40) at eval.c:156
#9  0x3ac4c in applyClosure (call=0x112ac8, op=0x367a44, arglist=0x113158,
    rho=0x12f45c, suppliedenv=0x112b2c) at eval.c:269
#10 0x49e00 in applyMethod (call=0x112ac8, op=0x367a44, args=0x113158,
    rho=0x12f45c, newrho=0x112b2c) at objects.c:66
#11 0x4a198 in usemethod (generic=0xefffb228 "[", obj=0x0, call=0x112ac8,
    args=0x113158, rho=0x12f45c, ans=0xefffb31c) at objects.c:174
#12 0x3c694 in DispatchOrEval (call=0x4dfc50, op=0x107e20, args=0x113158,
    rho=0x12f45c, ans=0xefffb31c, dropmissing=0) at eval.c:1085
#13 0x73164 in do_subset (call=0x4dfc50, op=0x107e20, args=0xfcc00,
    rho=0x12f45c) at subset.c:469
#14 0x3a8f8 in eval (e=0x4dfc50, rho=0x12f45c) at eval.c:156
#15 0x3bcf4 in do_set (call=0x4dfc8c, op=0x107d1c, args=0x4dfc78, rho=0x12f45c)
    at eval.c:749
#16 0x3a8f8 in eval (e=0x4dfc8c, rho=0x12f45c) at eval.c:156
#17 0x3b738 in do_begin (call=0x4dfb10, op=0x107dbc, args=0x4dfca0,
    rho=0x12f45c) at eval.c:560
#18 0x3a8f8 in eval (e=0x4dfb10, rho=0x12f45c) at eval.c:156
#19 0x3aef8 in do_if (call=0x4e0010, op=0x1079fc, args=0x4dfffc, rho=0x12f45c)
    at eval.c:353
---Type <return> to continue, or q <return> to quit---
#20 0x3a8f8 in eval (e=0x4e0010, rho=0x12f45c) at eval.c:156
#21 0x3b738 in do_begin (call=0x4e0024, op=0x107dbc, args=0x4e0038,
    rho=0x12f45c) at eval.c:560
#22 0x3a8f8 in eval (e=0x4e0024, rho=0x12f45c) at eval.c:156
#23 0x3ac4c in applyClosure (call=0x12ffb0, op=0x5292b0, arglist=0x130820,
    rho=0x1306e0, suppliedenv=0x1306b8) at eval.c:269
#24 0x49e00 in applyMethod (call=0x12ffb0, op=0x5292b0, args=0x130820,
    rho=0x1306e0, newrho=0x1306b8) at objects.c:66
#25 0x4a198 in usemethod (generic=0xefffbb58 "output.data", obj=0x0,
    call=0x12ffb0, args=0x130820, rho=0x1306e0, ans=0xefffbb54)
    at objects.c:174
#26 0x4a44c in do_usemethod (call=0x4cfa94, op=0x10f260, args=0x4cfa80,
    env=0x1306e0) at objects.c:242
#27 0x3a8f8 in eval (e=0x4cfa94, rho=0x1306e0) at eval.c:156
#28 0x3ac4c in applyClosure (call=0x4734ec, op=0x526394, arglist=0x130820,
    rho=0x1d4420, suppliedenv=0x107560) at eval.c:269
#29 0x3a974 in eval (e=0x4734ec, rho=0x1d4420) at eval.c:165
#30 0x3a734 in eval (e=0x133b38, rho=0x1336d8) at eval.c:118
#31 0x3a674 in eval (e=0x113694, rho=0x1336d8) at eval.c:100
#32 0x3a734 in eval (e=0x1313c4, rho=0x1336d8) at eval.c:118
#33 0x3c5c8 in DispatchOrEval (call=0x452580, op=0x107e20, args=0x1312fc,
    rho=0x1336d8, ans=0xefffc0cc, dropmissing=0) at eval.c:1076
#34 0x73164 in do_subset (call=0x452580, op=0x107e20, args=0xfcc00,
    rho=0x1336d8) at subset.c:469
#35 0x3a8f8 in eval (e=0x452580, rho=0x1336d8) at eval.c:156
#36 0x3bf40 in evalList (el=0x452594, rho=0x1336d8) at eval.c:825
#37 0x3a884 in eval (e=0x4525bc, rho=0x1336d8) at eval.c:154
#38 0x3bcf4 in do_set (call=0x4525f8, op=0x107d1c, args=0x4525e4, rho=0x1336d8)
    at eval.c:749
#39 0x3a8f8 in eval (e=0x4525f8, rho=0x1336d8) at eval.c:156
#40 0x3b738 in do_begin (call=0x452648, op=0x107dbc, args=0x45265c,
    rho=0x1336d8) at eval.c:560
#41 0x3a8f8 in eval (e=0x452648, rho=0x1336d8) at eval.c:156
---Type <return> to continue, or q <return> to quit---
#42 0x3ac4c in applyClosure (call=0x4735b4, op=0x520304, arglist=0x133ee4,
    rho=0x1d4420, suppliedenv=0x107560) at eval.c:269
#43 0x3a974 in eval (e=0x4735b4, rho=0x1d4420) at eval.c:165
#44 0x3a734 in eval (e=0x1349c0, rho=0x134308) at eval.c:118
#45 0x3a674 in eval (e=0x111330, rho=0x134308) at eval.c:100
#46 0x3bf40 in evalList (el=0x1211f4, rho=0x134308) at eval.c:825
#47 0x3a884 in eval (e=0x121208, rho=0x134308) at eval.c:154
#48 0x3bcf4 in do_set (call=0x121244, op=0x107d1c, args=0x121230, rho=0x134308)
    at eval.c:749
#49 0x3a8f8 in eval (e=0x121244, rho=0x134308) at eval.c:156
#50 0x3b738 in do_begin (call=0x121258, op=0x107dbc, args=0x12126c,
    rho=0x134308) at eval.c:560
#51 0x3a8f8 in eval (e=0x121258, rho=0x134308) at eval.c:156
#52 0x3ac4c in applyClosure (call=0x473730, op=0x121848, arglist=0x134998,
    rho=0x1d4420, suppliedenv=0x107560) at eval.c:269
#53 0x3a974 in eval (e=0x473730, rho=0x1d4420) at eval.c:165
#54 0x3bcf4 in do_set (call=0x47376c, op=0x107d1c, args=0x473758, rho=0x1d4420)
    at eval.c:749
#55 0x3a8f8 in eval (e=0x47376c, rho=0x1d4420) at eval.c:156
#56 0x3b738 in do_begin (call=0x46903c, op=0x107dbc, args=0x473780,
    rho=0x1d4420) at eval.c:560
#57 0x3a8f8 in eval (e=0x46903c, rho=0x1d4420) at eval.c:156
#58 0x3ac4c in applyClosure (call=0x3242f8, op=0x520fe8, arglist=0x1d4ec0,
    rho=0x5cb7b8, suppliedenv=0x107560) at eval.c:269
#59 0x3a974 in eval (e=0x3242f8, rho=0x5cb7b8) at eval.c:165
#60 0x3bcf4 in do_set (call=0x324280, op=0x107d1c, args=0x3242d0, rho=0x5cb7b8)
    at eval.c:749
#61 0x3a8f8 in eval (e=0x324280, rho=0x5cb7b8) at eval.c:156
#62 0x3b738 in do_begin (call=0x325bf8, op=0x107dbc, args=0x32426c,
    rho=0x5cb7b8) at eval.c:560
#63 0x3a8f8 in eval (e=0x325bf8, rho=0x5cb7b8) at eval.c:156
#64 0x3b278 in do_for (call=0x323bc8, op=0x107a9c, args=0x323bdc, rho=0x5cb7b8)
    at eval.c:435
---Type <return> to continue, or q <return> to quit---
#65 0x3a8f8 in eval (e=0x323bc8, rho=0x5cb7b8) at eval.c:156
#66 0x3b738 in do_begin (call=0x32638c, op=0x107dbc, args=0x323b8c,
    rho=0x5cb7b8) at eval.c:560
#67 0x3a8f8 in eval (e=0x32638c, rho=0x5cb7b8) at eval.c:156
#68 0x3aef8 in do_if (call=0x31e31c, op=0x1079fc, args=0x31e3f8, rho=0x5cb7b8)
    at eval.c:353
#69 0x3a8f8 in eval (e=0x31e31c, rho=0x5cb7b8) at eval.c:156
#70 0x3b738 in do_begin (call=0x3278f4, op=0x107dbc, args=0x31e308,
    rho=0x5cb7b8) at eval.c:560
#71 0x3a8f8 in eval (e=0x3278f4, rho=0x5cb7b8) at eval.c:156
#72 0x3ac4c in applyClosure (call=0x328718, op=0x5820f4, arglist=0x5cbca4,
    rho=0x1409b4, suppliedenv=0x107560) at eval.c:269
#73 0x3a974 in eval (e=0x328718, rho=0x1409b4) at eval.c:165
#74 0x3b738 in do_begin (call=0x3298fc, op=0x107dbc, args=0x328704,
    rho=0x1409b4) at eval.c:560
#75 0x3a8f8 in eval (e=0x3298fc, rho=0x1409b4) at eval.c:156
#76 0x3ac4c in applyClosure (call=0x141738, op=0x5822e8, arglist=0x141698,
    rho=0x148eac, suppliedenv=0x107560) at eval.c:269
#77 0x3a974 in eval (e=0x141738, rho=0x148eac) at eval.c:165
#78 0x2a8d8 in do_docall (call=0x141738, op=0x10c240, args=0x148e0c,
    rho=0x148eac) at coerce.c:1230
#79 0x49bb4 in do_internal (call=0xe8950, op=0x10c218, args=0x148e0c,
    env=0x148eac) at names.c:768
#80 0x3a8f8 in eval (e=0x2c0e4c, rho=0x148eac) at eval.c:156
#81 0x3ac4c in applyClosure (call=0x33632c, op=0x2c0ed8, arglist=0x14903c,
    rho=0x5176c8, suppliedenv=0x107560) at eval.c:269
#82 0x3a974 in eval (e=0x33632c, rho=0x5176c8) at eval.c:165
#83 0x3bcf4 in do_set (call=0x336264, op=0x107d1c, args=0x336304, rho=0x5176c8)
    at eval.c:749
#84 0x3a8f8 in eval (e=0x336264, rho=0x5176c8) at eval.c:156
#85 0x3b738 in do_begin (call=0x336228, op=0x107dbc, args=0x336214,
    rho=0x5176c8) at eval.c:560
#86 0x3a8f8 in eval (e=0x336228, rho=0x5176c8) at eval.c:156
---Type <return> to continue, or q <return> to quit---
#87 0x3aef8 in do_if (call=0x334bf8, op=0x1079fc, args=0x334c0c, rho=0x5176c8)
    at eval.c:353
#88 0x3a8f8 in eval (e=0x334bf8, rho=0x5176c8) at eval.c:156
#89 0x3b738 in do_begin (call=0x33a2c4, op=0x107dbc, args=0x334bbc,
    rho=0x5176c8) at eval.c:560
#90 0x3a8f8 in eval (e=0x33a2c4, rho=0x5176c8) at eval.c:156
#91 0x3ac4c in applyClosure (call=0x2e5a6c, op=0x5825e0, arglist=0x517b64,
    rho=0x56e144, suppliedenv=0x107560) at eval.c:269
#92 0x3a974 in eval (e=0x2e5a6c, rho=0x56e144) at eval.c:165
#93 0x3bcf4 in do_set (call=0x2e5a30, op=0x107d1c, args=0x2e5a44, rho=0x56e144)
    at eval.c:749
#94 0x3a8f8 in eval (e=0x2e5a30, rho=0x56e144) at eval.c:156
#95 0x3b738 in do_begin (call=0x2e74fc, op=0x107dbc, args=0x2e5a08,
    rho=0x56e144) at eval.c:560
#96 0x3a8f8 in eval (e=0x2e74fc, rho=0x56e144) at eval.c:156
#97 0x3ac4c in applyClosure (call=0x155148, op=0x57fcc8, arglist=0x56e374,
    rho=0x10f594, suppliedenv=0x107560) at eval.c:269
#98 0x3a974 in eval (e=0x155148, rho=0x10f594) at eval.c:165
#99 0x3a778 in eval (e=0x56e694, rho=0x10f594) at eval.c:129
#100 0x3c458 in do_eval (call=0x1dbd60, op=0x10f594, args=0x56e400,
    rho=0x56e48c) at eval.c:1007
#101 0x49bb4 in do_internal (call=0xe8950, op=0x10d938, args=0x56e400,
    env=0x56e48c) at names.c:768
#102 0x3a8f8 in eval (e=0x1dbdc4, rho=0x56e48c) at eval.c:156
#103 0x3ac4c in applyClosure (call=0x31ff64, op=0x1dbe50, arglist=0x56e5f4,
    rho=0x15e6e4, suppliedenv=0x107560) at eval.c:269
#104 0x3a974 in eval (e=0x31ff64, rho=0x15e6e4) at eval.c:165
#105 0x3bcf4 in do_set (call=0x31ffa0, op=0x107d1c, args=0x31ff8c,
    rho=0x15e6e4) at eval.c:749
#106 0x3a8f8 in eval (e=0x31ffa0, rho=0x15e6e4) at eval.c:156
#107 0x3b738 in do_begin (call=0x31f3ac, op=0x107dbc, args=0x31ffb4,
    rho=0x15e6e4) at eval.c:560
#108 0x3a8f8 in eval (e=0x31f3ac, rho=0x15e6e4) at eval.c:156
---Type <return> to continue, or q <return> to quit---
#109 0x3b278 in do_for (call=0x321238, op=0x107a9c, args=0x321224,
    rho=0x15e6e4) at eval.c:435
#110 0x3a8f8 in eval (e=0x321238, rho=0x15e6e4) at eval.c:156
#111 0x3b738 in do_begin (call=0x31e808, op=0x107dbc, args=0x32124c,
    rho=0x15e6e4) at eval.c:560
#112 0x3a8f8 in eval (e=0x31e808, rho=0x15e6e4) at eval.c:156
#113 0x3ac4c in applyClosure (call=0x15f210, op=0x321350, arglist=0x15ef18,
    rho=0x10f594, suppliedenv=0x107560) at eval.c:269
#114 0x3a974 in eval (e=0x15f210, rho=0x10f594) at eval.c:165
#115 0x435d8 in R_ReplConsole (rho=0x10f594, savestack=0, browselevel=0)
    at main.c:260
#116 0x43a04 in mainloop () at main.c:439
#117 0x8bd40 in main (ac=0, av=0xefffefe8) at system.c:498
(gdb)

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 16 Oct 1998, Paul Gilbert wrote:

            
<great big long trace>

Segfaults in the internal R code seem to usually be due to an unprotected
pointer being garbage collected (which is why they are unpredictable --
you don't know when garbage collection will be triggered).  This looks
like one of these.

Unfortunately the only reliable way to find out exactly where it is is to
get a reproducible segfault.  The development version can be set up to
garbage collect at every opportunity, which helps make the problem
reproducible, and then it's possible to track down when the offending
pointer gets mangled and see what wasn't protected. As you can imagine,
it's somewhat time consuming. Quite a few of these bugs have been found
and fixed for 0.63.

	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._