[comp.lang.perl] Perl dumps core on SparcStation: Script At 11 ...

mark@DRD.Com (Mark Lawrence) (07/19/90)

$Header: perly.c,v 3.0.1.5 90/03/27 16:20:57 lwall Locked $
Patch level: 18

SparcStation 1+ (4/65) and Sun 3/60, both running 4.0.3.

The following script runs fine on the 3/60 but dumps core (Segmentation
fault) on the Sparc.


dbmopen(units,"foo",0666) || die "Can't open units ndbm files";
$unitfile = "foo.txt";
open unitfile || die "Can't open $unitfile";
while (<unitfile>) {
  next if (/^#/ || /^!/);
  ($symbol,$type,$id,$name) = split(/[\t\n ]/);
  print "$symbol,$name,$type,$id\n";
  $units{$symbol,'Type'} = $type;     # DUMPS CORE AT THIS LINE
  $units{$symbol,'ID'} = $id;
  $units{$symbol,'Name'} = $name;
}
close(unitfile);
dbmclose(units);

foo.txt:
!Symbol	Type	id	name
gpm	11	2	FlowRate

audit:
262 sparky:/home/rtd/mark/tmp% perl foo.pl
gpm,FlowRate,11,2
Segmentation fault (core dumped)
263 sparky:/home/rtd/mark/tmp% ll core
-rw-r--r--  1 mark     staff     8499632 Jul 19 08:25 core
264 sparky:/home/rtd/mark/tmp% swat
GDB 3.5, Copyright (C) 1989 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for
details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /usr/local/bin/perl...
(no debugging symbols found)...done.
Type "help" for a list of commands.
(gdb) core core
Core file is from "perl".
Program terminated with signal 11, Segmentation fault.
(gdb) where
#0  0x4476c in dbm_nextkey ()
#1  0x43c60 in dbm_fetch ()
#2  0x2026c in hfetch ()
#3  0x1aaec in eval ()
#4  0x17aa8 in eval ()
#5  0x3f00 in cmd_exec ()
#6  0x4794 in cmd_exec ()
#7  0x22df8 in main ()
(gdb)

Selected macros from the Makefile:
CC = gcc
YACC = yacc
bin = /usr/local/bin
privlib = /usr/local/lib/perl
mansrc = /usr/man/manl
manext = l
CFLAGS = -fpcc-struct-return -I/usr/include/sun -O
LDFLAGS =
SMALL =
LARGE =
mallocsrc = malloc.c
mallocobj = malloc.o
SLN = ln -s
libs = -ldbm -lm

GCC Version:
267 sparky:/usr/local/src/perl% gcc -v
gcc version 1.37.1

jet@karazm.math.uh.edu (J. Eric Townsend) (07/21/90)

In article <1990Jul19.133014.1445@DRD.Com> mark@drd.Com (Mark Lawrence) writes:
>Core file is from "perl".
>Program terminated with signal 11, Segmentation fault.
>(gdb) where
>#0  0x4476c in dbm_nextkey ()
>#1  0x43c60 in dbm_fetch ()
[etc.]

Two things:
0. Segmentation faults are common on the sparc, as it's a word-aligned
box, and compiler tools seem to ignore things like alignment these
days. 1/2 :-)

1. There is a known bug in the gcc compiler regarding passing structures
on the stack.  It is supposed to be fixed in the next gcc release.
I use cc(1) on perl, and anything else that crashes (and shouldn't),
including the Poskanzer tools, parts of X11R4 (the rgb database stuff,
which also uses dbm and dies under gcc), and a few other goodies.
--
J. Eric Townsend -- University of Houston Dept. of Mathematics (713) 749-2120
Internet: jet@uh.edu
Bitnet: jet@UHOU
Skate UNIX(r)