Bug 36207 - [4.4 regression] Ada bootstrap fails in uintp.adb:1595
Summary: [4.4 regression] Ada bootstrap fails in uintp.adb:1595
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.4.0
: P4 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks: 36216
  Show dependency treegraph
 
Reported: 2008-05-11 09:24 UTC by Aaron W. LaFramboise
Modified: 2008-07-29 20:47 UTC (History)
5 users (show)

See Also:
Host: i386-pc-mingw32
Target: i386-pc-mingw32
Build:
Known to work: 4.3.0
Known to fail: 4.4.0
Last reconfirmed: 2008-06-03 19:32:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron W. LaFramboise 2008-05-11 09:24:32 UTC
The type size seems to be getting set to zero when calling Build_Signed_Integer_Type in cstand.adb.  It's possible that the stage2 gnat has been miscompiled.

/mingw/src/gccsvn/obj/./prev-gcc/xgcc -B/mingw/src/gccsvn/obj/./prev-gcc/ -B/mingw/i386-pc-mingw32/bin/ -c -g -O2 -D__USE_MINGW_ACCESS      -gnatpg -gnata -gnatws -nostdinc -I- -I. -Iada -I../../svn/gcc/ada ../../svn/gcc/ada/ada.ads -o ada/ada.o -v -save-temps
Reading specs from /mingw/src/gccsvn/obj/./prev-gcc/specs
Target: i386-pc-mingw32
Configured with: ../svn/configure --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ --disable-sjlj-exceptions --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-concept-checks --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gcc/gmp-mpfr-root --with-mpfr=/mingw/src/gcc/gmp-mpfr-root --with-libiconv-prefix=/mingw/src/gcc/libiconv-root
Thread model: win32
gcc version 4.4.0 20080510 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-B/mingw/src/gccsvn/obj/./prev-gcc/' '-B/mingw/i386-pc-mingw32/bin/' '-c' '-g' '-O2' '-D__USE_MINGW_ACCESS' '-gnatpg' '-gnata' '-gnatws' '-nostdinc' '-I-' '-I.' '-Iada' '-I../../svn/gcc/ada' '-o' 'ada/ada.o' '-v' '-save-temps' '-mtune=i386'
 /mingw/src/gccsvn/obj/./prev-gcc/gnat1.exe -I- -I. -Iada -I../../svn/gcc/ada -quiet -nostdinc -dumpbase ada.ads -O2 -g -gnatpg -gnata -gnatws -mtune=i386 -gnatO ada/ada.o ../../svn/gcc/ada/ada.ads -o ada.s
+===========================GNAT BUG DETECTED==============================+
| 4.4.0 20080510 (experimental) (i386-pc-mingw32) Assert_Failure uintp.adb:1595|
| No source file position information available                            |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

(gdb) run
Starting program: /mingw/src/gccsvn/obj/./prev-gcc/gnat1.exe -I- -I. -Iada -I../../svn/gcc/ada -quiet -nostdinc -dumpbase ada.ads -O2 -g -gnatpg -gnata -gnatws -mtune=i386 -gnatO ada/ada.o ../../svn/gcc/ada/ada.ads -o ada.s
[New thread 1908.0x11bc]

Breakpoint 5, uintp.ui_expon (left=600032770, right=600032767)
    at ../../svn/gcc/ada/uintp.adb:1595
1595          pragma Assert (Right >= Uint_0);
(gdb) print Right
$7 = 600032767
(gdb) print Uint_0
$8 = 600032768
(gdb) bt
#0  uintp.ui_expon (left=600032770, right=600032767)
    at ../../svn/gcc/ada/uintp.adb:1595
#1  0x00497451 in cstand.build_signed_integer_type (e=17, siz=0)
    at ../../svn/gcc/ada/cstand.adb:160
#2  0x00498917 in cstand.create_standard ()
    at ../../svn/gcc/ada/cstand.adb:473
