Demonstrates crash on memory allocation.
main.cpp
- Committer:
- Kemp
- Date:
- 2011-03-29
- Revision:
- 1:883b8bc1f54a
- Parent:
- 0:786b75c6aaca
File content as of revision 1:883b8bc1f54a:
#include "mbed.h"
Serial pc(USBTX, USBRX);
BusOut leds(LED1, LED2, LED3, LED4);
extern "C" void HardFault_Handler()
{
pc.printf("Hard fault!\r\n");
while(1) {
leds = 0x09;
wait(0.4);
leds = 0x06;
wait(0.4);
}
}
void fail()
{
pc.printf("Caught the failure\r\n");
while(1) {
leds = 0x09;
wait(0.4);
leds = 0x06;
wait(0.4);
}
}
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;
}
}