Segmentation (CoreDump) error !!

Hi all,

I am trying to create few directories using script and its giving me segmentation error.

#!/bin/ksh

createDirectories()

createDirectories()
{
        cat dirs | \
        while read line
        do
                mkdir "/clocal/mqbrkrs/user/mqsiadm/varun/ClientSecurity/$line", 0777
        done
}

and file "dirs" contains the name of the directories to be created.

Please suggest !

Thanks
Varun Gupta:b:

Put this after the function declaration

createDirectories

Instead of before it.

what is the intention of ', 0777' on the 'mkdir' call?

Hey Jim,

That won't change the result.
In that case too, i am getting the same error !!

Hey,

Intension to give 0777 is to assign the permissions to the newly created directories.
Even i have tried without this, it gives the same error. As follows:
mkdir "/clocal/mqbrkrs/user/mqsiadm/varun/ClientSecurity/$line"

If you run it with ksh -x scriptname, do you see anything useful?

Segfault sounds vaguely like infinite loop, but it could be something else too, of course.

(Maybe iit gives you a lead to help you solve it yourself. If you do want to post something here, try to trim it down to just a representative part.)

Even using "ksh -x dir_script" it gives the same error without tracking details. it gives the segmentation fault(coredump) in the next line when i try to execute the above command.
Something is strange here !!

See which mkdir the machine is using.

# which mkdir

It's possible that the shell is invoking the wrong binary.

Hey,

It is probably using /bin/mkdir
Then could you please let me explain how does it matter ?

Thanks
Varun Gupta:b:

this is quite strange ..

sorry for being too pessimistic

could you please revisit the contents of the file that contains the directory names ?

and also try executing mkdir command for just one entry in the file ( which contains list of directory names ) and that too from a shell

I meant to ask about that, too. What's in dirs?

Hi

#!/bin/ksh

createDirectories()
{
cat dirs | \
while read line
do
mkdir "/clocal/mqbrkrs/user/mqsiadm/varun/ClientSecurity/$line", 0777
done
}

createDirectories

without ()

look a post by jim mcnamara

Hey,

"dirs" contains the list of names, which are going to be used while creating the directories.

cat dirs -->
CFCONNECT
BVF
ONLINEPAY
ECP
EFT

These are the simply names, which will be used to create directories. These names are constant string, which are then assigned to variable "line" in the script. ($line)

:b:

I hope this should not be the reason, but give it a shot

Ya, you are right this time, its not the reason of Segmentation fault - coredump error.
If i am not wrong, core dump comes when there is some problem with memory allocation or memory address resolution. Is there could be any other reason for that ?
:b:

Did you try to remove the parentheses from the invocation of the function, like taran suggested?

Can you successively remove lines from the script and get it to work without bombing?

Segmentation violation is a fairly unspecific error, it means the program ended up writing to memory it shouldn't write to, but the number of possible root causes for such behavior is large. Basically it's a programming error under any circumstances; the program should catch the error and report a more meaningful diagnostic, rather than plunge ahead into code which doesn't work.

Hey,

Ya, it worked out when removed the braces () while calling the function defined. I don't know why and how this worked out as in other scripts i call functions with braces and it works perfectly fine. I am using AIX5.3 version.
Anyways solution to this problem I got, thanks for all.
But then, if you could help in resolving Open Question, why and how function calls are different ? Sometimes it works with braces () and sometimes it doesn't work.

Thanks.:b: