summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/malloc03
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-01 07:04:45 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-05 08:49:56 +0200
commitde9b7d712bf5da6593386fd4fbca0d5f8b8431d8 (patch)
tree0f5716349a3a50243bd24f2cb9eaed280d88e3e8 /testsuites/libtests/malloc03
parentUpdate rtems_fatal_source_text() (diff)
downloadrtems-de9b7d712bf5da6593386fd4fbca0d5f8b8431d8.tar.bz2
Add RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE
An invalid heap usage such as a double free is usually a fatal error since this indicates a use after free. Replace the use of printk() in free() with a fatal error. Update #3437.
Diffstat (limited to 'testsuites/libtests/malloc03')
-rw-r--r--testsuites/libtests/malloc03/init.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/testsuites/libtests/malloc03/init.c b/testsuites/libtests/malloc03/init.c
index 9e2b04d2a0..89c147b1b6 100644
--- a/testsuites/libtests/malloc03/init.c
+++ b/testsuites/libtests/malloc03/init.c
@@ -12,14 +12,10 @@
#endif
#include <tmacros.h>
-#include "test_support.h"
const char rtems_test_name[] = "MALLOC 3";
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
+static rtems_task Init(
rtems_task_argument argument
)
{
@@ -30,10 +26,21 @@ rtems_task Init(
p1 = __builtin_frame_address(0);
printf("Attempt to free stack memory\n");
free( p1 );
+}
- TEST_END();
-
- rtems_test_exit(0);
+static void fatal_extension(
+ rtems_fatal_source source,
+ bool always_set_to_false,
+ rtems_fatal_code error
+)
+{
+ if (
+ source == RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE
+ && !always_set_to_false
+ && error != 0
+ ) {
+ TEST_END();
+ }
}
/* configuration information */
@@ -42,7 +49,10 @@ rtems_task Init(
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
-#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_INITIAL_EXTENSIONS \
+ { .fatal = fatal_extension }, \
+ RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE