Are printf()s allowed within xTimer callbacks?

I understand that blocking functions are not permitted within an xTimer callback.

Short form:

Is printf() considered a blocking function?

Details:

I’m observing a case where I’m getting an illegal memory reference within uxListRemove(), following an xTimer callback and a printf(). Specifically, the pxItemToRemove->pxNext = 0x1, which is clearly not a valid pointer.

When I removed the call to printf(), I do not get the illegal memory reference.

As far as I can tell from the sources I inherited, we’re running FreeRTOS V9.0.0. Let me know if additional info is needed.

The point the removing the call to printf makes the crash go away indicates towards a memory corruption/stack overflow. Have you enabled stack overflow detection? You can also try to increase the timer task stack size.

Thanks.

Many thanks. Will enable stack overflow detection and will report back.

@aggarg Thank you for the suggestions, but no luck: I’ve added:

void vApplicationStackOverflowHook( TaskHandle_t xTask,
                                signed char *pcTaskName ) {
  (void)xTask;
  (void)pcTaskName;
  __asm("nop");
}

to my code, placed a breakpoint on the nop and set configCHECK_FOR_STACK_OVERFLOW to 1 (and tried 2 as well), but it still bombs out with an illegal reference.

Question: since I can identify the place in the code that gets the illegal access, is there a FreeRTOS call I can insert there that will validate the state of the stack?

UPDATE:

Increasing TIMER_TASK_STACK_SIZE from 100 to 200 did the trick. So I believe your analysis was correct: it’s overflowing the stack, probably because the standard printf() makes heavy use of the stack.