Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
When i execute my small perl program from the command prompt, i'm receiving a below error
Bus error(coredump)

If we run "file core"
O/P: core: core file from 'perl-static' - received SIGBUS.
Is there any hint to know the fialure reason?
Thanks in advance

Replies are listed 'Best First'.
Re: Coredump error.
by Corion (Patriarch) on Jul 18, 2006 at 08:59 UTC

    Without seeing the code, it's hard to tell. The most likely causes for "bus errors" (or segfaults) are external libraries linked into Perl which cause memory corruption. So your best bet is to stepwise remove all modules that use external libraries until the error goes away, and then add them in again, one by one, to eliminate the offending external library.

    Another possibility for intermittent segfaults is faulty hardware, like RAM that gets too hot or something similar.

Re: Coredump error.
by dave_the_m (Monsignor) on Jul 18, 2006 at 12:13 UTC
    This is covered by perlbug #39358. I know how to fix it, just haven't got round to it yet.

    Dave.

Re: Coredump error.
by gellyfish (Monsignor) on Jul 18, 2006 at 08:59 UTC

    perl should never core dump. Please could you give us an indication of the perl version and operating system (the output of perl -V will suffice) as well as a small example of the Perl code that causes this behaviour.

    /J\

Re: Coredump error.
by cdarke (Prior) on Jul 18, 2006 at 11:44 UTC
    It appears to be the sort that is causing the crash. This is 'a bit' dubious because you are referring to the same array in the sort cmp as well as in the result. I suggest:
    { my @sortkey2 = sort { lc($names[$sortkey[$a]]) cmp lc($names[$sortkey[$b]]) } @sortkey; @sortkey = @sortkey2; }
    BTW the parentheses make no difference, but are not necessary (and I'm sure you can think of a better way to print the array ;-)).
Re: Coredump error.
by Moron (Curate) on Jul 18, 2006 at 10:12 UTC
    To give us some kind of starting point, try giving us the code (however small!) and the output from the command:
    $ uname -a

    -M

    Free your mind

      Thanks for the help
      The perl code is as below
      (@sortkey)=('0','1','2','3','4','5','6','7','8','9','10','11','12','1 +3','14','15 '); (@names)=("xyz","iop","abc","opop","qwer","kkkk","wwww","qqqq","wwpp", +"klkoo","p pii","mmmm","hhhh","yyyy","ssss","eee"); @sortkey = sort { lc($names[$sortkey[$a]]) cmp lc($names[$sortkey[$b]] +) } @sortk ey; foreach $i (0..$#names) { print "$names[$sortkey[$i]]\n"; }
      the exact output is
      => perl try70.pl
      Bus error(coredump)
      the perl version is perl5.8.7 and running on HPUX
      thanks,
      Renu.

        Ah. Yes that does coredump with both 5.9.4 @ DEVEL28476 and 5.8.8 that I have here, but not with 5.8.1.

        Please can you use the perlbug program to submit a report including the offending code.

        /J\

        I don't have all the required Perl versions to test here, but the "( @arr ) = ( listelement, ... )" construction looks suspiciously ambiguous. Have you tried dropping the brackets from the left hand side of the list-to-array assignments?

        -M

        Free your mind