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.
This commit is contained in:
Sebastian Huber
2018-06-01 07:04:45 +02:00
parent c934365f23
commit de9b7d712b
11 changed files with 88 additions and 17 deletions

View File

@@ -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