Bug 2133097

Summary: bash fails to handle nested expansions
Product: [Fedora] Fedora Reporter: Gursewak Mangat <gurssing>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: admiller, bmj001, dustymabe, jlebon, joepesco2020, kasal, kdudka, lantw44, nixuser, svashisht
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: bash-5.2.2-2.fc36 bash-5.2.2-2.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-10-14 12:59:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gursewak Mangat 2022-10-07 20:38:11 UTC
Description of problem:
The latest rawhide bash errors out for `bad substitution` for /lib/kdump/kdump-lib.sh file in ${_src#${_src_nofsroot}[} when we try to enable kdump.service
It fails for bash-5.2.0-2.fc38.x86_64 and bash-5.2.2-1.fc38.x86_64
It works for bash-5.1.16-4.fc38

Error:
```
Oct 06 21:37:11 cosa-devsh kdumpctl[1291]: grep: warning: stray \ before -
Oct 06 21:37:11 cosa-devsh kdumpctl[1322]: /lib/kdump/kdump-lib.sh: line 192: bad substitution: no closing `}' in ${_src#${_src_nofsroot}[}
Oct 06 21:37:11 cosa-devsh kdumpctl[1170]: kdump: mkdumprd: failed to make kdump initrd
Oct 06 21:37:11 cosa-devsh kdumpctl[1170]: kdump: Starting kdump: [FAILED]
Oct 06 21:37:11 cosa-devsh systemd[1]: kdump.service: Main process exited, code=exited, status=1/FAILURE
Oct 06 21:37:11 cosa-devsh systemd[1]: kdump.service: Failed with result 'exit-code'.
Oct 06 21:37:11 cosa-devsh systemd[1]: Failed to start kdump.service - Crash recovery kernel arming.
```

Version-Release number of selected component (if applicable): bash-5.2.0-2.fc38.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. Get up a machine with the latest rawhide bash rpm packages
2. Enable kdump service with `systemctl enable kdump.service`

Actual results:
Enabling the service results in error for bad substitution as shown in the description above

Expected results:
The kdump.service should be enabled with no errors.

Additional info:
Filing under the bash component because it appears to be a backwards compatibility break, but if it was intentional, please re-assign to kdump.

Comment 1 Siteshwar Vashisht 2022-10-10 14:41:27 UTC
Thanks for the report!

Upstream discussion: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00022.html

Related patch: https://git.savannah.gnu.org/cgit/bash.git/diff/subst.c?h=devel&id=22f21b760ed90eb77c3756e6ccf39b73c84f532a

Minimal reproducer:

#!/bin/bash
foo="foobar"
string_to_remove="foo"
bar=${foo#${string_to_remove}[}
echo $bar

Comment 2 Siteshwar Vashisht 2022-10-10 14:54:23 UTC
Review https://src.fedoraproject.org/rpms/bash/pull-request/36?

Comment 3 Kamil Dudka 2022-10-10 15:24:46 UTC
Looks good.

Comment 4 Fedora Update System 2022-10-11 14:55:36 UTC
FEDORA-2022-6d7a87b3aa has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-6d7a87b3aa

Comment 5 Fedora Update System 2022-10-11 14:55:36 UTC
FEDORA-2022-1551c099fc has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-1551c099fc

Comment 6 Fedora Update System 2022-10-11 15:53:20 UTC
FEDORA-2022-1551c099fc has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-1551c099fc`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-1551c099fc

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2022-10-12 13:02:26 UTC
FEDORA-2022-6d7a87b3aa has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-6d7a87b3aa`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-6d7a87b3aa

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Bruce Jerrick 2022-10-12 20:56:55 UTC
I am investigating what may be a related failure that popped up after upgrading F36 5.1.16-3 to 5.2.2-1, and
still seems to be present in 5.2.2-2 (will report later.)

Meanwhile, something that hinders testing is that neither $BASH_VERSION nor 'bash --verbose' report the release number (e.g. -1 or -2).
Can that be fixed?

Comment 9 Bruce Jerrick 2022-10-13 06:41:08 UTC
(In reply to Bruce Jerrick from comment #8)
> I am investigating what may be a related failure ...

I have filed 2134307: 'sh' fails to recognize an eval'd alias inside $() command substitution
The circumstances are similar but seem sufficiently different to warrant a separate report.
(I included a link to this report in that new one, but don't see a way to add the opposite link
  from here to there.)

Comment 10 Fedora Update System 2022-10-14 12:59:17 UTC
FEDORA-2022-6d7a87b3aa has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 11 Fedora Update System 2022-11-10 22:15:13 UTC
FEDORA-2022-1551c099fc has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.