Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp_intr_free(): core could change after call to esp_cpu_get_core_id() (IDFGH-11480) #12608

Closed
3 tasks done
gralpli opened this issue Nov 17, 2023 · 3 comments
Closed
3 tasks done
Assignees
Labels
Status: In Progress Work is in progress

Comments

@gralpli
Copy link

gralpli commented Nov 17, 2023

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.

General issue report

The function esp_intr_free() in components/esp_hw_support/intr_alloc.c on line 703 does this:

//Assign this routine to the core where this interrupt is allocated on.
if (handle->vector_desc->cpu != esp_cpu_get_core_id()) {
    esp_err_t ret = esp_ipc_call_blocking(handle->vector_desc->cpu, &esp_intr_free_cb, (void *)handle);
    return ret == ESP_OK ? ESP_OK : ESP_FAIL;
}

If this routine is run on a task that has no core affinity, the scheduler could move it to the other core after esp_cpu_get_core_id() got called. The call to esp_ipc_call_blocking() should therefore be made unconditionally, but at least in all cases in which the current task has no affinity.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 17, 2023
@github-actions github-actions bot changed the title esp_intr_free(): core could change after call to esp_cpu_get_core_id() esp_intr_free(): core could change after call to esp_cpu_get_core_id() (IDFGH-11480) Nov 17, 2023
@ESP-Marius
Copy link
Collaborator

Thanks for reporting this, this indeed seems like a potential issue.

We'll investigate it.

@KonstantinKondrashov
Copy link
Collaborator

Hi @gralpli!
Thanks for reporting it. I created a fix for it. I am wondering how this issue affects the system. Did you get an error message?
This would be useful to share an error log (or incorrect behavior that you observed) for people who encounter the same problem.

@gralpli
Copy link
Author

gralpli commented Nov 22, 2023

I did not get an error message, I spotted it by reading the source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Work is in progress
Projects
None yet
Development

No branches or pull requests

4 participants