[uClinux-dev] test program doesn't crash

Greg Ungerer gerg at snapgear.com
Fri Mar 21 10:27:00 EST 2003


Hi Peter,

Hornung Peter wrote:
> 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?
[snip]
> 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");

You don't use any "float" variable types, I would not expect
you to get a Floating Point Exception signal in this code...


> 	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

If you where on a system that had full virtual memory then this
would crash. When you are running with no MMU there is not
neccessarily any way for the kernel/system to detect that you are
accessing a NULL pointer.

Without an MMU applications can access any memory regions they
want, kernel, other processes, peripherals, whatever. Some
processes will pick up accesses to regions that are not actually
defined for use (ie not RAM, flash, etc), many will happily
driver the address onto the bus and read back garbage. That is
life without an MMU.

Regards
Greg



------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Wizard        EMAIL:  gerg at snapgear.com
Snapgear Pty Ltd                               PHONE:    +61 7 3279 1822
825 Stanley St,                                  FAX:    +61 7 3279 1820
Woolloongabba, QLD, 4102, Australia              WEB:   www.SnapGear.com




More information about the uClinux-dev mailing list