Perhaps this might shed some light on the error message that you're getting?
Perhaps there is some erroneous data being passed to `printf()` that triggers the error in some lower level standard library or system call?
You should probably try debugging your code to identify what's going wrong. Spike instruction execution tracing might also help.
If that still doesn't help then creating a minimal, self-contained, reproducible test case that others can easily use to reproduce the problem might be a good idea.