Throw ends in abort on new blank frdm22f project (+ malloc/new )

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Throw ends in abort on new blank frdm22f project (+ malloc/new )

Jump to solution
2,286 Views
markusklemm
Contributor II

Problem: 
`try{throw 4;} catch(...){}` ends in std::terminate()->_exit() on a new created frdmk22f project. Even if an own malloc and new is implemented (which is used even for `throw 4;` for about 130 bytes BTW). Yes, the "noexceptions" optimizer check box is NOT checked. 

 

I also uploaded the minimal example on github: GitHub - Superlokkus/minimal_kinetis_throw_example 

 

So what do I have to do, to use C++ exceptions? Shouldn't this be documented anywhere if exceptions are not supported out of the box?!

 

This is a minimized example of my similar problem using c++ exceptions with freertos 


Kinetis Design Sutdio 3.2.0

KSDK 1.3.0
FRDM-K22F Rev:A1

(GNU Tools for ARM Embedded Processors) 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147]

Labels (1)
1 Solution
1,593 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Markus,

There is a simple demo about use try() catch()  , you can copy the application code

into a new K22 project to have a try.

How to use " try catch() " of C++ on KDS 3.0 

Please pay attention that remove --specs=nano.specs from the linker options,

because newlib-nano have exception handling disabled .

pastedImage_2.png

BR

Alice

View solution in original post

6 Replies
1,593 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Markus,

Does these linker can helps?

Exceptions - C++ Tutorials 

exception - C++ Reference 

They introduce the Standard exceptions.

BR

Alice

0 Kudos
1,593 Views
superlokkus
Contributor I

Hello Alice_Yang,

this question is around the problem that the implementation NXP gives us, seems to be not able to catch any exceptions, not that I'm new to exceptions or don't know to use them, so I'm sorry no, the the top google links you throw at me, doesn't help me. It's also not relevant if the object thrown is inherited from std::exception since catch(...) is supposed to catch anything. Besides, the implementation also shows the same behavior to them.

Have nice holidays 

Markus Klemm

0 Kudos
1,594 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Markus,

There is a simple demo about use try() catch()  , you can copy the application code

into a new K22 project to have a try.

How to use " try catch() " of C++ on KDS 3.0 

Please pay attention that remove --specs=nano.specs from the linker options,

because newlib-nano have exception handling disabled .

pastedImage_2.png

BR

Alice

1,593 Views
superlokkus
Contributor I

Thank you Alice_Yang I quite sure this is the solution.

But I must say I am pissed towards NXP:

Please pay attention that remove --specs=nano.specs from the linker options,

because newlib-nano have exception handling disabled

how was I supposed to know, I never read this in the documentation from nxp anywhere, which of course says something like "Here is our C++11 implementation for our MCUs" but should be corrected to "Here is our somehow C++11 implementation which differs from the standard somehow, but we don't say you where and how, happy debugging!"

As always have nice holidays Alice

Markus

0 Kudos
1,593 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Markus,

I understand your mood , sorry for the inconvenient to you.

As you know the KDS use the GUN ARM Embedded Toolchain,

it includes many lib. And we may use many functions when development

proeject on KDS,  so it hard to introduce all of that on User Guide.

So we can only check the we use which lib , then find what about the lib.

Or of course we are glad to you ask NXP support .

You can also search your problem on community , maybe someone else have

the same question , and have got the answer . If not , please contact us without

any hesitate.

I think you are in Christmas,  While in my country , we don't have holidays at Christmas.

Happy holidays !

Alice

0 Kudos
1,593 Views
markusklemm
Contributor II

Today I was able to check on our boards, and it actually fixed the problem! Thanks again Alice_Yang a million times.

Of course I can relate to your position, often as a user you have to be aware of the gcc toolchain. But since the toolchain also comes in many flavors and has so much compilation and linking options, it's very hard to see all that in the complex kinetis product. So I would propose, that even an intermediate programmer would understand a "This is a C++11 solution, with compliance exceptions found in chapter x". 

0 Kudos