Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!rice!sun-spots-request From: eirik@elf.tn.cornell.edu (Eirik Fuller) Newsgroups: comp.sys.sun Subject: SunOS 4.1 localtime bug Keywords: SunOS Message-ID: <8132@brazos.Rice.edu> Date: 24 May 90 17:53:40 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 64 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 9, Issue 180, message 11 The release notes for SunOS 4.1 suggest #define SYSTEM_MALLOC for GNU emacs, to avoid an abort in GNU malloc. The enclosed patch gives a workaround for GNU malloc so that it too can dodge a bug in localtime and avoid this abort. The enclosed script demonstrates the localtime bug without using any GNU software. *** malloc.c~ Fri Apr 7 22:12:10 1989 --- malloc.c Tue May 8 07:07:22 1990 *************** *** 476,482 **** --- 476,487 ---- multiple of 8, then figure out which nestf[] area to use. Both the beginning of the header and the beginning of the block should be on an eight byte boundary. */ + #ifdef SUNOS_LOCALTIME_BUG + /* SunOS 4.1 localtime scribbles on the ninth byte. */ + nbytes = (n + ((sizeof *p + 15) & ~15) + EXTRA + 15) & ~15; + #else nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7; + #endif { register unsigned int shiftr = (nbytes - 1) >> 2; #!/bin/sh - # This script demonstrates a bug in SunOS 4.1 localtime.o # It shows a call to calloc that allocates eight bytes, and the value # returned by calloc. Then it stops just before the instruction that # writes the next byte past the eight byte region allocated by that # call to calloc. The breakpoint at free is to show that the region is # not freed in the meantime. cat << 'EOF' > t.c main () { tzsetwall(); exit (0); } EOF echo cc -Bstatic -o t t.c cc -Bstatic -o t t.c echo adb t adb t << 'EOF' tzsetwall-126c:b :r :s :s :s !echo '#' 'calloc(8,1)'