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

[v3.7 branch] shell: fix unsafe API calls and add configurable autoflush behavior #84589

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

jakub-uC
Copy link
Contributor

@jakub-uC jakub-uC commented Jan 27, 2025

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.

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`.

Signed-off-by: Jakub Rzeszutko <[email protected]>
(cherry picked from commit 8991b95)
@zephyrbot zephyrbot added the area: Shell Shell subsystem label Jan 27, 2025
@zephyrbot zephyrbot requested a review from carlescufi January 27, 2025 09:56
@jakub-uC jakub-uC added the backport v3.7-branch Request backport to the v3.7-branch label Jan 27, 2025
Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the link reference in the second commit.

@pdgendt
Copy link
Collaborator

pdgendt commented Jan 27, 2025

The backport label is to automate it, no need to add this here.

@pdgendt pdgendt added Backport Backport PR and backport failure issues and removed backport v3.7-branch Request backport to the v3.7-branch labels Jan 27, 2025
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.

Signed-off-by: Jakub Rzeszutko <[email protected]>
(cherry picked from commit b0a0feb)
@jakub-uC jakub-uC force-pushed the backport-84290-to-v3.7-branch branch from 7685453 to 2145bb7 Compare January 27, 2025 11:21
@jakub-uC
Copy link
Contributor Author

done

Copy link
Member

@nashif nashif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a title that describes the change, not numbers and branches, also include a body in the PR with more details, beside the bug being fixed.

Nobody knows what 84290 is and similarly, nobody knows what #84439 fixes by just looking at numbers.

@jakub-uC
Copy link
Contributor Author

@nashif done

@nashif
Copy link
Member

nashif commented Jan 28, 2025

@nashif done

title still says: "Backport 84290 to v3.7 branch"

Fixes #84439

This is not a bug, this is the issue opened when automatic backport is failing, need a real issue

@nashif
Copy link
Member

nashif commented Jan 28, 2025

should be fixing #84274?

@jakub-uC
Copy link
Contributor Author

Yes, fixed it.

@nashif nashif changed the title Backport 84290 to v3.7 branch [v3.7 branch] shell: fix unsafe API calls and add configurable autoflush behavior Jan 28, 2025
@nashif nashif merged commit 9cc6307 into v3.7-branch Jan 29, 2025
29 checks passed
@nashif nashif deleted the backport-84290-to-v3.7-branch branch January 29, 2025 15:11
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