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_execute_shared_stack_function: random Watchpoint 1 panics without CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK (IDFGH-9003) #10414

Closed
3 tasks done
DirtYiCE opened this issue Dec 20, 2022 · 1 comment
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@DirtYiCE
Copy link

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.0-378-g5278cc7de0

Operating System used.

Linux

How did you build your project?

Command line with idf.py

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

None

Development Kit.

LILYGO T-Embed ESP32-S3

Power Supply used.

USB

What is the expected behavior?

The program continues to work after calling esp_execute_shared_stack_function

What is the actual behavior?

Random panics:

Guru Meditation Error: Core  0 panic'ed (Unhandled debug exception). 
Debug exception reason: Watchpoint 1 triggered 

usually from malloc code, but randomly from other places too.

Steps to reproduce.

  1. Call esp_execute_shared_stack_function (just with a noop function)
  2. Delete the task
  3. Wait

Debug Logs.

No response

More Information.

Here it sets the watchpoint to the shared stack:

#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
vPortSetStackWatchpoint(stack);
#endif

And it resets here after returning:
vPortSetStackWatchpoint(current->pxDummy6);

Please not that there is no #if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK here. And without that config, normally nothing sets watchpoint 1, which means if later anything accesses that memory (for example because the task was deleted and its memory was reused for something else), it will panic. Adding that missing #if seems to fix the problem.

Also here it sets pxDummy6 (aka pxStack) to the shared stack's beginning, shouldn't it also set pxEndOfStack?

From a quick look, it looks like riscv implementation has the same problem, but I never tried to use that.

@DirtYiCE DirtYiCE added the Type: Bug bugs in IDF label Dec 20, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 20, 2022
@github-actions github-actions bot changed the title esp_execute_shared_stack_function: random Watchpoint 1 panics without CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK esp_execute_shared_stack_function: random Watchpoint 1 panics without CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK (IDFGH-9003) Dec 20, 2022
@0xjakob
Copy link
Contributor

0xjakob commented Dec 21, 2022

@DirtYiCE Thanks for reporting this issue! It seems that you're right and the second watch point setting needs to be wrapped in ifdefs as well. We'll fix this.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Dec 21, 2022
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: In Progress Work is in progress labels Mar 10, 2023
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable labels Mar 20, 2023
espressif-bot pushed a commit to espressif/esp-hal-components that referenced this issue Mar 20, 2023
esp_execute_shared_stack_function always restored the stack watchpoint
regardless of CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK. This would lead
to an abondoned but active watchpoint on a former stack once the task
calling esp_execute_shared_stack_function is deleted, if
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is inactive.
This has been fixed now.

Closes espressif/esp-idf#10414
espressif-bot pushed a commit to espressif/esp-hal-components that referenced this issue Mar 20, 2023
esp_execute_shared_stack_function always restored the stack watchpoint
regardless of CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK. This would lead
to an abondoned but active watchpoint on a former stack once the task
calling esp_execute_shared_stack_function is deleted, if
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is inactive.
This has been fixed now.

Closes espressif/esp-idf#10414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants