From owner-freebsd-hackers Thu Feb 8 12:38:59 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by hub.freebsd.org (Postfix) with ESMTP id 49ACB37B6C5; Thu, 8 Feb 2001 12:38:40 -0800 (PST) Received: from curve.dellroad.org (curve.dellroad.org [10.1.1.30]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id MAA62242; Thu, 8 Feb 2001 12:38:39 -0800 (PST) Received: (from archie@localhost) by curve.dellroad.org (8.9.3/8.9.3) id MAA56927; Thu, 8 Feb 2001 12:38:39 -0800 (PST) (envelope-from archie) From: Archie Cobbs Message-Id: <200102082038.MAA56927@curve.dellroad.org> Subject: new /etc/malloc.conf option To: freebsd-hackers@freebsd.org, phk@freebsd.org Date: Thu, 8 Feb 2001 12:38:38 -0800 (PST) X-Mailer: ELM [version 2.4ME+ PL77 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Here's an idea for a new /etc/malloc.conf option to help with debugging... I'm interested in what other people think. The option would have the effect of setting a "failure probability" P between 0.0 and 1.0 such that any malloc()/realloc() operation would fail with probability P. Sometimes I've implemented this kind of thing manually to test code robustness and it's been very helpful in catching obscure bugs. You can't do this with a single letter, but maybe we could do something like this using a number between 0..100: $ ln -s F5AJ /etc/malloc.conf Then in the malloc code read out the 'F5' at startup and set failure_prob to 5%... static u_int failure_prob; /* a number between 0 and 100 */ void * malloc(size_t len) { u_int failure_index; if (failure_prob != 0 && (random() % 100) < failure_prob) { errno = ENOMEM; return (NULL) } } This would then give you a 1% failure probability. By using random(), the exact failure can be reproduced by the application by setting the same seed with srandom(). We might want to use a more precise range, e.g., 0..1000000 instead of 0..100. -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message