Possible Bad _HAssert in cpukit/score/src/heapgetinformation.c ?
Phillip Sorensen
pas37 at cornell.edu
Tue Oct 2 20:10:13 UTC 2007
Hello All,
I am have problems with an assertion in the heap code when I compile
against RTEMS built with --enable=debug. I am trying to get both the
free space and the allocated space from the malloc heap using the
rtems_region_get_information command. This is the code:
long rtems_mem_get(double *total, double *used, double *free)
{
region_information_block heap;
if(!rtems_region_get_information(RTEMS_Malloc_Heap, &heap)) {
*used = (double)heap.Used.total / (1024 * 1024);
*free = (double)heap.Free.total / (1024 * 1024);
*total = *used + *free;
return 0;
} else {
*total = 0;
*used = 0;
*free = 0;
return -1;
}
}
When I run the code I get an assertion from the code
cpukit/score/src/heap.c. The first _HAssert call in
_Heap_Get_information() causes the assertion.
Heap_Get_information_status _Heap_Get_information(
Heap_Control *the_heap,
Heap_Information_block *the_info
)
{
Heap_Block *the_block = the_heap->start;
Heap_Block *const end = the_heap->final;
_HAssert(the_block->prev_size == HEAP_PREV_USED);
If I check with a debugger the_block->prev_size is always 4.
If I compile RTEMS without --rtems-debug (which makes the _HAssert code
due nothing), the code runs as it should. Is this a bug in the
_HAssert's, or am I lucky that my code runs.
I can work around this by using RTEMS compiled without --rtems-debug,
but I would prefer to have the asserts and other debugging code active
for development.
Phil Sorensen
CHESS
More information about the users
mailing list