Subject: Re: sed drops core
To: Havard Eidnes <Havard.Eidnes@runit.sintef.no>
From: Thomas Eberhardt <thomas@mathematik.uni-Bremen.de>
List: current-users
Date: 11/20/1993 23:00:10
> 
> > trying to do the whatis database in /etc/daily cron job. I know this is a
> > FAQ, but what was the resolution?
> 
> Stick a bzero() in xmalloc() in misc.c at the obvious place -- that's what
> I ended up doing, anyway.  Sed was doing accesses to uninitialized memory.
> After this change my sed is once again able to create the whatis database.
> 
> Finding the problem involved moving (and porting) the sed and regex sources
> to a Sun/SPARC host and running sed under a debugger with a tool called
> Purify, which helps me to easily find memory access errors such as these.
> 
> BTW, my fix to this bug was only recently reported (as in 10 minutes ago).
> 
> - Havard
> 

I've just looked with gdb and did the following change:

*** usr.bin/sed/compile.c-	Sun Nov  7 11:09:33 1993
--- usr.bin/sed/compile.c	Sat Nov 20 22:44:12 1993
***************
*** 209,214 ****
--- 209,215 ----
  				p = NULL;
  			cmd2 = xmalloc(sizeof(struct s_command));
  			cmd2->code = '}';
+ 			cmd2->a1 = cmd2->a2 = NULL;
  			*compile_stream("}", &cmd->u.c, p) = cmd2;
  			cmd->next = cmd2;
  			link = &cmd2->next;

-- 
thomas@mathematik.uni-Bremen.de | Centrum für Complexe Systeme & Visualisierung
Thomas Eberhardt                | Universität Bremen, FB 3, Bibliothekstr. 1
Kölner Str. 4, D-28327 Bremen   | D-28359 Bremen, Germany
Home Phone: +49 421 472527      | FAX: +49 421 218-4236, Office: 218-4823

------------------------------------------------------------------------------