Workspace Initialization Faliure Bug

Joel Sherrill joel at rtems.org
Thu Sep 30 22:38:25 UTC 2021


Hi

I need to produce a small test case but on the way to realizing the
IDLE task stacks needed to be allocated special, I tripped across a
problem where the computed workspace needed size was so low, it
tripped the second condition in the error check in
_Heap_Get_first_and_last_block:

 if (
    heap_area_end < heap_area_begin
      || heap_area_size <= overhead
      || first_block_size < min_block_size
  ) {
    /* Invalid area or area too small */
    return false;
  }

The computed _Workspace_Size is 8. which fails the second condition.

I ended up temporarily adding the += line in
_Workspace_Handler_initialization as a workaround

  overhead = _Heap_Area_overhead( page_size );
  overhead += _Heap_Min_block_size( page_size );

This was with ticker but with RTEMS thinking that all stacks came from
user controlled space and not the workspace.

I think this workaround is right in adding some to allow for the third
condition which is < min_block_size. But it might be better to have a
special case for an empty heap initialization case.

I think in this configuration, the workspace is essentially unneeded
but has to be able to be initialized. It shows that the static
allocation work has succeeded in trimming the workspace at least. But
now we have to account for an empty one. :)

Thoughts?

--joel


More information about the devel mailing list