[PATCH] s390: Fix missing early-clobber in __to_generic_vx [BZ #34952]
Florian Fuchs
fuchsfl@gmail.com
Thu Nov 5 00:13:54 GMT 2026
R_TMP is declared as a plain output ("=d") without an early-clobber, so
the compiler may give it the same register as one of the inputs.
At -O1, GCC does so for R_BUF: the buffer address is zeroed and the
following "vst %v16,0(%[R_I],%[R_BUF])" stores to address 0. Any
conversion of 16 or more characters to IBM037, IBM1047 or a similar
8-bit charset then crashes. -O2 and -Os happen to allocate different
registers.
Mark R_TMP as early-clobber ("=&d"), like R_I in the same asm.
Reproducer, when glibc built with -O1:
head -c16 /dev/zero | tr '\0' A | iconv -f UTF-8 -t IBM1047
Tested on s390x with glibc built with -O1: the reproducer above
crashes without this change and works with it.
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
Issue was hit, while building s390-tools with an -O1 glibc: GCC with
-fexec-charset=IBM1047 crashed with an internal compiler error in
iconv. cmdline that reproduces the gcc ice:
echo 'const char *s = "Start subchannel failed";' | \
gcc -fexec-charset=IBM1047 -x c -c - -o /dev/null
sysdeps/s390/multiarch/8bit-generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/s390/multiarch/8bit-generic.c b/sysdeps/s390/multiarch/8bit-generic.c
index 8224cec557..18671a8775 100644
--- a/sysdeps/s390/multiarch/8bit-generic.c
+++ b/sysdeps/s390/multiarch/8bit-generic.c
@@ -266,7 +266,7 @@
".machine pop" \
: /* outputs */ [R_IN] "+a" (inptr) \
, [R_I] "=&a" (index) \
- , [R_TMP] "=d" (tmp) \
+ , [R_TMP] "=&d" (tmp) \
, [R_LI] "+d" (remaining_loop_count) \
: /* inputs */ [R_BUF] "a" (buf) \
, [R_MAX] "d" (max) \
--
2.43.0
More information about the Libc-alpha
mailing list