public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110792] New: GCC 13 x86_32 miscompilation of Whirlpool hash function
@ 2023-07-24 12:29 lloyd at randombit dot net
  2023-07-24 13:22 ` [Bug target/110792] " rguenth at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: lloyd at randombit dot net @ 2023-07-24 12:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110792

            Bug ID: 110792
           Summary: GCC 13 x86_32 miscompilation of Whirlpool hash
                    function
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lloyd at randombit dot net
  Target Milestone: ---

Created attachment 55619
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55619&action=edit
Reproducing testcase

Attached is a reproducing testcase for an apparent miscompilation bug in GCC 13
when compiling for 32-bit x86.

Upstream issue: https://github.com/randombit/botan/issues/3637

This code is the core loop of the Whirlpool hash function.

In the attachment if `CAUSE_CODEGEN_BUG` is defined then a particular function
is defined in an anonymous namespace. When that happens, GCC apparently
generates invalid code

$ g++ -O2 -std=c++20 -m32 whirl.cpp -o whirl
$ ./whirl
19FA61D75522A466 9B44E39C1D2E1726 C530232130D407F8 9AFEE0964997F7A7
3E83BE698B288FEB CF88E3E03C4F0757 EA8964E59B63D937 08B138CC42A66EB3
# above is the correct Whirlpool hash for the empty message

$ g++ -DCAUSE_CODEGEN_BUG -O2 -std=c++20 -m32 whirl.cpp -o whirl
$ ./whirl
zsh: segmentation fault  ./whirl

If compiled with Ubsan/Asan, the code is ok:

$ g++ -DCAUSE_CODEGEN_BUG -fsanitize=address -fsanitize=undefined -O2
-std=c++20 -m32 whirl.cpp -o whirl
$ ./whirl
19FA61D75522A466 9B44E39C1D2E1726 C530232130D407F8 9AFEE0964997F7A7
3E83BE698B288FEB CF88E3E03C4F0757 EA8964E59B63D937 08B138CC42A66EB3

My GCC is

$ g++ -v
Using built-in specs.
COLLECT_GCC=/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.1 20230429 (GCC)

This is the compiler from Arch Linux which is AFAIK stock GCC. The original
report related to the GCC 13 included in Alpine Edge.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-05-08 12:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 12:29 [Bug target/110792] New: GCC 13 x86_32 miscompilation of Whirlpool hash function lloyd at randombit dot net
2023-07-24 13:22 ` [Bug target/110792] " rguenth at gcc dot gnu.org
2023-07-24 17:11 ` [Bug target/110792] [13 Regregression] " pinskia at gcc dot gnu.org
2023-07-24 17:25 ` [Bug target/110792] [13 Regression] " pinskia at gcc dot gnu.org
2023-07-24 17:45 ` [Bug target/110792] [13/14 " pinskia at gcc dot gnu.org
2023-07-24 18:00 ` pinskia at gcc dot gnu.org
2023-07-24 18:02 ` pinskia at gcc dot gnu.org
2023-07-24 18:06 ` pinskia at gcc dot gnu.org
2023-07-24 18:16 ` pinskia at gcc dot gnu.org
2023-07-24 18:16 ` pinskia at gcc dot gnu.org
2023-07-24 18:31 ` pinskia at gcc dot gnu.org
2023-07-24 18:37 ` pinskia at gcc dot gnu.org
2023-07-25 14:56 ` roger at nextmovesoftware dot com
2023-07-27  9:27 ` rguenth at gcc dot gnu.org
2023-08-03  6:13 ` cvs-commit at gcc dot gnu.org
2023-08-06 22:24 ` cvs-commit at gcc dot gnu.org
2023-08-11  3:06 ` sjames at gcc dot gnu.org
2023-09-15 17:54 ` mpolacek at gcc dot gnu.org
2023-10-30  9:00 ` sjames at gcc dot gnu.org
2024-05-08 12:45 ` [Bug target/110792] [13 " cvs-commit at gcc dot gnu.org
2024-05-08 12:45 ` cvs-commit at gcc dot gnu.org
2024-05-08 12:47 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).