John Kemp
/
memory_test
Demonstrates crash on memory allocation.
Diff: main.cpp
- Revision:
- 0:786b75c6aaca
- Child:
- 1:883b8bc1f54a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 29 13:42:16 2011 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" + + +Serial pc(USBTX, USBRX); + +extern "C" void HardFault_Handler() +{ + pc.printf("Hard fault!\r\n"); + exit(1); +} + + +void fail() +{ + pc.printf("Caught the failure\r\n"); + exit(1); +} + + +class Test +{ + public: + int something; + char woot[28]; +}; + + +int main() { + Test *dummy; + int index = 0; + + while(1) { + dummy = new Test; + if (dummy == NULL) fail(); + pc.printf("%u\r\n", index); + ++index; + } +}