From 6a107099d7de1801d8efe9f471529709ffdb3ea8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 31 Mar 1999 22:33:14 +0000 Subject: Patch from Chris Johns : joel@OARcorp.com wrote: > > Chris, > > sp09 fails on the rtems_port_delete(0) call. This is supposed to give an > invalid id error. I can't find any changes other than the unlimited > objects patch which would have tripped this so would appreciate it if you > could look into it. I suspect that this is a side-effect of the unlimited > objects patch. > It is me. > > Basically, there are 0 ports configured in sp09. The test ends up > dereferecing NULL in local_table[0] and comes up with a non-NULL invalid > pointer. > The issue is not actually allocating a local_table for an object type which has a maximum value of 0. I cannot remember the exact workings of the id values and the local_table. I might have changed the nature from the pre-unlimited change. As you know the id's are an interesting game where performance is most important. > > I know the problem could be solved by adding a check for index == 0. But > I hate to slow this path down. I think you may have changed the way the > object information structure gets initialized. > ---- CVS log ---- This change lets the unlimited and sp09 tests run on the posix Linux BSP. A static local variable `null_local_table' has been added. This variable is always set to NULL. The `**local_table' element of the information structure is set to point to this variable earily in the initialisation. If the object type has more than 0 elements the `local_table' element is updated. All object types which have 0 elements reference `null_local_table'. This change fixes the problem sp09 found yet does not add any extra processing to the critical `_Objects_Get_local_object' function. ---- CVS log ---- --- c/src/exec/score/src/object.c | 18 +++++++++++++----- cpukit/score/src/object.c | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/c/src/exec/score/src/object.c b/c/src/exec/score/src/object.c index cbbe889a79..dee86f5ba2 100644 --- a/c/src/exec/score/src/object.c +++ b/c/src/exec/score/src/object.c @@ -95,10 +95,10 @@ void _Objects_Extend_information( */ minimum_index = _Objects_Get_index( information->minimum_id ); - index_base = minimum_index; - block = 0; + index_base = minimum_index; + block = 0; - if (information->maximum < minimum_index) + if ( information->maximum < minimum_index ) block_count = 0; else { block_count = information->maximum / information->allocation_size; @@ -439,6 +439,8 @@ void _Objects_Initialize_information( boolean is_thread ) { + static Objects_Control *null_local_table = NULL; + unsigned32 minimum_index; unsigned32 index; unsigned32 name_length; @@ -471,7 +473,7 @@ void _Objects_Initialize_information( */ information->auto_extend = (maximum & OBJECTS_UNLIMITED_OBJECTS) ? TRUE : FALSE; - maximum &= ~OBJECTS_UNLIMITED_OBJECTS; + maximum &= ~OBJECTS_UNLIMITED_OBJECTS; /* * The allocation unit is the maximum value @@ -479,6 +481,12 @@ void _Objects_Initialize_information( information->allocation_size = maximum; + /* + * Provide a null local table entry for the case of any empty table. + */ + + information->local_table = &null_local_table; + /* * Calculate minimum and maximum Id's */ @@ -495,7 +503,7 @@ void _Objects_Initialize_information( name_length = maximum_name_length; - if (name_length & (OBJECTS_NAME_ALIGNMENT-1)) + if ( name_length & (OBJECTS_NAME_ALIGNMENT-1) ) name_length = (name_length + OBJECTS_NAME_ALIGNMENT) & ~(OBJECTS_NAME_ALIGNMENT-1); diff --git a/cpukit/score/src/object.c b/cpukit/score/src/object.c index cbbe889a79..dee86f5ba2 100644 --- a/cpukit/score/src/object.c +++ b/cpukit/score/src/object.c @@ -95,10 +95,10 @@ void _Objects_Extend_information( */ minimum_index = _Objects_Get_index( information->minimum_id ); - index_base = minimum_index; - block = 0; + index_base = minimum_index; + block = 0; - if (information->maximum < minimum_index) + if ( information->maximum < minimum_index ) block_count = 0; else { block_count = information->maximum / information->allocation_size; @@ -439,6 +439,8 @@ void _Objects_Initialize_information( boolean is_thread ) { + static Objects_Control *null_local_table = NULL; + unsigned32 minimum_index; unsigned32 index; unsigned32 name_length; @@ -471,7 +473,7 @@ void _Objects_Initialize_information( */ information->auto_extend = (maximum & OBJECTS_UNLIMITED_OBJECTS) ? TRUE : FALSE; - maximum &= ~OBJECTS_UNLIMITED_OBJECTS; + maximum &= ~OBJECTS_UNLIMITED_OBJECTS; /* * The allocation unit is the maximum value @@ -479,6 +481,12 @@ void _Objects_Initialize_information( information->allocation_size = maximum; + /* + * Provide a null local table entry for the case of any empty table. + */ + + information->local_table = &null_local_table; + /* * Calculate minimum and maximum Id's */ @@ -495,7 +503,7 @@ void _Objects_Initialize_information( name_length = maximum_name_length; - if (name_length & (OBJECTS_NAME_ALIGNMENT-1)) + if ( name_length & (OBJECTS_NAME_ALIGNMENT-1) ) name_length = (name_length + OBJECTS_NAME_ALIGNMENT) & ~(OBJECTS_NAME_ALIGNMENT-1); -- cgit v1.2.3