app2.c

来自「pebble」· C语言 代码 · 共 53 行

C
53
字号
/* 
 * Copyright 1999, 2000, 2001, 2002 Lucent Technologies Inc.
 * All Rights Reserved.
 * Information Sciences Research Center, Bell Labs.
 *
 * LUCENT TECHNOLOGIES DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE 
 * OR THE SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The
 * software is provided "as is" without expressed or implied warranty 
 * of any kind.
 *
 * These notices must be retained in any copies of any part of this
 * software.
 *
 */

/*
 * test stack overflow
 */
#include "pebble.h"

#define	N	100

static char *tos;

void
f(int i)
{
	char x[N];

	printf("call depth=%d: stack at %p size so far=%d\n",
		i, x, tos - x);
	f(i+1);
}


int
main(void)
{
	char x;

	printf("testing Pebble stack overflow\n");
	printf("THIS PROGRAM SHOULD TERMINATE WITH A STACK OVERFLOW MESSAGE\n");
	tos = (char *)&x;

	/* infinite recursion */
	f(1);

	printf("should never reach here!\n");
	task_exit(0);

	return 0;	/* to make gcc happy */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?