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

            Bug ID: 66247
           Summary: make check-gmp fails for gcc-5.1.0
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mlmar...@clearsky-data.com
  Target Milestone: ---

Created attachment 35592
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35592&action=edit
Preprocessor output

It appears that a pre-fetch at the bottom of a loop walks off the end of
addressable memory. Setting -fno-aggressive-loop-optimizations does change the
behavior by moving the loop comparison to the bottom of the loop and forcing
the next page to be allocated.

$ uname -a
Linux vm-mlmartin-5-1.clearsky-data.net 3.13.9-5.clearsky.el7.centos.x86_64 #1
SMP Wed Aug 6 21:22:34 BST 2014 x86_64 x86_64 x86_64 GNU/Linux

$ /home/mlmartin/gcc-5.1.0-build/./prev-gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=/home/mlmartin/gcc-5.1.0-build/./prev-gcc/xgcc
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.1.0/configure --prefix=/opt/clearsky
--enable-languages=c,c++ --disable-multilib --with-system-zlib
Thread model: posix
gcc version 5.1.0 (GCC) 

$ pwd
/home/mlmartin/gcc-5.1.0-build/gmp/tests/mpz

$[mlmartin@vm-mlmartin-5-1 mpz]$ /home/mlmartin/gcc-5.1.0-build/./prev-gcc/xgcc
-B/home/mlmartin/gcc-5.1.0-build/./prev-gcc/
-B/opt/clearsky/x86_64-unknown-linux-gnu/bin/
-B/opt/clearsky/x86_64-unknown-linux-gnu/bin/
-B/opt/clearsky/x86_64-unknown-linux-gnu/lib/ -isystem
/opt/clearsky/x86_64-unknown-linux-gnu/include -isystem
/opt/clearsky/x86_64-unknown-linux-gnu/sys-include    -DHAVE_CONFIG_H -I.
-I../../../../gcc-5.1.0/gmp/tests/mpz -I../.. -I../../../../gcc-5.1.0/gmp
-I../../../../gcc-5.1.0/gmp/tests  -DNO_ASM  -Wall -Wextra  -fwrapv  -g -O2
-gtoggle -c ../../../../gcc-5.1.0/gmp/tests/mpz/t-scan.c -save-temps
In file included from ../../../../gcc-5.1.0/gmp/tests/mpz/t-scan.c:23:0:
../../../../gcc-5.1.0/gmp/gmp-impl.h: In function ‘mpn_toom33_mul_itch’:
../../../../gcc-5.1.0/gmp/gmp-impl.h:980:46: warning: unused parameter ‘bn’
[-Wunused-parameter]
 mpn_toom33_mul_itch (mp_size_t an, mp_size_t bn)
                                              ^
../../../../gcc-5.1.0/gmp/gmp-impl.h: In function ‘mpn_toom44_mul_itch’:
../../../../gcc-5.1.0/gmp/gmp-impl.h:989:46: warning: unused parameter ‘bn’
[-Wunused-parameter]
 mpn_toom44_mul_itch (mp_size_t an, mp_size_t bn)
                                              ^
../../../../gcc-5.1.0/gmp/tests/mpz/t-scan.c: In function ‘main’:
../../../../gcc-5.1.0/gmp/tests/mpz/t-scan.c:124:11: warning: unused parameter
‘argc’ [-Wunused-parameter]
 main (int argc, char *argv[])
           ^
../../../../gcc-5.1.0/gmp/tests/mpz/t-scan.c:124:23: warning: unused parameter
‘argv’ [-Wunused-parameter]
 main (int argc, char *argv[])
                       ^
$ ./t-scan
Segmentation fault (core dumped)

