Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Jan 2003 09:00:39 +0100
From:      phk@freebsd.org
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        current@freebsd.org, alpha@freebsd.org
Subject:   Re: panic: malloc(M_WAITOK) returned NULL 
Message-ID:  <18381.1042876839@critter.freebsd.dk>
In-Reply-To: Your message of "Fri, 17 Jan 2003 20:53:16 PST." <20030118045316.GA25224@rot13.obsecurity.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?18381.1042876839>