AnsweredAssumed Answered

Odd new() exception - K22F KDS

Question asked by Tharon Hall on Jun 26, 2015
Latest reply on Jul 2, 2015 by Carlos_Mendoza

I am getting a rather odd __cxa_throw() exception using operator new() using KDS and a K22F. I saw, odd, because it happens on only maybe the second invocation of new(), and there is PLENTY of room on the heap.


Using the representative code below:


class_ptr1 = new Class("Class 1");

class_ptr2 = new Class("Class 2");


class_ptr1 is assigned the address 0x20000020


When the attempt to allocate the second class fires, I get the __cxa_throw() exception. Of course, this would typically mean I am out of memory, but I have TONS of space left in the heap, unless i am reading this wrong somehow and the space is allocated top to bottom and not bottom to top:


.heap           0x20000000     0x8000

                0x20000000                . = ALIGN (0x8)

                0x20000000                __end__ = .

                0x20000000                PROVIDE (end, .)

                0x20000000                __HeapBase = .

                0x20008000                . = (. + HEAP_SIZE)


Anyone else seen this? This triggered after I changed my OSA from Bare Metal to FreeRTOS, so something funny may have happened there.


This has stopped me in my tracks, so any help GREATLY appreciated. Thanks!