#3  0x005556d5 in frontend () at ../../svn/gcc/ada/frontend.adb:88
#4  0x006a0b37 in gnat1drv () at ../../svn/gcc/ada/gnat1drv.adb:432
#5  0x00422657 in gnat_parse_file (set_yydebug=0)
    at ../../svn/gcc/ada/misc.c:240
#6  0x006fe03e in toplev_main (argc=20, argv=0x3d42f8)
    at ../../svn/gcc/toplev.c:962
#7  0x006a14d9 in main (argc=) at ../../svn/gcc/main.c:35
(gdb) frame 2
#2  0x00498917 in cstand.create_standard ()
    at ../../svn/gcc/ada/cstand.adb:473

(gdb) print Standard_Short_Short_Integer
$9 = 694
(gdb) print Standard_Short_Short_Integer_Size
$10 = 8
Comment 1 Samuel Tardieu 2008-05-12 12:11:02 UTC
Could you post the disassembly of the previous stage "get_target_char_size" from targtyps.o? (objdump --source targtyps.o)

On i686-pc-linux-gnu, I get:

Pos
get_target_char_size (void)
{
  14:   55                      push   %ebp
  15:   89 e5                   mov    %esp,%ebp
  return CHAR_TYPE_SIZE;
  17:   b8 08 00 00 00          mov    $0x8,%eax
}
  1c:   5d                      pop    %ebp
  1d:   c3                      ret    

This function is called to initialize Standard_Short_Short_Integer_Size. If CHAR_TYPE_SIZE is not defined for your target, it defaults to BITS_PER_UNIT (gigi.h).
Comment 2 Samuel Tardieu 2008-05-12 12:18:22 UTC
The beginning of "objdump --disassemble-all -r ttypes.o" should be interesting as well:

00000000 <ttypes___elabs>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   e8 fc ff ff ff          call   7 <ttypes___elabs+0x7>
                        7: R_386_PC32   get_target_char_size
   b:   89 04 24                mov    %eax,(%esp)
   e:   a3 00 00 00 00          mov    %eax,0x0
                        f: R_386_32    ttypes__standard_short_short_integer_size
Comment 3 Aaron W. LaFramboise 2008-05-13 13:50:19 UTC
Here is the information.  I included the stage1 compiler as well just for comparison purposes.  For some reason, the source line information is missing from both, but I suspect thats not very important.

Unfortunately, I don't see anything wrong here, so I'm not quite sure how to proceed.

stage1

00000014 <_get_target_char_size>:
  14:	55                   	push   %ebp
  15:	89 e5                	mov    %esp,%ebp
  17:	b8 08 00 00 00       	mov    $0x8,%eax
  1c:	5d                   	pop    %ebp
  1d:	c3                   	ret    

00000000 <_ttypes___elabs>:
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	83 ec 08             	sub    $0x8,%esp
   6:	e8 00 00 00 00       	call   b <_ttypes___elabs+0xb>
			7: DISP32	_get_target_char_size
   b:	a3 00 00 00 00       	mov    %eax,0x0
			c: dir32	.bss
  10:	a1 00 00 00 00       	mov    0x0,%eax
			11: dir32	.bss
  15:	89 04 24             	mov    %eax,(%esp)
  18:	e8 00 00 00 00       	call   1d <_ttypes___elabs+0x1d>



stage2

00000018 <_get_target_char_size>:
  18:	55                   	push   %ebp
  19:	89 e5                	mov    %esp,%ebp
  1b:	b8 08 00 00 00       	mov    $0x8,%eax
  20:	c9                   	leave  
  21:	c3                   	ret    
  22:	66 90                	xchg   %ax,%ax


00000000 <_ttypes___elabs>:
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	83 ec 08             	sub    $0x8,%esp
   6:	e8 00 00 00 00       	call   b <_ttypes___elabs+0xb>
			7: DISP32	_get_target_char_size
   b:	a3 00 00 00 00       	mov    %eax,0x0
			c: dir32	.bss
  10:	89 04 24             	mov    %eax,(%esp)
  13:	e8 00 00 00 00       	call   18 <_ttypes___elabs+0x18>
Comment 4 Danny Smith 2008-05-17 07:27:44 UTC
Is this related to PR35493?
A possibly related cygwin failure was also reported here.
http://gcc.gnu.org/ml/gcc/2008-03/msg00681.html.

My last successful build of Ada on mingw was:
gcc version 4.4.0 20080312 (experimental) (GCC)

Danny
Comment 5 Aaron W. LaFramboise 2008-06-03 19:32:55 UTC
Apparently not related to PR35493, because its still present.  I'll give debugging this another shot later.
Comment 6 Eric Botcazou 2008-06-03 19:57:37 UTC
> Apparently not related to PR35493, because its still present.

I think it's actually the same problem, the patch that has fixed it on other
platforms probably doesn't behave the same everywhere.
Comment 7 Eric Botcazou 2008-07-11 21:20:03 UTC
> I think it's actually the same problem, the patch that has fixed it on other
> platforms probably doesn't behave the same everywhere.

Yep, PE-COFF has a custom binds_local_p hook that doesn't reject DECL_EXTERNAL.
That's OK according to http://gcc.gnu.org/ml/gcc/2008-07/msg00205.html

Aaron, could you conduct a small experiment?  In winnt.c:i386_pe_binds_local_p,
just before the 'return true', could you add

gcc_assert (!(TREE_CODE (exp) == VAR_DECL && DECL_EXTERNAL (exp)));

and see whether it triggers during an Ada bootstrap?  If so, what's 'exp'?

Thanks in advance.
Comment 8 Aaron W. LaFramboise 2008-07-14 08:57:24 UTC
Eric, with that change, I see this:

../../../svn/libgcc/../gcc/libgcc2.c: In function '__do_global_ctors':          
../../../svn/libgcc/../gcc/libgcc2.c:2161: internal compiler error: in i386_pe_binds_local_p, at config/i386/winnt.c:337

debug_tree(exp)
 <var_decl 04C036E0 __CTOR_LIST__
    type <array_type 04C0EC98
        type <pointer_type 04C0EC30 func_ptr type <function_type 03CC4888>
            public unsigned SI
            size <integer_cst 03C987C0 constant 32>
            unit size <integer_cst 03C98560 constant 4>
            align 32 symtab 79753888 alias set -1 canonical type 041F5D68
            pointer_to_this <pointer_type 04C0ED00>>
        BLK
        align 32 symtab 0 alias set -1 canonical type 04C0EDD0
        pointer_to_this <pointer_type 04C12270>>
    addressable used public external common BLK file ../../../svn/libgcc/../gcc/
gbl-ctors.h line 48 col 17
    align 32
    (mem/s/c:BLK (symbol_ref:SI ("__CTOR_LIST__") <var_decl 04C036E0 __CTOR_LIST
__>) [2 __CTOR_LIST__+0 A32]) chain <var_decl 04C03738 __DTOR_LIST__>>
Comment 9 Eric Botcazou 2008-07-14 09:03:30 UTC
> Eric, with that change, I see this:
> 
> ../../../svn/libgcc/../gcc/libgcc2.c: In function '__do_global_ctors':          
> ../../../svn/libgcc/../gcc/libgcc2.c:2161: internal compiler error: in
> i386_pe_binds_local_p, at config/i386/winnt.c:337

OK, thanks, the assertion is too broad.  Could you replace it with

  gcc_assert (!(TREE_CODE (exp) == VAR_DECL
                && TREE_STATIC (exp)
                && DECL_EXTERNAL (exp)));

