From owner-freebsd-alpha Sat Jan 18 0: 1:14 2003 Delivered-To: freebsd-alpha@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38B4F37B401; Sat, 18 Jan 2003 00:01:13 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6612943F18; Sat, 18 Jan 2003 00:01:12 -0800 (PST) (envelope-from phk@freebsd.org) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id h0I80dK1018382; Sat, 18 Jan 2003 09:00:45 +0100 (CET) (envelope-from phk@freebsd.org) To: Kris Kennaway Cc: current@freebsd.org, alpha@freebsd.org Subject: Re: panic: malloc(M_WAITOK) returned NULL From: phk@freebsd.org In-Reply-To: Your message of "Fri, 17 Jan 2003 20:53:16 PST." <20030118045316.GA25224@rot13.obsecurity.org> Date: Sat, 18 Jan 2003 09:00:39 +0100 Message-ID: <18381.1042876839@critter.freebsd.dk> Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In message <20030118045316.GA25224@rot13.obsecurity.org>, Kris Kennaway writes: >I just got the following on axp1: > >panic: malloc(M_WAITOK) returned NULL >db_print_backtrace() at db_print_backtrace+0x18 >panic() at panic+0x104 >malloc() at malloc+0x1a8 >initiate_write_inodeblock_ufs1() at initiate_write_inodeblock_ufs1+0xc4 >softdep_disk_io_initiation() at softdep_disk_io_initiation+0xa4 >spec_strategy() at spec_strategy+0x158 >spec_vnoperate() at spec_vnoperate+0x2c This is a bug in the kernel memory allocator, since it should not be able to return NULL when M_WAITOK is specified. The potential bugs are more likely because M_WAITOK is defined as zero. M_WAITOK Indicates that it is Ok to wait for resources. It is unconve- niently defined as 0 so care should be taken never to compare against this value directly or try to AND it as a flag. The default operation is to block until the memory allocation suc- ceeds. malloc(), realloc(), and reallocf() can only return NULL if M_NOWAIT is specified. void * malloc(size, type, flags) unsigned long size; struct malloc_type *type; int flags; { [...] if (!(flags & M_NOWAIT)) KASSERT(va != NULL, ("malloc(M_WAITOK) returned NULL")); [...] } -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message