async_context_threadsafe_background: fix incorrect mutex assertion in cross-core execute_sync() #2528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_mutex
is 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_count
is 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-Os
andRelWithDebInfo
builds.Fixes #2527