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

[Backport v4.0-branch] lib: os: mpsc_pbuf: do not wait when spinlock is held #83577

Open
wants to merge 1 commit into
base: v4.0-branch
Choose a base branch
from

Conversation

zephyrbot
Copy link
Collaborator

@zephyrbot zephyrbot commented Jan 6, 2025

Backport 1a578eb from #83355.

Fixes #83354

Check if the spinlock is held before attempting to wait by
taking the semaphore, as that would cause a context switch which
isn't allowed and will trigger an assertion error when
`CONFIG_SPIN_VALIDATE` is enabled.

Logging in spinlock-held context when the log buffer is full can lead
to an infinite assertion error loop, as the logging subsys attempts to
allocate buffer when there's none available, it will try to wait for
one and thus triggers the assertion error, the error message will be
printed through the logging sybsys but there's no buffer available,
so it will try to wait for one and triggers another assertion error..
This loop just goes on and on forever, and nothing gets printed to
the terminal.

Added a test to validate the fix.

Signed-off-by: Yong Cong Sin <[email protected]>
Signed-off-by: Yong Cong Sin <[email protected]>
Signed-off-by: Maxim Adelman <[email protected]>
(cherry picked from commit 1a578eb)
@zephyrbot zephyrbot added Backport Backport PR and backport failure issues area: Logging labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Logging Backport Backport PR and backport failure issues
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

3 participants