Bug#1050589: gcc-13: [x32] -fbuiltin-strchr miscompiles

2023-08-26 Thread Thorsten Glaser
Dixi quod…

>Package: gcc-13
>Version: 13.2.0-1

This is a regression against gcc-12 (= 12.3.0-8); if I install that
and export CC='diet -Os gcc-12' it works.

>./mksh -c 'x=q; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo .$x.'

In case this is relevant: that codepath uses setjmp/longjmp quite a bit,
and builds for glibc, musl or klibc don’t trigger this, so it’s probably
a combination of several things. Using dietlibc/amd64 is also fine, and
dietlibc-wise, they are good as identical: differ only in start.S and
syscall numbers, and a few sections in header files.

bye,
//mirabilos
-- 
 you introduced a merge commit│ % g rebase -i HEAD^^
 sorry, no idea and rebasing just fscked │ Segmentation
 should have cloned into a clean repo  │  fault (core dumped)
 if I rebase that now, it's really ugh │ wuahh



Bug#1050589: gcc-13: [x32] -fbuiltin-strchr miscompiles

2023-08-26 Thread Thorsten Glaser
Package: gcc-13
Version: 13.2.0-1
Severity: normal
X-Debbugs-Cc: t...@mirbsd.de

I've got miscompiles of mksh with gcc-13 on x32 with dietlibc.

I could reproduce this in a chroot by doing…

export CC='diet -Os gcc'
export CFLAGS='-g -Wformat -Werror=format-security -Wall -Wextra'
export CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2 -DMKSH_BUILDMEAT'
sh Build.sh -r -j
./mksh -c 'x=q; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo .$x.'

… in an mksh source tree. (Output is “..” but “.a.” was expected.)

Adding -fno-builtin-strchr to CFLAGS makes the problem go away.

This is as far as I could reduce this; more would involve diving
into the gcc internals.


-- System Information:
Debian Release: trixie/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: x32 (x86_64)

Kernel: Linux 5.10.0-23-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C), 
LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages gcc-13 depends on:
ii  binutils   2.41-4
ii  cpp-13 13.2.0-1
ii  gcc-13-base13.2.0-1
ii  libc6  2.37-7
ii  libcc1-0   13.2.0-1
ii  libgcc-13-dev  13.2.0-1
ii  libgcc-s1  13.2.0-1
ii  libgmp10   2:6.3.0+dfsg-2
ii  libisl23   0.26-3
ii  libmpc31.3.1-1
ii  libmpfr6   4.2.0-1
ii  libstdc++6 13.2.0-1
ii  libzstd1   1.5.5+dfsg2-1
ii  zlib1g 1:1.2.13.dfsg-3

Versions of packages gcc-13 recommends:
ii  libc6-dev  2.37-7

Versions of packages gcc-13 suggests:
pn  gcc-13-doc   
pn  gcc-13-locales   
pn  gcc-13-multilib  

-- no debconf information