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

            Bug ID: 127621
           Summary: wrong code with large _BitInt() arguments and
                    --param=stack-clash-protection-probe-interval=15
                    -fstack-clash-protection on powerpc64le
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---

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

Output:
$ powerpc64le-unknown-linux-gnu-gcc
--param=stack-clash-protection-probe-interval=15 -fstack-clash-protection
testcase.c -static
$ qemu-ppc64le -- ./a.out
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault         ./a.out


This crashes at:
...
   0x0000000010000d60 <+324>:   mr      r3,r10
   0x0000000010000d64 <+328>:   bl      0x10000be4 <foo>
   0x0000000010000d68 <+332>:   lbz     r9,32(r31)
   0x0000000010000d6c <+336>:   clrlwi  r9,r9,24
   0x0000000010000d70 <+340>:   extsw   r9,r9
   0x0000000010000d74 <+344>:   mr      r3,r9
   0x0000000010000d78 <+348>:   ld      r1,0(r1)
=> 0x0000000010000d7c <+352>:   ld      r0,16(r1)
   0x0000000010000d80 <+356>:   mtlr    r0
   0x0000000010000d84 <+360>:   ld      r31,-8(r1)
   0x0000000010000d88 <+364>:   blr
...
(gdb) bt f
#0  0x0000000010000d7c in main () at testcase.c:16
        x = <error reading variable x (Cannot access memory at address
0xfffffffffffec0a0)>
Backtrace stopped: Cannot access memory at address 0xffffffffffff8010
(gdb) info reg
r0             0x1fd8              8152
r1             0xffffffffffff8000  18446744073709518848
...


Using a same-sized struct instead of _BitInt():
typedef struct { long long ll[8160]; } T;
seems to work fine.

Using --param=stack-clash-protection-probe-interval=16 however results in
assembly failure in that case:
/tmp/ccHQye6f.s: Assembler messages:
/tmp/ccHQye6f.s:61: Error: operand out of range (0xffffffffffff0000 is not
between 0xffffffffffff8000 and 0x7ffc)
I don't know if that might be related.

$ powerpc64le-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-20260924134636-r17-4628-g416290b10bb9cb-checking-yes-rtl-df-extra-powerpc64le/bin/../libexec/gcc/powerpc64le-unknown-linux-gnu/17.0.0/lto-wrapper
Target: powerpc64le-unknown-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--enable-libsanitizer --with-sysroot=/usr/powerpc64le-unknown-linux-gnu
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=powerpc64le-unknown-linux-gnu
--with-ld=/usr/bin/powerpc64le-unknown-linux-gnu-ld
--with-as=/usr/bin/powerpc64le-unknown-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-20260924134636-r17-4628-g416290b10bb9cb-checking-yes-rtl-df-extra-powerpc64le
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260924 (experimental) (GCC)

Reply via email to