source: rtems/testsuites/libtests/malloc03/init.c @ de9b7d7

5
Last change on this file since de9b7d7 was de9b7d7, checked in by Sebastian Huber <sebastian.huber@…>, on 06/01/18 at 05:04:45

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.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15
16const char rtems_test_name[] = "MALLOC 3";
17
18static rtems_task Init(
19  rtems_task_argument argument
20)
21{
22  void *p1;
23
24  TEST_BEGIN();
25
26  p1 = __builtin_frame_address(0);
27  printf("Attempt to free stack memory\n");
28  free( p1 );
29}
30
31static void fatal_extension(
32  rtems_fatal_source source,
33  bool always_set_to_false,
34  rtems_fatal_code error
35)
36{
37  if (
38    source == RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE
39      && !always_set_to_false
40      && error != 0
41  ) {
42    TEST_END();
43  }
44}
45
46/* configuration information */
47
48#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
49#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
50
51#define CONFIGURE_MAXIMUM_TASKS             1
52
53#define CONFIGURE_INITIAL_EXTENSIONS \
54  { .fatal = fatal_extension }, \
55  RTEMS_TEST_INITIAL_EXTENSION
56
57#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
58
59#define CONFIGURE_INIT
60
61#include <rtems/confdefs.h>
62/* end of file */
Note: See TracBrowser for help on using the repository browser.