Re: segmentation fault at the end of script

From: Andy Hassall (andy_at_andyh.co.uk)
Date: 11/04/03


Date: Mon, 03 Nov 2003 23:41:59 +0000

On 3 Nov 2003 02:36:34 -0800, jsivignon@ifrance.com (sivignon) wrote:

>I'm writing a php script which deals with 3 ORACLE databases.
>This script is launch by a script shell on an linux machine like this :
>/../php/bin/php ./MySript.php (PHP 4.3.3)
>
>My script works fine and do all what I need.
>But at the end of the execution, I can read "Segmentation Fault".
>
>The segmentation fault appear at the end of my script execution,
>no line code is responsible of this. Somebody has been confronted
>with this problem ?

 What distribution of Linux, and what version(s) of Oracle? (Oracle's only
officially certified on a few commercial Linux distributions e.g. RedHat
Advanced Server - but it works on many others, if you set it up right. It has
more trouble on some distributions than others ... )

 What's in the code? Have you tried examining the core dump with gdb to give
you some idea where the segfault happened?

 For example, using a program that'll deliberately crash:

andyh@server:~/tmp$ cat dumpy.c
int crash() {
  char* crashycrashy = 12345;
  *crashycrashy = 100;
}

int main() {
  crash();
}
andyh@server:~/tmp$ gcc -o dumpy dumpy.c
dumpy.c: In function `crash':
dumpy.c:2: warning: initialization makes pointer from integer without a cast
andyh@server:~/tmp$ ./dumpy
Segmentation fault (core dumped)

 OK - so it's crashed, and dumped out a 'core' file.

 You can use gdb (the debugger) to load up the program and the core file, and
it'll be able to give clues as to what happened at the time of the crash:

andyh@server:~/tmp$ gdb dumpy core
GNU gdb 5.2
Copyright 2002 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 "i386-slackware-linux"...
Core was generated by `./dumpy'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0 0x080483d0 in crash ()
(gdb)

 Here it's saying that the crash happened in the crash() function. (If it were
compiled with debugging options it'd give even more information).

 You can use the 'bt' (backtrace) command to get the stack of calls that lead
up to the crash:

(gdb) bt
#0 0x080483d0 in crash ()
#1 0x080483e3 in main ()
#2 0x4003317d in __libc_start_main () from /lib/libc.so.6

--
Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)


Relevant Pages

  • Re: Not able to debug Core, SunOS 5.10, Gdb also crash.
    ... core using gdb, GDB itself crashes and gives core. ... here is test program, always crash, not able to use GDB. ... Fix the warnings first, then you might be able to see the wood from the ...
    (comp.unix.programmer)
  • Re: Problems with BCE network adapter (Dell PE2950)
    ... how much data is in your NFS mounted directory? ... First boot with debug driver crash very shortly after nfs mounts ... Second boot with the debug driver system does not crash after cat * ... identical PE1950 the system crashed (Again producing a corrupt core ...
    (freebsd-net)
  • Re: on input form showing error message for duplicate entry.
    ... my SITE will not crash. ... you can 'what if' the daylights out of this script. ... this scenario DOES NOT exist in this script. ... | i think, there is no sense to speak more about it, think again about my ...
    (alt.php)
  • Re: oops in :snd_pcm_oss:resample_expand+0x19c/0x1f0
    ... Currently we can use gdb but only for linearly mapped region. ... I mean kernel crash handler. ... we can write gdb scripts to implement ... Displaying even the currently non executing threads using "info threads" ...
    (Linux-Kernel)
  • RE: How to ensure a script to run when system crashes
    ... If the latter (Crash) there is no way to run some code AFTER the system has ... Your best bet is disabling Wake-On-Lan in the BIOS which should disable your ... I am running wmi script to enable one of the LAN connections during system ... for shut down but the unload event is not called when the system crashes. ...
    (microsoft.public.win32.programmer.wmi)