Joerg Schumacher writes: > > Hi! > > I've had a problem with perl5.005_02 and Term::ReadLine::Gnu dumping > core on a solaris 5.5.1 box. A little bit of debugging revealed that > readline-4.0 calls putenv(3) for LINES and COLUMNS during initialization. > If these vars weren't present in the environment the call to putenv() > changes the value of char **environ. my_setenv() tests this value to > decide wether to copy the environment. In my case it didn't copy and > thus dumped core on Safefree() as result of an assignment to $ENV{PATH}. > > Patch appended. > > Kind regards, > Joerg > > -- > Gaertner Datensysteme 38114 Braunschweig > Joerg Schumacher Hamburger Str. 273a > Tel: 0531-2335555 Fax: 0531-2335556 > > > > > --- perl5.005_02/util.c.orig Wed Nov 17 00:21:06 1999 > +++ perl5.005_02/util.c Wed Nov 17 00:21:50 1999 > @@ -1413,12 +1413,14 @@ > my_setenv(char *nam, char *val) > { > register I32 i=setenv_getix(nam); /* where does it go? */ > + static int copyenv = 1; > > - if (environ == PL_origenviron) { /* need we copy environment? */ > + if (copyenv) { /* need we copy environment? */ > I32 j; > I32 max; > char **tmpenv; > > + copyenv = 0; > /*SUPPRESS 530*/ > for (max = i; environ[max]; max++) ; > New(901,tmpenv, max+2, char*); Without further explanation I hardly think this is a solution. The real problem is that putenv() of Term::ReadLine::Gnu is mentioning a wrong malloc() [though I have no idea how this might have happened - but it does, at least on Solaris 2.7]. Note that malloc.c of 5.005_62 already includes Perl_putenv(). Since the default now is to have backward compatibility (including overriding malloc()), we may need to byte a bullet and make Perl by default override putenv() too (same as it is done for calloc(): #if POLLUTE... # define Perl_calloc calloc # define Perl_putenv putenv #endif ). I think this (and possibly strdup(), for which Perl_strdup() is already in place) will fix 95% of problems with mismatched malloc()s. Ilya