- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8.2k
Labels
area: ShellShell subsystemShell subsystembugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug
Description
Describe the bug
when running the shell bypass sample the shell gets stuck and to text is not printed to terminal, and shell is locked.
after short inspection it seems that shell_fprintf() fails to take the internal shell mutex (sh->ctx->lock_sem) and printing is dropped.
possible fix is to unlock shell before and re-lock after calling bypass cb. snippet from shell.c:
		if (bypass) {
#if defined(CONFIG_SHELL_BACKEND_RTT) && defined(CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN)
			uint8_t buf[CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN];
#else
			uint8_t buf[16];
#endif
			(void)sh->iface->api->read(sh->iface, buf,
							sizeof(buf), &count);
			if (count) {
				z_flag_cmd_ctx_set(sh, true);
				z_shell_unlock(sh); // add this 
				bypass(sh, buf, count);
				z_shell_lock(sh); //and this
				z_flag_cmd_ctx_set(sh, false);
				/* Check if bypass mode ended. */
				if (!(volatile shell_bypass_cb_t *)sh->ctx->bypass) {
					state_set(sh, SHELL_STATE_ACTIVE);
				} else {
					continue;
				}
			}
			return;
		}this fix was tested and seems to fix the issue.
Regression
- This is a regression.
Steps to reproduce
- build shell_module sample
- flash and run on nucleo_l476rg
- type 'bypass' cmd in shell.
- shell will freeze
Relevant log output
uart:~$ bypass
Bypass started, press ctrl-x ctrl-q to escape
0a |
at this point shell freezes
Impact
Showstopper – Prevents release or major functionality; system unusable.
Environment
Windows 11
zephyr 4.2.0
Additional Context
this regression started after updating zephyr from v4.0.0 to 4.2.0
Metadata
Metadata
Assignees
Labels
area: ShellShell subsystemShell subsystembugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug