[uClinux-dev] test program doesn't crash

Hornung Peter peter_hornung at siemens.com
Fri Mar 21 08:57:08 EST 2003


Hi,

I'm using the current uClinux distribution (20030305) and the current
arm-elf-tools (20030314). My target system is configured as an Atmel AT91.
When I try to run a little test program which is supposed to crash in the
Armulator, the program actually doesn't crash und doesn't show any calls to
the signal handler.

Does anybody have an idea what is wrong?

This is the program:

#include <stdio.h>
#include <signal.h>

void fpeHandler (int signum)
{
	printf ("FLOATING POINT EXCEPTION\n");
	exit (1);
}

int main (int argc, char *argv[])
{
	int a;
	int b;
	int c;
	int * pb = &b;

	struct sigaction sa;
	memset (&sa, 0, sizeof (sa));
	sa.sa_handler = fpeHandler;
	if (sigaction (SIGFPE, &sa, NULL))
		perror ("sigaction");
		
	printf ("division a / b\n");
	printf ("a\n");
	scanf ("%d", &a);
	printf ("b\n");
	scanf ("%d", pb);
	printf ("division %d / %d = ... \n", a, b);
	c = a / b;	// crash here if b = 0
	printf ("... %d\n", c);
	pb = NULL;
	printf ("NULL pointer division %d / %d = ... \n", a, *pb);	//
crash here because of NULL pointer
	c = a / *pb;	// crash here because of NULL pointer and if b = 0
	printf ("... %d\n", c);
	printf ("this is a test!\n");
	return 0;
}


This is the output:

Sash command shell (version 1.1.1)
/> crashtest
crashtest
division a / b
a
99
b
0
division 99 / 0 = ... 
... 0
NULL pointer division 99 / -274792448 = ... 
... 0
this is a test!
/>


Thank you!
Peter Hornung




More information about the uClinux-dev mailing list