Article View: gnu.misc.discuss
Article #2324Re: malloc and allocation errors
From: Mark Moraes
Date: Sun, 30 Jan 1994 03:36
Date: Sun, 30 Jan 1994 03:36
71 lines
3281 bytes
3281 bytes
oz@ursa.sis.yorku.ca (Ozan S. Yigit) writes: >take a look at the moraes allocator, ftp-able from cs.toronto.edu as >pub/moraes/malloc.tar.gz. And just after this note (and a couple of years of peace and quiet on the bug front:-), someone found a subtle bug in realloc. Those of you who snarfed my malloc by anonymous ftp can get the fix from ftp.cs.toronto.edu:pub/moraes/malloc-1.13.patch.gz. [As a happy Purify user, I have to say that if you can afford it and are using one of the platforms that they support, I'd recommend Purify (info@pure.com) instead. People interested in a comparison of some of the leading Sun debuggers (including Sentinel) can see Sun Expert, Dec 1993, "Advanced Debuggers".] Enjoy, Mark. -- *** /tmp/T0a17869 Sat Jan 29 21:32:00 1994 --- CHANGES Sat Jan 29 21:31:25 1994 *************** *** 1,2 **** --- 1,8 ---- + Jan 29, 1994 v1.13 + + Subtle realloc bug uncovered by Gianni Mariani's super malloc stress test. + (realloc could return a block less than _malloc_minchunk which could cause + free to die under certain conditions). testmalloc now checks this case. + Dec 15, 1993 *** /tmp/T0a17663 Sat Jan 29 21:02:43 1994 --- version.c Sat Jan 29 21:02:09 1994 *************** *** 1 **** ! char *_malloc_version = "CSRI, University of Toronto Malloc Version 1.12beta"; --- 1 ---- ! char *_malloc_version = "CSRI, University of Toronto Malloc Version 1.13beta"; *** /tmp/T0a17264 Sat Jan 29 20:19:20 1994 --- malloc.c Sat Jan 29 20:18:59 1994 *************** *** 480,483 **** --- 480,485 ---- required = ALLOC_OVERHEAD + (nbytes + sizeof(Word) - 1) / sizeof(Word); + if (required < (size_t) _malloc_minchunk) + required = _malloc_minchunk; p0 -= HEADERWORDS; *** /tmp/,RCSt1a19196 Sat Jan 29 20:56:44 1994 --- testmalloc.c Sat Jan 29 20:55:24 1994 *************** *** 158,163 **** --- 158,174 ---- cp1 = (char *)realloc(cp1, (u_int) 32000); (void) memset(cp1, 'S', 32000); mal_heapdump(dumpfp); + cp1 = (char *)realloc(cp1, (u_int) 1); + (void) memset(cp1, 'U', 1); + cp2 = (char *)malloc(60000); + (void) memset(cp2, 'V', 60000); + cp3 = (char *)malloc(18000); + (void) memset(cp3, 'W', 18000); + cp4 = (char *)malloc(18000); + (void) memset(cp4, 'W', 18000); + mal_heapdump(dumpfp); + free(cp1); + mal_heapdump(dumpfp); mal_statsdump(dumpfp); (void) write(1, "Test done\n", 10); return 0;
Technical Details
Message-ID:
<CKFBC5.882@deshaw.com>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!deshaw.com!moraesReferences:
<AWB.94Jan18111511@as53.itl.atr.co.jp> <OZ.94Jan18150957@ursa.sis.yorku.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,82aeb50e0bd65249 X-Google-Attributes: gid11318c,public X-Google-Thread: 106b4a,7780ae9facc4121d X-Google-Attributes: gid106b4a,public X-Google-Thread: 1025b4,82aeb50e0bd65249 X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 1994-01-30 13:01:26 PST Newsgroups: gnu.misc.discuss,gnu.gcc.help,comp.sources.d Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!deshaw.com!moraes From: moraes@deshaw.com (Mark Moraes) Subject: Re: malloc and allocation errors Message-ID: <CKFBC5.882@deshaw.com> Sender: usenet@deshaw.com Nntp-Posting-Host: cs2 Organization: D. E. Shaw & Co. References: <AWB.94Jan18111511@as53.itl.atr.co.jp> <OZ.94Jan18150957@ursa.sis.yorku.ca> Date: Sun, 30 Jan 1994 03:36:05 GMT Lines: 71