STM32 gotchas
65.Standard C library function (e.g. printf()) fails in interrupt or RTOS (not STM32 specific)

It is not a widely known fact, that standard C library functions are not reentrant (C99 7.1.4#4). It means, among other things, that they cannot be used both in main() and in interrupts, simultaneously. It also means, that if some form of multitasking (usually called RTOS in the realm of microcontrollers) is used, the same library function cannot be used in several processes/tasks/threads simultaneously.

Although this is a generic issue, it usually does not exhibit itself for most of the standard library functions. Compilers/libraries authors recognize the importance of reentrancy and usually give explicit guarantee for reentrancy at least for the math part of the library; and also provide clues or methods to make also rest of the library reentrant. This information of course toolchain dependent, i.e. non-portable, and it has to be looked up in the documentation accompanying the toolchain.

printf() and its family is an extremely complex function, if it attempts to implement all the features imposed by the standard, and its newlib implementation uses some form of dynamic memory allocation, which represents the non-reentrant element. While newlib does implement some techniques to ensure reentrancy, these require close attention, they are dependent on the environment where the library is used, and are not always properly implemented or utilized. This resulted in issue reported on the STM32 forum, with this printf() implementation failing when printing floating-point numbers in FreeRTOS environment.