esp_execute_shared_stack_function thread safety

jdoubleu
Posts: 8
Joined: Wed Sep 29, 2021 3:58 pm

esp_execute_shared_stack_function thread safety

Postby jdoubleu » Wed Feb 08, 2023 3:52 pm

I was wondering whether I could call esp_execute_shared_stack_function from multiple tasks. Looking at the implementation, the function doesn't seem to be thread safe. Mainly because it uses global static variables (e.g. xtensa_shared_stack_callback). Although I have to pass a mutex, this is only used to guard access to the stack memory also provided.

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: esp_execute_shared_stack_function thread safety

Postby ESP_Sprite » Thu Feb 09, 2023 12:39 am

Yeah, that looks like a bug, good catch. I'll file an internal issue.

jdoubleu
Posts: 8
Joined: Wed Sep 29, 2021 3:58 pm

Re: esp_execute_shared_stack_function thread safety

Postby jdoubleu » Thu Feb 09, 2023 6:17 pm

Thanks for the quick reply!

Please note the open issue on GitHub, which is also affected by the function, but not related to my issue: https://github.com/espressif/esp-idf/issues/10414.

While I'm at it: it would be really nice if I could pass void* arg to esp_execute_shared_stack_function, so that my callback receives the void* arg when called on the external stack.

Who is online

Users browsing this forum: No registered users and 123 guests