AW: [uClinux-dev] test program doesn't crash

Hornung Peter peter_hornung at siemens.com
Mon Mar 24 06:56:17 EST 2003


Hi,

the NULL pointer expalnation sounds logical.

However a division by 0 should crash the program - with or without calling
the signal handler! Instead I get the result 0 and the program keeps
running.

Peter

-----Ursprüngliche Nachricht-----
Von: Greg Ungerer [mailto:gerg at snapgear.com]
Gesendet: Freitag, 21. März 2003 16:27
An: uclinux-dev at uclinux.org
Betreff: Re: [uClinux-dev] test program doesn't crash


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

_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org



More information about the uClinux-dev mailing list