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] shell: fix unsafe API calls and add configurable autoflush behavior #84440

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

zephyrbot
Copy link
Collaborator

@zephyrbot zephyrbot commented Jan 23, 2025

Backport b0a0feb~2..b0a0feb from #84290.

Fixes #84274

Introduced a new Kconfig option SHELL_PRINTF_AUTOFLUSH to allow
configuring the autoflush behavior of shell printing functions.

Updated Z_SHELL_FPRINTF_DEFINE to use the
CONFIG_SHELL_PRINTF_AUTOFLUSH setting instead of hardcoding
the autoflush behavior to true.

Fixes an issue where the shell API could block indefinitely when called
from threads other than the shell's processing thread, especially when
the transport (e.g. USB CDC ACM) was unavailable or inactive.

Replaced k_mutex_lock calls with an indefinite timeout (K_FOREVER)
by using a fixed timeout (K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) in shell
API functions to prevent indefinite blocking.

Introduced a new Kconfig option `SHELL_PRINTF_AUTOFLUSH` to allow
configuring the autoflush behavior of shell printing functions.

Updated `Z_SHELL_FPRINTF_DEFINE` to use the
`CONFIG_SHELL_PRINTF_AUTOFLUSH` setting instead of hardcoding
the autoflush behavior to `true`.

Signed-off-by: Jakub Rzeszutko <[email protected]>
(cherry picked from commit 8991b95)
Fixes an issue where the shell API could block indefinitely when called
from threads other than the shell's processing thread, especially when
the transport (e.g. USB CDC ACM) was unavailable or inactive.

Replaced `k_mutex_lock` calls with an indefinite timeout (`K_FOREVER`)
by using a fixed timeout (`K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)`) in shell
API functions to prevent indefinite blocking.

Link: #84274

Signed-off-by: Jakub Rzeszutko <[email protected]>
(cherry picked from commit b0a0feb)
@zephyrbot zephyrbot added Backport Backport PR and backport failure issues area: Shell Shell subsystem labels Jan 23, 2025
@jakub-uC
Copy link
Contributor

@carlescufi @kartben

I am a bit confused why this PR is failing:

ERROR:root:https://github.com/zephyrproject-rtos/zephyr/pull/84440 does not have an associated issue
ERROR:root:Please ensure the body of each PR to a release branch contains "Fixes #1234"
ERROR:root:The following PRs are lacking associated issues:
ERROR:root:https://github.com/zephyrproject-rtos/zephyr/pull/84440

while at the same it is forbidden to use the fixes keyword as it is a reference to the zephyr github repository.

Is it an inconsistency or are backport branches special?

@pdgendt
Copy link
Collaborator

pdgendt commented Jan 23, 2025

@carlescufi @kartben

I am a bit confused why this PR is failing:

ERROR:root:https://github.com/zephyrproject-rtos/zephyr/pull/84440 does not have an associated issue
ERROR:root:Please ensure the body of each PR to a release branch contains "Fixes #1234"
ERROR:root:The following PRs are lacking associated issues:
ERROR:root:https://github.com/zephyrproject-rtos/zephyr/pull/84440

while at the same it is forbidden to use the fixes keyword as it is a reference to the zephyr github repository.

Is it an inconsistency or are backport branches special?

I've updated the PR description, should be fixed once the bot sees the "Fixes ..." in the PR description.

@pdgendt
Copy link
Collaborator

pdgendt commented Jan 23, 2025

while at the same it is forbidden to use the fixes keyword as it is a reference to the zephyr github repository.

Commits should not reference PRs or issues, but PR descriptions can and should.

@dkalowsk dkalowsk added this to the v4.0.1 milestone Jan 31, 2025
@dkalowsk dkalowsk merged commit 4a1ffd8 into v4.0-branch Jan 31, 2025
30 of 31 checks passed
@dkalowsk dkalowsk deleted the backport-84290-to-v4.0-branch branch January 31, 2025 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shell Shell subsystem Backport Backport PR and backport failure issues
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants