The attached code generates a segfault when compiled with -fbounds-check, even if there is no bounds violation nor any other error I can see. (indeed if it's wrong code I'd love to learn why). Session log: [sfilippo@localhost bugtest]$ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.2-20061107/configure --prefix=/usr/local/gcc42 --with- mpfr-dir=/home/sfilippo/COMPILERS/GFORTRAN/TEMP/mpfr-2.2.0 --with-mpfr=/home/sfi lippo/COMPILERS/GFORTRAN/TEMP/mpfr --with-gmp-dir=/home/sfilippo/COMPILERS/GFORT RAN/TEMP/gmp-4.2/ --with-gmp=/home/sfilippo/COMPILERS/GFORTRAN/TEMP/gmp Thread model: posix gcc version 4.2.0 20061107 (prerelease) [sfilippo@localhost bugtest]$ gfortran -o dt_bnd -ggdb dt_bnd.f90 [sfilippo@localhost bugtest]$ ./dt_bnd Test case : 1 Description: Base Type 2 : 2 4 6 8 10 1 2 14 16 18 20 22 24 26 28 30 32 34 36 38 40 Multilevel: Level No 2 Multilevel: 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 Test case : 2 Description: Base Type 2 : 2 4 6 8 10 1 2 14 16 18 20 22 24 26 28 30 32 34 36 38 40 Multilevel: Level No 2 Multilevel: 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 [sfilippo@localhost bugtest]$ gfortran -o dt_bnd -ggdb -fbounds-check dt_bnd.f90 [sfilippo@localhost bugtest]$ ./dt_bnd Test case : 1 Segmentation fault (core dumped) [sfilippo@localhost bugtest]$ gdb dt_bnd -c core.4828 GNU gdb Red Hat Linux (6.0post-0.20040223.19rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db lib rary "/lib/tls/libthread_db.so.1". Core was generated by `./dt_bnd'. Program terminated with signal 11, Segmentation fault. Reading symbols from /usr/local/gcc42/lib/libgfortran.so.2...done. Loaded symbols for /usr/local/gcc42/lib/libgfortran.so.2 Reading symbols from /lib/tls/libm.so.6...done. Loaded symbols for /lib/tls/libm.so.6 Reading symbols from /usr/local/gcc42/lib/libgcc_s.so.1...done. Loaded symbols for /usr/local/gcc42/lib/libgcc_s.so.1 Reading symbols from /lib/tls/libc.so.6...done. Loaded symbols for /lib/tls/libc.so.6 Reading symbols from /lib/ld-linux.so.2...done. Loaded symbols for /lib/ld-linux.so.2 #0 0x08048c5a in __pp_type__dppset (p=@0x804e6f8, ptype=@0x804bc86, info=@0xbfe053c0, iv=0x0, rs=0x0, rv=0x0, il=0x804d4c4, nl=0x804d4c4, _ptype=2) at dt_bnd.f90:104 104 if (.not.allocated(p%bv(il_)%ipv)) then
Created attachment 12592 [details] Test case Very much reduced from a real application code, possibly not minimal yet.
Created attachment 12593 [details] ignore (wrong file)
Created attachment 12594 [details] Reduced test case Ignore previous attachment that was the wrong file.
Salvatore, When I got round to your off-list email, I foun that it was empty. I was about to contact you. Paul
Rather than segfaulting, with Cywin_NT the progam produces Inconsistent BV for IL>1! in runtime. It runs fine withou -founds-check.
Salvatore, could you please recheck this one? I can not observe any problems, neither on dt_bnd.f90 nor on the reduced testcase. $> gfortran-svn -g -fbounds-check dt_bnd.f90 && ./a.out [snipped output] $> valgrind --tool=memcheck --leak-check=full a.out [...] ==12425== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 7 from 1) ==12425== malloc/free: in use at exit: 0 bytes in 0 blocks. ==12425== malloc/free: 24 allocs, 24 frees, 44,703 bytes allocated. $> gfortran-svn -v gcc version 4.3.0 20070705 (experimental) The same holds for: $> gfortran-4.2 -v gcc version 4.2.1 20070620 (prerelease)
(In reply to comment #6) > Salvatore, could you please recheck this one? I can not observe any problems, > neither on dt_bnd.f90 nor on the reduced testcase. Neither can I, it seems to have fixed itself. Should we put it into the test suite to make sure there's no regression?
Subject: Re: segfault with -fbounds-check on allocatable derived type components Have you looked with valgrind or similar to see if there are errors occurring? Please definitely put in the testsuite. There may be something we don't see yet going on here.
Subject: Bug 29804 Author: fxcoudert Date: Thu Jul 12 10:58:49 2007 New Revision: 126578 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126578 Log: PR fortran/29804 * gfortran.dg/alloc_comp_misc_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/alloc_comp_misc_1.f90 Modified: trunk/gcc/testsuite/ChangeLog
I can't see this bug on i686-linux nor x86_64-linux, even with valgrind. I committed the testcase into our testsuite, so that we can see if it ever reappears.