rtel wrote on Friday, May 18, 2012:
Ideally there would be no limit on the length of a task’s name, and the TCB would just contain a pointer to the string. However, that is dangerous because it is assumed that the string is persistent in memory, and not in a temporary buffer or on the stack. Therefore the name is instead copied into an array using the following code:
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );
That should in theory prevent the array from overflowing, presuming strncpy() is implemented correctly. The line of code that follows then ensures the string is terminated correctly, in case the entire array was filled.
However, many C libraries that come with compilers require a large ROM footprint and huge stacks, so many FreeRTOS demos come with a cut down version of sprintf() that has limited functionality, but requires very little ROM or RAM. To ensure projects still link, the file that contains the sprintf() function also contains an snprintf() function, but it is not implemented correctly and just blindly calls sprintf(). If you project contains the file (third party) file named printf-stdarg.c, then this is most likely the cause of your problem.
This has been discussed a few times here, and I think, although it is a third party file, I need to do something about it for the next release.