www.pudn.com > pebble.zip > app2.c


/*  
 * 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 */ 
}