Core dump in a simple shell script!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Core dump in a simple shell script!
# 1  
Old 01-16-2015
Core dump in a simple shell script!

Hi

I have a very simple shell script that is dumping core -

testScript -

Code:
#!/bin/ksh
PROG=${0##*/}   # basename
if [ $# -ne 1 ]; then
        print -u2 "Usage: $PROG filename"
        exit 1
fi
MDY=$(date '+%m%d%y')
if [ -f ${1}.${MDY} ]; then
        cat ${1}.out >>${1}.${MDY}
else
        cp -p ${1}.out ${1}.${MDY}
fi

Code:
gdb testScript core.11632
Core was generated by `/bin/ksh /bin/testScript /data/SREF'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000000004c16e7 in ?? ()

Here we are passing another file, named /data/SREF as the only argument.

I have tested the code several times and it is working without any issue. So why it's dumping core in the customer's machine?

I read somewhere that when a shell script dumps core, then the issue should be related to the shell binary itself and not with the code. The shell binary is corrupted and we should install Linux patches to solve the problem.

Is the above statement true? Why this simple shell script is dumping core?

Thanks
# 2  
Old 01-16-2015
Have a try run with some quotings.
Like around "${1}.${MDY}"
And add a space & quotes >> "${1}.${MDY}"

Welll, not sure if that helps, but might be worth a try.

Just recently i've experienced a core dump too while running a shell script.
Though it just occoured when the binary was executed in background (subshell of script), but it worked well when called regulary.

hth
This User Gave Thanks to sea For This Post:
# 3  
Old 01-16-2015
Is this running as root? What does backtrace in gdb reveal (calling sequence) or bt full for detail.
Did you try gdb /bin/ksh <corefile>, gdb only requires an executable call, but the ?? indicates it can't figure out the symbolic reference for the address (function or library).
At a guess resource (ulimit/environment difference) between test environment and customer's.

Last edited by blackrageous; 01-16-2015 at 12:55 PM..
This User Gave Thanks to blackrageous For This Post:
# 4  
Old 01-16-2015
That's a bug in the shell all right. What version and variety of ksh is this?
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 01-27-2015
Quote:
Originally Posted by Corona688
That's a bug in the shell all right. What version and variety of ksh is this?
Hi All

Sorry for the late update in this post. Actually I don't have direct access to the customer system and customer support folk went for a vacation.

I edited the code as "sea" has suggested and placed it in the customer machine. Time will tell whether the changes are working or not.

GDB "bt full" does not give anything -

Code:
Program terminated with signal 11, Segmentation fault.
#0  0x00000000004c16e7 in ?? ()
(gdb) bt full
#0  0x00000000004c16e7 in ?? ()
No symbol table info available.

As Corona688 has suggested it's a bug in the KSH and requested for more information, here it is -
Code:
$ksh --version
sh (AT&T Research) 93t+ 2010-06-21

OS version -
Code:
$uname -a
2.6.18-348.16.1.el5 #1 SMP x86_64 x86_64 x86_64 GNU/Linux

How to know that this is indeed a bug in KSH?

Many thanks in advance.
# 6  
Old 01-27-2015
Yes, this looks like the shell is at fault but maybe not because of a bug. I suggest to reinstall the ksh first, just to make sure the binary is unaltered.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Core dump in HP-UX

Hi Guys, I was wondering if somebody could give me a link to a very good source of information or document about core dump process and How to's about it. I have also googled it and found some articles myself. Thanks Messi (1 Reply)
Discussion started by: messi777
1 Replies

2. UNIX for Dummies Questions & Answers

No core dump

my progrme complaints 'Segmentation fault'. How to let it print 'Segmentation fault(core dumped)' and generate core dump file? $ulimit unlimited (22 Replies)
Discussion started by: vistastar
22 Replies

3. AIX

Core dump

Hi , I want to read core dump file on AIX5.3. While i am trying to use following commands, i am getting only few lines of information. ux201p3:e46123> dbx capsWrkstnMgr core Type 'help' for help. reading symbolic information ... Segmentation fault in malloc_common.extend_brk at... (1 Reply)
Discussion started by: rps
1 Replies

4. Programming

core dump

how to view core dumped file using gdb and how to extract information from the coredumped file.can we get similar information from the other utilites like strace or ptrace. (2 Replies)
Discussion started by: Manabhanjan
2 Replies

5. UNIX for Advanced & Expert Users

Core Dump

Hello all, Iam new to unix while executing java program which finely working in windows know iam testing with unix ,but in unix while executing iam getting core dump, my application is in client server environment and it is menu drivrn application on clicking options no problem but after some time... (1 Reply)
Discussion started by: vinp
1 Replies

6. Solaris

Shell script to send email alert for core dump

Friends, I am in search for a shell script that is capable of running as a cronjob and have to send out an email when ever there is a CORE DUMP. Please post the hints to achieve my goal. Thanks in advance. (1 Reply)
Discussion started by: rtatineni
1 Replies

7. UNIX for Advanced & Expert Users

core dump

Hi All, i am new to this forum.i want detail of reading the core file and trace the problem because of what the program get crashed.please help me.if any body knows any website or tutoril plese let me know. sudhir (6 Replies)
Discussion started by: sudhir patnaik
6 Replies

8. Programming

about core dump

MY friends: my program under sco unix have a problem? it create a core dump file on the path when execute program , but i can't find the error of the C program ,i don't know how to see the error about my program use core, please help me or give me some suggest and what tools can use... (1 Reply)
Discussion started by: zhaohaizhou
1 Replies

9. UNIX for Dummies Questions & Answers

core dump

Hi , Working on AIX 4.3. An internal error from my apps engine suddenly causes the engine to die. During this time i do notice a core file being dumped in the directory from where I try to re-start my engine. Q is how does one read this core file, or I should say 'what is this core file'? thnx (2 Replies)
Discussion started by: buRst
2 Replies

10. UNIX for Dummies Questions & Answers

help, what is the difference between core dump and panic dump?

help, what is the difference between core dump and panic dump? (1 Reply)
Discussion started by: aileen
1 Replies
Login or Register to Ask a Question