source: rtems/testsuites/libtests/stackchk02/init.c @ b539af8

Last change on this file since b539af8 was b539af8, checked in by Kinsey Moore <kinsey.moore@…>, on 01/26/22 at 22:00:04

cpukit: Prevent error with disabled stack checker

When the stack checker is not enabled, the stack checker reporting
function can still be called. This prevents that call from performing a
null memory access in trying to find the high water mark if the stack
checker was never initialized.

This also introduces a test to ensure this call does not cause a crash.

Closes #4588

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup libtests
7 */
8
9/*
10 * Copyright (C) 2022 On-Line Applications Research Corporation (OAR)
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifdef HAVE_CONFIG_H
35#include "config.h"
36#endif
37
38#define CONFIGURE_INIT
39
40#include <tmacros.h>
41
42#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
43#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
44
45#define TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE*3)
46
47#define CONFIGURE_MAXIMUM_TASKS               1
48
49#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
50
51#include <rtems/confdefs.h>
52
53#include <rtems/stackchk.h>
54
55const char rtems_test_name[] = "STACKCHK02";
56
57rtems_task Init(
58  rtems_task_argument argument
59)
60{
61  TEST_BEGIN();
62
63  rtems_stack_checker_report_usage();
64
65  TEST_END();
66  rtems_test_exit( 0 );
67}
Note: See TracBrowser for help on using the repository browser.