async_context_threadsafe_background: fix incorrect mutex assertion in cross-core execute_sync() #2528
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!2528
Loading…
Reference in a new issue
No description provided.
Delete branch "2527_mutex_owner"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In multicore configurations,
async_context_threadsafe_background_execute_sync()contained an overly strict assertion used during cross-core calls:This check fails whenever the
lock_mutexis held — regardless of who owns it — even in valid situations where the async core is processing background work.The assertion does not check ownership, only that the
enter_countis zero, which leads to false-positive failures on valid cross-core calls.This patch replaces the enter-count check with a core-aware assertion:
This ensures the current core does not recursively hold the mutex, preventing deadlocks while allowing valid usage where the other core owns the lock.
The patch ensures that both
get_core_num()andhard_assert()remain inlined as in the original implementation, preserving the performance characteristics under-OsandRelWithDebInfobuilds.Fixes #2527
@ -138,8 +138,15 @@ static void lock_release(async_context_threadsafe_background_t *self) {uint32_t async_context_threadsafe_background_execute_sync(async_context_t *self_base, uint32_t (*func)(void *param), void *param) {Is "other call" here supposed to be "other core" ?
@ -138,8 +138,15 @@ static void lock_release(async_context_threadsafe_background_t *self) {uint32_t async_context_threadsafe_background_execute_sync(async_context_t *self_base, uint32_t (*func)(void *param), void *param) {yes
@ -138,8 +138,15 @@ static void lock_release(async_context_threadsafe_background_t *self) {uint32_t async_context_threadsafe_background_execute_sync(async_context_t *self_base, uint32_t (*func)(void *param), void *param) {Maybe: ...to own the mutex concurrently.
@ -138,8 +138,15 @@ static void lock_release(async_context_threadsafe_background_t *self) {uint32_t async_context_threadsafe_background_execute_sync(async_context_t *self_base, uint32_t (*func)(void *param), void *param) {maybe i improved it a little, idk