Skip to content

Commit

Permalink
bugfix(esp_system): made watchpoint setting configuration-dependent
Browse files Browse the repository at this point in the history
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
  • Loading branch information
0xjakob committed Mar 13, 2023
1 parent 931b792 commit fe4f386
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
20 changes: 7 additions & 13 deletions components/esp_system/port/arch/riscv/expression_with_stack.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <esp_expression_with_stack.h>
#include <riscv/rvruntime-frames.h>
Expand Down Expand Up @@ -66,7 +58,9 @@ void esp_execute_shared_stack_function(SemaphoreHandle_t lock, void *stack, size

//Restore current task stack:
current->pxDummy6 = (StackType_t *)current_task_stack;
#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
vPortSetStackWatchpoint(current->pxDummy6);
#endif
portEXIT_CRITICAL(&shared_stack_spinlock);

xSemaphoreGive(lock);
Expand Down
20 changes: 7 additions & 13 deletions components/esp_system/port/arch/xtensa/expression_with_stack.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <esp_expression_with_stack.h>
#include <setjmp.h>
Expand Down Expand Up @@ -75,7 +67,9 @@ void esp_execute_shared_stack_function(SemaphoreHandle_t lock, void *stack, size

//Restore current task stack:
current->pxDummy6 = (StackType_t *)current_task_stack;
#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
vPortSetStackWatchpoint(current->pxDummy6);
#endif
portEXIT_CRITICAL(&xtensa_shared_stack_spinlock);

xSemaphoreGive(lock);
Expand Down

0 comments on commit fe4f386

Please sign in to comment.