On Nov 10, 2007, at 9:07 PM, Jeongyeup Paek wrote:


Maybe there is a misunderstanding...

If you write a code that has segmentation fault,
then the mote will restart.
And I don't think this 'behavior' is a bug
since it is the only thing it can do.

To be more precise, there is no such thing as a "segmentation fault" in TinyOS; a segfault is when a program accesses a memory address for which there is no valid virtual memory segment, and so no valid virtual->physical address mapping. In UNIX/Windows/etc., typically the OS does not allow you to define a segment that covers the first page of the address space, so that null pointers always segfault.

When you have no virtual memory (read: microcontrollers), this becomes a bit trickier. It turns out that the low physical addresses are memory mapped registers. So if you dereference a null pointer, you end up accessing things like the register that controls whether interrupts are enabled or not. This can sometimes appear as a reset.

Another thing that can cause a reset is if you have a stack overflow. It turns out that the reset vector is sometimes at code address 0. So if you have an array on the stack of size X and write X+Y 0x00 bytes, if Y is big enough, you will overwrite the return address to be 0.

This second case appeared on micaz nodes pre 2.0.2; the way the SPI bus was implemented, if you send a packet of length 0 it would send a packet of length 65535. This is a pretty bad bug: writing 65535 bytes of value 0x00 would blow away the heap and stack, causing the return address on the stack to be 0x0000 and... a reset. It turned out that this was caused by corrupted 802.15.4 packets whose PHY length byte was 0; this is clearly a nad length, but the code never considered it might happen, so it triggered the SPI bug.

It's stuff like this that has made core start leaning towards default- on but disableable Deputy support.

Phil
_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to