FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2012 Threads] 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!!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|