[mlmartin@vm-mlmartin-5-1 mpz]$ gdb ./t-scan
core.t-scan.13359.vm-mlmartin-5-1.clearsky-data.net.1432223828 
GNU gdb (GDB) 7.8
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./t-scan...done.
[New LWP 13359]
Core was generated by `./t-scan'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000400f80 in check_ref ()
(gdb) disassemble
Dump of assembler code for function check_ref:
   0x0000000000400e70 <+0>:     push   %r15
   0x0000000000400e72 <+2>:     push   %r14
   0x0000000000400e74 <+4>:     push   %r13
   0x0000000000400e76 <+6>:     push   %r12
   0x0000000000400e78 <+8>:     push   %rbp
   0x0000000000400e79 <+9>:     push   %rbx
   0x0000000000400e7a <+10>:    mov    $0x4153c4,%ebp
   0x0000000000400e7f <+15>:    sub    $0x18,%rsp
   0x0000000000400e83 <+19>:    mov    %rsp,%rdi
   0x0000000000400e86 <+22>:    callq  0x404b20 <__gmpz_init>
   0x0000000000400e8b <+27>:    xor    %esi,%esi
   0x0000000000400e8d <+29>:    mov    %rsp,%rdi
   0x0000000000400e90 <+32>:    callq  0x4053c0 <__gmpz_random2>
   0x0000000000400e95 <+37>:    mov    $0xfffffffe,%esi
   0x0000000000400e9a <+42>:    nopw   0x0(%rax,%rax,1)
   0x0000000000400ea0 <+48>:    mov    %esi,%eax
   0x0000000000400ea2 <+50>:    neg    %eax
   0x0000000000400ea4 <+52>:    test   %eax,%eax
   0x0000000000400ea6 <+54>:    jg     0x400f80 <check_ref+272>
   0x0000000000400eac <+60>:    xor    %r12d,%r12d
   0x0000000000400eaf <+63>:    movslq %esi,%rbx
   0x0000000000400eb2 <+66>:    mov    $0x1,%r13d
   0x0000000000400eb8 <+72>:    test   %r12d,%r12d
   0x0000000000400ebb <+75>:    mov    %rbx,%rsi
   0x0000000000400ebe <+78>:    mov    %rsp,%rdi
   0x0000000000400ec1 <+81>:    je     0x400f00 <check_ref+144>
   0x0000000000400ec3 <+83>:    callq  0x4057b0 <__gmpz_scan1>
   0x0000000000400ec8 <+88>:    mov    $0x1,%edx
   0x0000000000400ecd <+93>:    mov    %rax,%r14
   0x0000000000400ed0 <+96>:    mov    %rbx,%rsi
   0x0000000000400ed3 <+99>:    mov    %rsp,%rdi
   0x0000000000400ed6 <+102>:   callq  0x400de0 <refmpz_scan>
   0x0000000000400edb <+107>:   cmp    %rax,%r14
   0x0000000000400ede <+110>:   mov    %rax,%r15
   0x0000000000400ee1 <+113>:   jne    0x400f1d <check_ref+173>
   0x0000000000400ee3 <+115>:   cmp    $0x2,%r13d
   0x0000000000400ee7 <+119>:   je     0x400f80 <check_ref+272>
   0x0000000000400eed <+125>:   add    $0x1,%r12d
   0x0000000000400ef1 <+129>:   add    $0x1,%r13d
   0x0000000000400ef5 <+133>:   mov    %rbx,%rsi
   0x0000000000400ef8 <+136>:   test   %r12d,%r12d
   0x0000000000400efb <+139>:   mov    %rsp,%rdi
   0x0000000000400efe <+142>:   jne    0x400ec3 <check_ref+83>
   0x0000000000400f00 <+144>:   callq  0x405650 <__gmpz_scan0>
   0x0000000000400f05 <+149>:   xor    %edx,%edx
   0x0000000000400f07 <+151>:   mov    %rax,%r14
   0x0000000000400f0a <+154>:   mov    %rbx,%rsi
   0x0000000000400f0d <+157>:   mov    %rsp,%rdi
   0x0000000000400f10 <+160>:   callq  0x400de0 <refmpz_scan>
   0x0000000000400f15 <+165>:   cmp    %r14,%rax
   0x0000000000400f18 <+168>:   mov    %rax,%r15
   0x0000000000400f1b <+171>:   je     0x400eed <check_ref+125>
   0x0000000000400f1d <+173>:   mov    %r12d,%r9d
   0x0000000000400f20 <+176>:   mov    %rbx,%r8
   0x0000000000400f23 <+179>:   xor    %ecx,%ecx
   0x0000000000400f25 <+181>:   xor    %edx,%edx
   0x0000000000400f27 <+183>:   xor    %esi,%esi
   0x0000000000400f29 <+185>:   mov    $0x415368,%edi
   0x0000000000400f2e <+190>:   xor    %eax,%eax
   0x0000000000400f30 <+192>:   callq  0x400b90 <printf@plt>
   0x0000000000400f35 <+197>:   mov    $0x4153a2,%edi
   0x0000000000400f3a <+202>:   xor    %eax,%eax
   0x0000000000400f3c <+204>:   callq  0x400b90 <printf@plt>
   0x0000000000400f41 <+209>:   mov    0x21b1f8(%rip),%rdi        # 0x61c140
<stdout@@GLIBC_2.2.5>
   0x0000000000400f48 <+216>:   mov    %rsp,%rdx
   0x0000000000400f4b <+219>:   mov    $0xfffffff0,%esi
   0x0000000000400f50 <+224>:   callq  0x4050d0 <__gmpz_out_str>
   0x0000000000400f55 <+229>:   mov    $0xa,%edi
   0x0000000000400f5a <+234>:   callq  0x400b20 <putchar@plt>
   0x0000000000400f5f <+239>:   mov    $0x4153aa,%edi
   0x0000000000400f64 <+244>:   mov    %r15,%rdx
   0x0000000000400f67 <+247>:   mov    %r14,%rsi
   0x0000000000400f6a <+250>:   xor    %eax,%eax
   0x0000000000400f6c <+252>:   callq  0x400b90 <printf@plt>
   0x0000000000400f71 <+257>:   mov    $0x1,%edi
   0x0000000000400f76 <+262>:   callq  0x400c80 <exit@plt>
   0x0000000000400f7b <+267>:   nopl   0x0(%rax,%rax,1)
=> 0x0000000000400f80 <+272>:   mov    0x0(%rbp),%esi           <<<<<<<<<
   0x0000000000400f83 <+275>:   add    $0x4,%rbp
   0x0000000000400f87 <+279>:   jmpq   0x400ea0 <check_ref+48>
End of assembler dump.

(gdb) info registers
rax            0xffffffffffffffff       -1
rbx            0x0      0
rcx            0x0      0
rdx            0x0      0
rsi            0x0      0
rdi            0x7fff6ad518c0   140734985738432
rbp            0x41c000 0x41c000                                <<<<<<<<<
rsp            0x7fff6ad518c0   0x7fff6ad518c0
r8             0x0      0
r9             0x0      0
r10            0x7fff6ad51670   140734985737840
r11            0x7fe78f534420   140632518771744
r12            0x1      1
r13            0x2      2
r14            0xffffffffffffffff       -1
r15            0xffffffffffffffff       -1
rip            0x400f80 0x400f80 <check_ref+272>
eflags         0x10246  [ PF ZF IF RF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb) x 0x41c000
0x41c000:       Cannot access memory at address 0x41c000
(gdb)

Reply via email to