Description
It was found that when building gawk 5.2.1 with -O2
or -O3
, incorrect machine code is generated which is causing differing runtime behavior than expected.
Background
Originally I ran into this when upgrading gawk on my personal Gentoo systems to 5.2.1. There is a particular regex[1] used in plymouth which was suddenly erroring that did not previously. Downgrading to gawk 5.1.1, building it with gcc, or disabling compiler optimizations would work around the issue.
This issue is being submitted after some discussion[2] on the gawk-bug mailing list, particularly because of these findings[3].
A simple test case is this command:
head /dev/zero | awk 'BEGIN { RS="[[][:blank:]]" }'
When running this command, the expected behavior is no output and a clean exit. However, when building gawk 5.2.1 with clang and -O2
or -O3
, we see this error (and a non-zero exit code):
awk: cmd. line:1: fatal: invalid character class
[1] https://gitlab.freedesktop.org/plymouth/plymouth/-/blob/main/scripts/plymouth-set-default-theme.in#L50
[2] https://lists.gnu.org/archive/html/bug-gawk/2022-12/msg00010.html
[3] https://lists.gnu.org/archive/html/bug-gnulib/2023-01/msg00002.html