esp_execute_shared_stack_function thread safety
Posted: Wed Feb 08, 2023 3:52 pm
by jdoubleu
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.
Re: esp_execute_shared_stack_function thread safety
Posted: Thu Feb 09, 2023 12:39 am
by ESP_Sprite
Yeah, that looks like a bug, good catch. I'll file an internal issue.
Re: esp_execute_shared_stack_function thread safety
Posted: Thu Feb 09, 2023 6:17 pm
by jdoubleu
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.