[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: Problem with 11/785 running 4.3 BSD
Ha! looks like BDS4.3 really loses on this count.
I just discovered this the hard way 4 days ago.
The bug is that the Lsave() code closes all the open FILE * _iob[]
structs. Problem is, these AREN'T all contiguous in the BSD4.3 _iob[]
layout. This causes havoc when flose() is called on some stacked
return addresses, etc.
(Side note: this exposes a second bug. Even though free() gets pissed
off at the memory it just got handed and calls FEerror(), something
still corrupts the malloc arena, and make_simple_string dies the big
SEGV death.)
A quick ~portable hack fix is just to close (iobs < 20). The correct
fix probably involves BSD4.3 specific code. (In discussions with Ken
Rimey on this matter, he made an excellent suggestion to call _fwalk()
with a function that calls fclose on the _iob *only* if the _iob isn't
stderr.)
Diffs that I use here at mgm (vax750 w. bsd4.3) follow.
*** /usr/local/okcl/c/unixsave.c-dist Thu Jun 4 03:07:55 1987
--- /usr/local/okcl/c/unixsave.c Mon Nov 16 11:30:52 1987
***************
*** 308,313 ****
--- 308,322 ----
fclose(save);
}
+ #ifdef BSD4_3
+ fclose_notstderr(iop)
+ FILE *iop;
+ {
+ if (iop != stderr)
+ fclose (iop);
+ }
+ #endif
+
Lsave()
{
char filename[256];
***************
*** 318,323 ****
--- 327,335 ----
/*
_cleanup();
*/
+ #ifdef BSD4_3
+ _fwalk (fclose_notstderr);
+ #else
{
FILE *p;
int nfile;
***************
*** 330,335 ****
--- 342,348 ----
for (p = &_iob[3]; p < &_iob[nfile]; p++)
fclose(p);
}
+ #endif
memory_save(kcl_self, filename);
/*
_exit(0);
---
Wolfgang Rupprecht UUCP: mit-eddie!mgm.mit.edu!wolfgang
(or) mirror!mit-mgm!wolfgang
ARPA: wolfgang@mgm.mit.edu (IP addr 18.82.0.114)