Skip to content

uxTaskGetTaskNumber returns 0 due to incorrect TCB handle conversion in ESP-IDF FreeRTOS port (IDFGH-16930) #17991

@tanakamasayuki

Description

@tanakamasayuki

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.5-8410210c-v2

Espressif SoC revision.

ESP32-D0WD-V3 (revision v3.1)

Operating System used.

Windows

How did you build your project?

Other (please specify in More Information)

If you are using Windows, please specify command line type.

None

Development Kit.

Freenove ESP32

Power Supply used.

USB

What is the expected behavior?

0 is returned, but I want to get the correct value.

Code

void setup() {
  Serial.begin(115200);
}

void loop() {
  TaskHandle_t h = xTaskGetCurrentTaskHandle();
  printf("name=%s\n", pcTaskGetName(h));

  UBaseType_t taskNumber = uxTaskGetTaskNumber(h);
  printf("taskNumber=%u\n", taskNumber);

  TaskStatus_t info = {};
  vTaskGetInfo(h, &info, pdTRUE, eInvalid);
  printf("info.name=%s\n", info.pcTaskName ? info.pcTaskName : "(null)");
  printf("info.taskNumber=%u\n", info.xTaskNumber);

  delay(1000);
}

Output

name=loopTask
taskNumber=0
info.name=loopTask
info.taskNumber=8

The result of uxTaskGetTaskNumber is strange.

What is the actual behavior?

I want the same number as vTaskGetInfo to be returned.

name=loopTask
taskNumber=8
info.name=loopTask
info.taskNumber=8

Steps to reproduce.

Code

void setup() {
  Serial.begin(115200);
}

void loop() {
  TaskHandle_t h = xTaskGetCurrentTaskHandle();
  printf("name=%s\n", pcTaskGetName(h));

  UBaseType_t taskNumber = uxTaskGetTaskNumber(h);
  printf("taskNumber=%u\n", taskNumber);

  TaskStatus_t info = {};
  vTaskGetInfo(h, &info, pdTRUE, eInvalid);
  printf("info.name=%s\n", info.pcTaskName ? info.pcTaskName : "(null)");
  printf("info.taskNumber=%u\n", info.xTaskNumber);

  delay(1000);
}

Debug Logs.


Diagnostic report archive.

No response

More Information.

xTaskGetCurrentTaskHandle

vTaskGetInfo

pxTCB = prvGetTCBFromHandle( xTask );

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions