Subject: REPOST: FIXES to perl/makewhatis (core dump on OW3 man pages)

From: [email-masked] (Erez "HWank1" Zadok)
Date: 3 Dec 92 12:42:05 GMT

[This is a repost... -Erez]

I've found three small bugs in the the latest version of perl (4.035), which
I fixed.

The bugs only appeared when I got Tom Christiansen's man package, and ran
the makewhatis script.  Furthermore, it only occurred for one particular set
of manual pages -- SunOS's OpenWindows 3.

Since it seemed related to DBM, I tried to recompile perl with several
possible combinations of Sun's /bin/cc, gcc (2.2.2), ndbm, gdbm,
- -DDEBUGGING, -traditional (for gcc), Perl's malloc, Sun's malloc, etc. to no
avail.  Perl was still dumping core with a segmentation fault.  "make test"
was ok.  I was running on various Sun 4 machines, running SunOS 4.1.2.

After debugging I found out that perl was trying to dereference pointers
that were not initialized.

I fixed this by adding initialization to three declarations in perl.h.  The
ones to rsfp and statstab were needed for non-compressed man pages.  When I
started using compressed man pages I discovered I had to initialize fdpid as
well.  Now everything works fine.  Here is the diff file:

*** array.h.orig	Tue Nov 24 02:16:30 1992
--- array.h	Mon Nov 23 14:31:16 1992
***************
*** 17,22 ****
--- 17,33 ----
   * 
   */
  
+ #ifdef NULL
+ #undef NULL
+ #endif
+ #ifndef I286
+ #  define NULL 0
+ #else
+ #  define NULL 0L
+ #endif
+ #define Null(type) ((type)NULL)
+ #define Nullarray Null(ARRAY*)
+ 
  struct atbl {
      STR	**ary_array;
      STR **ary_alloc;
*** perl.h.orig	Tue Nov 24 02:16:10 1992
--- perl.h	Mon Nov 23 14:30:51 1992
***************
*** 868,874 ****
  
  EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  EXT char *origfilename;
! EXT FILE * VOLATILE rsfp;
  EXT char buf[1024];
  EXT char *bufptr;
  EXT char *oldbufptr;
--- 868,874 ----
  
  EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  EXT char *origfilename;
! EXT FILE * VOLATILE rsfp INIT(Nullfp);
  EXT char buf[1024];
  EXT char *bufptr;
  EXT char *oldbufptr;
***************
*** 952,958 ****
  EXT struct stat statbuf;
  EXT struct stat statcache;
  EXT STAB *statstab INIT(Nullstab);
! EXT STR *statname;
  #ifndef MSDOS
  EXT struct tms timesbuf;
  #endif
--- 952,958 ----
  EXT struct stat statbuf;
  EXT struct stat statcache;
  EXT STAB *statstab INIT(Nullstab);
! EXT STR *statname INIT(Nullstr);
  #ifndef MSDOS
  EXT struct tms timesbuf;
  #endif
***************
*** 1013,1019 ****
  EXT ARRAY *lineary;		/* lines of script for debugger */
  EXT ARRAY *dbargs;		/* args to call listed by caller function */
  
! EXT ARRAY *fdpid;		/* keep fd-to-pid mappings for mypopen */
  EXT HASH *pidstatus;		/* keep pid-to-status mappings for waitpid */
  
  EXT int *di;			/* for tmp use in debuggers */
--- 1013,1019 ----
  EXT ARRAY *lineary;		/* lines of script for debugger */
  EXT ARRAY *dbargs;		/* args to call listed by caller function */
  
! EXT ARRAY *fdpid INIT(Nullarray); /* keep fd-to-pid mappings for mypopen */
  EXT HASH *pidstatus;		/* keep pid-to-status mappings for waitpid */
  
  EXT int *di;			/* for tmp use in debuggers */

Erez Zadok.
Central Research Facilities.
Columbia University Department of Computer Science.
- ---
"A wank's morning starts one jiffy    | Arpa:   [email-masked]
 after midnight."                     | Usenet: ...!rutgers!columbia!cs!ezk
 -HebrewWank #1 (US meaning, not UK!) | Bitnet: [email-masked]