instead?
Comment 10 Aaron W. LaFramboise 2008-07-14 14:38:01 UTC
(In reply to comment #9)

>   gcc_assert (!(TREE_CODE (exp) == VAR_DECL
>                 && TREE_STATIC (exp)
>                 && DECL_EXTERNAL (exp)));

Eric, OK, now I get:

/mingw/src/gccada/./prev-gcc/xgcc -B/mingw/src/gccada/./prev-gcc/ -B/mingw/i386-pc-mingw32/bin/ -c -g -O2 -D__USE_MINGW_ACCESS      -gnatpg -gnata -gnatwns -g -O1 -fno-inline \
         -nostdinc -I- -I. -Iada -I../../svn/gcc/ada ../../svn/gcc/ada/a-except.adb -o ada/a-except.o
+===========================GNAT BUG DETECTED==============================+    
| 4.4.0 20080713 (experimental) (i386-pc-mingw32) GCC error:               |    
| in i386_pe_binds_local_p, at config/i386/winnt.c:339                     |    
| Error detected around ../../svn/gcc/ada\a-exexda.adb:647                 | 
...
raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:424 

debug_tree(exp)
 <var_decl 03D11D68 system__soft_links__get_current_excep
    type <pointer_type 03D142D8 system__soft_links__get_eoa_call
        type <function_type 03D141A0 system__soft_links__T10s type <pointer_type
 038E5A90 ada__exceptions__exception_occurrence_access>
            sizes-gimplified asm_written visited QI
            size <integer_cst 000C8520 constant 8>
            unit size <integer_cst 000C8540 constant 1>
            align 8 symtab 64062056 alias set -1 canonical type 03D141A0
            arg-types <tree_list 03D16DC0 value <void_type 000DA7B8 void>>
            pointer_to_this <pointer_type 03D142D8 system__soft_links__get_eoa_call>>                                                                           
        sizes-gimplified visited unsigned SI
        size <integer_cst 000C86E0 constant 32>
        unit size <integer_cst 000C8480 constant 4>
        align 32 symtab 64062280 alias set -1 canonical type 03D142D8>
    side-effects addressable volatile public static unsigned external SI file ../../svn/gcc/ada\s-soflin.ads line 255 col 4 size <integer_cst 000C86E0 32> unit size <integer_cst 000C8480 4>
    align 32
    (mem/v/f/c/i:SI (symbol_ref:SI ("system__soft_links__get_current_excep") <var_decl 03D11D68 system__soft_links__get_current_excep>) [0 system__soft_links__get_current_excep+0 S4 A32])>
Comment 11 Eric Botcazou 2008-07-14 14:44:41 UTC
> /mingw/src/gccada/./prev-gcc/xgcc -B/mingw/src/gccada/./prev-gcc/
> -B/mingw/i386-pc-mingw32/bin/ -c -g -O2 -D__USE_MINGW_ACCESS      -gnatpg
> -gnata -gnatwns -g -O1 -fno-inline \
>          -nostdinc -I- -I. -Iada -I../../svn/gcc/ada
> ../../svn/gcc/ada/a-except.adb -o ada/a-except.o
> +===========================GNAT BUG DETECTED==============================+    
> | 4.4.0 20080713 (experimental) (i386-pc-mingw32) GCC error:               |    
> | in i386_pe_binds_local_p, at config/i386/winnt.c:339                     |    
> | Error detected around ../../svn/gcc/ada\a-exexda.adb:647                 | 

Thanks.  We have identified the potential source of the problem in Gigi.
Comment 12 Eric Botcazou 2008-07-27 17:11:16 UTC
Aaron, could you update your tree and attemp a clean bootstrap?  The fix is
supposed to be

2008-07-17  Olivier Hainque  <hainque@adacore.com>

	* utils.c (create_var_decl_1): Relax expectations on the PUBLIC_FLAG
	argument, to apply to references in addition to definitions.  Prevent
	setting TREE_STATIC on externals.
	(gnat_pushdecl): Always clear DECL_CONTEXT on public externals.
Comment 13 Aaron W. LaFramboise 2008-07-29 19:43:05 UTC
Eric, this failure seems to be fixed now on trunk.  Thanks!

Ada is back in business now on mingw32, modulo some Makefile.in problems which I'm fixing now.
Comment 14 Eric Botcazou 2008-07-29 20:47:25 UTC
> Eric, this failure seems to be fixed now on trunk.

Great!

> Ada is back in business now on mingw32, modulo some Makefile.in problems which
> I'm fixing now.

Thanks for spending a bit of your time on Ada.