AnsweredAssumed Answered

Floating Point sprintf Causes Bus Error

Question asked by Jerry Gardner on Feb 16, 2016
Latest reply on Nov 2, 2017 by Dave Nadler

I'm trying to use sprintf() to print floating point values to a string on a K64F in KDS 3.1 and the sprintf() call with %3.2f causes a bus error. The project is a Kinetis SDK 1.x project.


I have Float ABI set to Library (soft) and "Use float with nano printf" checked. As soon as the sprintf() executes, it causes a bus error in _dtoa_r, which is called from deep within the sprintf() library function. I traced the code and _dtoa_r calls malloc, which returns a null pointer, which _dtoa_r doesn't bother to check before using it. It's _dtoa_r's use of the null pointer that it gets back from malloc that causes the bus error.


What is the fix for this? I tried increasing the heap and the stack sizes to values that should be sufficient (32K and 16K respectively), but this didn't help.