[Prev][Next][Index][Thread]

Re: asserts in lmm/lmm_avail.c



> Date: Mon, 04 Jan 1999 17:07:26 -0600
> From: Mike Ashley <jashley@eecs.ukans.edu>
> To: oskit users <oskit-users@cs.utah.edu>
> Subject: asserts in lmm/lmm_avail.c
> 
> There are two suspicious lines in lmm_avail.c:
> 
>                 assert((oskit_addr_t)reg->nodes >= reg->min);
>                 assert((oskit_addr_t)reg->nodes < reg->max);
> 
> I think both should be eliminated.  The first is just wrong.  If there
> are no nodes associated with the region, e.g., they've all been
> allocated, then this assert will fail.  I suppose the second assert is
> correct, but it seems like overly-aggresive sanity checking since
> lmm_avail does not reference any nodes of any region.
> 
> We've commented them out locally since we tripped on the first assert
> after allocating all the nodes in a region.
> 
> Mike
> 

The first one is indeed wrong and should be:

	assert((reg->nodes == 0 && reg->free == 0)
		|| (oskit_addr_t)reg->nodes >= reg->min);

as is done elsewhere in the LMM code.  The asserts are in there as quick
(though aproximate) validity checks on region objects to make sure the
lmm->regions list hasn't been corrupted.  However, the checks are different
in the various places where the regions list is scanned.  So I defined a
macro in lmm.h to check a reasonable set of fields and went through and
changed the LMM code to use it.  This will be in the next release.

(I know the phrase "next release" sends a chill down the spine of anyone
who has been following the OSKit, but it will be out soon...really! :-)