Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

configMAX_TASK_NAME_LEN = 1: bug or feature?

Posted by https://www.google.com/accounts on May 31, 2012
Hi,

This macro lets you set the len of the task's name, but if you don't want to use task names in your project (due to limited resources mainly), then you might set it to 1 (in order to include a least the null string terminator). However this approach is not true at all, 'cause if you check the Idle task it already has the name "Idle" and it is fixed!! (five chars). Under this escenario your TCBs are going to crash sooner or later because they aren't allowing space for more than a one character, so critical data in the TCB will be overwritten.

There are two obvious workarounds:

1.- configMAX_TASK_NAME_LEN >5 or
2.- Hack the Idle task creation in order to change "Idle" to ""

None of them convince me so my question is: is it a bug or feature?

Thank you!!

RE: configMAX_TASK_NAME_LEN = 1: bug or feature?

Posted by MEdwards on May 31, 2012
Sorry - but everything in your post is inaccurate.

Look at the copy that copies the task name into the TCP;

#if configMAX_TASK_NAME_LEN > 1
{
/* Don't bring strncpy into the build unnecessarily. */
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );
}
#endif
pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = ( signed char ) '\0';


configMAX_TASK_NAME_LEN must be at least 1 to fit the NULL, like you say. If it is greater than 1 then only the first configMAX_TASK_NAME_LEN characters are copied in. There is, of course, no buffer overflow, no matter how long the task name is.

RE: configMAX_TASK_NAME_LEN = 1: bug or feature?

Posted by MEdwards on May 31, 2012
"code that copies", not copy that copies. Hopefully the pasted code will display better in this post.

#if configMAX_TASK_NAME_LEN > 1
{
/* Don't bring strncpy into the build unnecessarily. */
strncpy( pxTCB->pcTaskName, pcName, configMAX_TASK_NAME_LEN );
}
#endif
pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';

RE: configMAX_TASK_NAME_LEN = 1: bug or feature?

Posted by https://www.google.com/accounts on May 31, 2012
Edward, you're totally right, and I was totally wrong. Cscope shows 10 entries for configMAX_TASK_NAME_LEN, so I didn't know where to start, but now was easier once you pointed it out. Thank you!!


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists