,Newlib-none C++ exceptions and thread safety

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

,Newlib-none C++ exceptions and thread safety

Contributor III


We’ve been using Freertos for 1 year for our embedded projects and we really love it.
A bit of context : our main target is a Cortex M33 (LPC55S69) which has plenty of flash and RAM.

We’ve started to port our C code base to C++ and we wonder if we can enable the C++ exceptions safely with the Freertos multithreaded environnement?

I asked Freertos forums guys about this and they told me it depends on the newlib implementation. So, by default, are newlib-none (not nano!) C++ exceptions thread-safe? I'm using heap_useNewlib from the great Dave Nadler.

After a few test, I have strange behaviors when several tasks runs in parallel, if I do throw / try / catch in them...

What do I need to do exactly to be able to use them safely in a multi threaded environnement?

Many thanks,


1 Reply

NXP TechSupport
NXP TechSupport

Hello Victor,

I confirmed with our experts that Newlib does feature thread safely by itself. You would need to work with FreeRTOS to allow the implementation to be thread safe.

They actually pointed to the implementation from Dave Nadler as reference. We do not have a FreeRTOS example with thread safety implemented.

My apologies for the inconvenience.


0 Kudos