[rtems commit] score: Add fatal errors for NULL entry init tasks

Sebastian Huber sebh at rtems.org
Fri Jan 8 08:02:36 UTC 2016


Module:    rtems
Branch:    master
Commit:    fe100e16117c36c40e99a853d09cd8dcf98dbff0
Changeset: http://git.rtems.org/rtems/commit/?id=fe100e16117c36c40e99a853d09cd8dcf98dbff0

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Dec 22 09:13:08 2015 +0100

score: Add fatal errors for NULL entry init tasks

This simplifies the global construction.

Update #2514.

---

 cpukit/posix/src/pthreadinitthreads.c                      |  9 ++++++++-
 cpukit/rtems/src/taskinitusers.c                           | 14 +++++++++++---
 cpukit/sapi/src/interrtext.c                               |  6 ++++--
 cpukit/score/include/rtems/score/interr.h                  |  4 +++-
 testsuites/psxtests/psxfatal01/testcase.h                  |  5 +++--
 testsuites/sptests/spfatal02/testcase.h                    |  7 ++++---
 testsuites/sptests/spinternalerror02/init.c                |  6 ++++--
 testsuites/sptests/spinternalerror02/spinternalerror02.scn |  5 ++++-
 8 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/cpukit/posix/src/pthreadinitthreads.c b/cpukit/posix/src/pthreadinitthreads.c
index 3379b79..7804c18 100644
--- a/cpukit/posix/src/pthreadinitthreads.c
+++ b/cpukit/posix/src/pthreadinitthreads.c
@@ -74,8 +74,15 @@ void _POSIX_Threads_Initialize_user_threads_body(void)
     _Assert( eno == 0 );
 
     thread_entry = user_threads[ index ].thread_entry;
+    if ( thread_entry == NULL ) {
+      _Terminate(
+        INTERNAL_ERROR_CORE,
+        false,
+        INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL
+      );
+    }
 
-    if ( register_global_construction && thread_entry != NULL ) {
+    if ( register_global_construction ) {
       register_global_construction = false;
       thread_entry = (void *(*)(void *)) _Thread_Global_construction;
     }
diff --git a/cpukit/rtems/src/taskinitusers.c b/cpukit/rtems/src/taskinitusers.c
index 490ddc7..46d0af3 100644
--- a/cpukit/rtems/src/taskinitusers.c
+++ b/cpukit/rtems/src/taskinitusers.c
@@ -24,6 +24,7 @@
 #include <rtems/rtems/support.h>
 #include <rtems/rtems/modes.h>
 #include <rtems/rtems/rtemsapi.h>
+#include <rtems/score/assert.h>
 #include <rtems/score/stack.h>
 #include <rtems/rtems/tasksimpl.h>
 #include <rtems/score/thread.h>
@@ -81,8 +82,15 @@ void _RTEMS_tasks_Initialize_user_tasks_body( void )
       _Terminate( INTERNAL_ERROR_RTEMS_API, true, return_value );
 
     entry_point = user_tasks[ index ].entry_point;
+    if ( entry_point == NULL ) {
+      _Terminate(
+        INTERNAL_ERROR_CORE,
+        false,
+        INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
+      );
+    }
 
-    if ( register_global_construction && entry_point != NULL ) {
+    if ( register_global_construction ) {
       register_global_construction = false;
       entry_point = (rtems_task_entry) _Thread_Global_construction;
     }
@@ -92,7 +100,7 @@ void _RTEMS_tasks_Initialize_user_tasks_body( void )
       entry_point,
       user_tasks[ index ].argument
     );
-    if ( !rtems_is_status_successful( return_value ) )
-      _Terminate( INTERNAL_ERROR_RTEMS_API, true, return_value );
+    _Assert( rtems_is_status_successful( return_value ) );
+    (void) return_value;
   }
 }
diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index 09bc215..3a0681d 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2012-2014 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012-2015 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -52,7 +52,9 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED",
   "INTERNAL_ERROR_NO_MEMORY_FOR_HEAP",
   "INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR",
-  "INTERNAL_ERROR_RESOURCE_IN_USE"
+  "INTERNAL_ERROR_RESOURCE_IN_USE",
+  "INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL",
+  "INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL"
 };
 
 const char *rtems_internal_error_text( rtems_fatal_code error )
diff --git a/cpukit/score/include/rtems/score/interr.h b/cpukit/score/include/rtems/score/interr.h
index f09d6e9..ea468e0 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -161,7 +161,9 @@ typedef enum {
   INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED,
   INTERNAL_ERROR_NO_MEMORY_FOR_HEAP,
   INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR,
-  INTERNAL_ERROR_RESOURCE_IN_USE
+  INTERNAL_ERROR_RESOURCE_IN_USE,
+  INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL,
+  INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL
 } Internal_errors_Core_list;
 
 typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/testsuites/psxtests/psxfatal01/testcase.h b/testsuites/psxtests/psxfatal01/testcase.h
index 2426e7b..b400fa6 100644
--- a/testsuites/psxtests/psxfatal01/testcase.h
+++ b/testsuites/psxtests/psxfatal01/testcase.h
@@ -27,9 +27,10 @@ posix_initialization_threads_table POSIX_Initialization_threads[] = {
 #define FATAL_ERROR_TEST_NAME            "1"
 #define FATAL_ERROR_DESCRIPTION \
         "POSIX API Init thread create failure - NULL entry"
-#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_POSIX_API
+#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_CORE
 #define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
-#define FATAL_ERROR_EXPECTED_ERROR       ((POSIX_FD_PTHREAD << 8) | EFAULT)
+#define FATAL_ERROR_EXPECTED_ERROR \
+  INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL
 
 void force_error(void)
 {
diff --git a/testsuites/sptests/spfatal02/testcase.h b/testsuites/sptests/spfatal02/testcase.h
index 9043701..bd9ac67 100644
--- a/testsuites/sptests/spfatal02/testcase.h
+++ b/testsuites/sptests/spfatal02/testcase.h
@@ -24,9 +24,10 @@ rtems_initialization_tasks_table Initialization_tasks[] = {
 
 #define FATAL_ERROR_TEST_NAME            "2"
 #define FATAL_ERROR_DESCRIPTION          "Classic API Init task start failure"
-#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_RTEMS_API
-#define FATAL_ERROR_EXPECTED_IS_INTERNAL TRUE
-#define FATAL_ERROR_EXPECTED_ERROR       RTEMS_INVALID_ADDRESS
+#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_CORE
+#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
+#define FATAL_ERROR_EXPECTED_ERROR \
+  INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
 
 void force_error()
 {
diff --git a/testsuites/sptests/spinternalerror02/init.c b/testsuites/sptests/spinternalerror02/init.c
index 5d1d26f..cbc81a5 100644
--- a/testsuites/sptests/spinternalerror02/init.c
+++ b/testsuites/sptests/spinternalerror02/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2012-2015 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Donierstr. 4
@@ -35,7 +35,9 @@ static void test_internal_error_text(void)
     puts( text );
   } while ( text != text_last );
 
-  rtems_test_assert( error - 3 == INTERNAL_ERROR_RESOURCE_IN_USE );
+  rtems_test_assert(
+    error - 3 == INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL
+  );
 }
 
 static void test_fatal_source_text(void)
diff --git a/testsuites/sptests/spinternalerror02/spinternalerror02.scn b/testsuites/sptests/spinternalerror02/spinternalerror02.scn
index 1159654..c6e85b1 100644
--- a/testsuites/sptests/spinternalerror02/spinternalerror02.scn
+++ b/testsuites/sptests/spinternalerror02/spinternalerror02.scn
@@ -1,4 +1,4 @@
-*** TEST SPINTERNALERROR 2 ***
+*** BEGIN OF TEST SPINTERNALERROR 2 ***
 INTERNAL_ERROR_NO_CONFIGURATION_TABLE
 INTERNAL_ERROR_NO_CPU_TABLE
 INTERNAL_ERROR_TOO_LITTLE_WORKSPACE
@@ -24,6 +24,9 @@ INTERNAL_ERROR_GXX_KEY_ADD_FAILED
 INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED
 INTERNAL_ERROR_NO_MEMORY_FOR_HEAP
 INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR
+INTERNAL_ERROR_RESOURCE_IN_USE
+INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
+INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL
 ?
 ?
 INTERNAL_ERROR_CORE




More information about the vc mailing list