[Bug ada/114398] New: Unexpected storage error when "executing" return statement.

2024-03-19 Thread d.van.raaij at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114398

Bug ID: 114398
   Summary: Unexpected storage error when "executing" return
statement.
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: d.van.raaij at gmail dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57741
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57741=edit
Reproducer

The program included in this report generates an unexpected storage error
(SIGSEGV) when the return statement on line 37 is being "executed". The issue
seems to be a regression in GCC 14.0.1 (20240228). 

A quick analysis using rr hints at an invalid value of "_init" in the expanded
code:

(rr) list
244   procedure reproducer__pkg__intIP (_init : out
245 reproducer__pkg__int; P60b : natural := 0; _init_level :
246 natural := 0) is
247   begin
248  if P60b = 0 then
249 _init._tag := pkg__intP; < Error occurs here.
250  end if;
251  if P60b /= 3 then
252 $ada__finalization__limited_controlledIP (_init._parent,
253   1);
(rr) p/x _init
$1 = 

The invalid memory address seems to come from a hidden argument of the "+"
operator function named "OaddBIPaccess":

(rr) frame
#0  reproducer.pkg."+" (left=..., right=..., =0,
=0x0, =0x7fffc9c35df0,
=-909943160, =0x7f1d6258d340
,
=0x17fff) at
/home/dvraaij/gnat14_bip_issue/reproducer.adb.dg:385
385   function reproducer__pkg__Oadd (left : reproducer__pkg__int;


*** Compilation ***

$ gnatmake -f reproducer.adb -cargs -O0 -g -gnatDGL -bargs -Es
gcc -c -O0 -g -gnatDGL reproducer.adb
gnatbind -Es -x reproducer.ali
gnatlink reproducer.ali

*** Program output ***

$ ./reproducer

raised STORAGE_ERROR : stack overflow or erroneous memory access
[/lib64/libgnat-14.so]
0x7f441f1d805f
[/lib64/libc.so.6]
0x7f441ecaf70e
[./reproducer]
0x404b95 reproducer__pkg__intIP.12 at reproducer.adb.dg:249
0x4047eb reproducer__pkg__Oadd.5 at reproducer.adb.dg:579
0x404df9 reproducer__test.15 at reproducer.adb.dg:733
0x404478 _ada_reproducer at reproducer.adb.dg:855
0x403bf7 Main at b~reproducer.adb:254
[/lib64/libc.so.6]
0x7f441ec99086
0x7f441ec99149
[./reproducer]
0x403633 _start at ???
0xfffe

raised PROGRAM_ERROR : reproducer.adb.dg:571 finalize/adjust raised exception
[./reproducer]
0x404af0 reproducer__pkg__Oadd__R80b___finalizer.8 at reproducer.adb.dg:571
0x404894 reproducer__pkg__Oadd.5 at reproducer.adb.dg:600
0x404df9 reproducer__test.15 at reproducer.adb.dg:733
0x404478 _ada_reproducer at reproducer.adb.dg:855
0x403bf7 Main at b~reproducer.adb:254
[/lib64/libc.so.6]
0x7f441ec99086
0x7f441ec99149
[./reproducer]
0x403633 _start at ???
0xfffe

*** Compiler version ***

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-14.0.1-20240228/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240228 (Red Hat 14.0.1-0) (GCC)

[Bug ada/114300] New: Bug box when compiling a program that instantiates a package with a nested ghost package.

2024-03-10 Thread d.van.raaij at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114300

Bug ID: 114300
   Summary: Bug box when compiling a program that instantiates a
package with a nested ghost package.
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: d.van.raaij at gmail dot com
CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57663
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57663=edit
Reproducer

The code included in this report generates a bug box upon compilation. The code
is an isolated reproducer of the bug box that appears when compiling a program
that instantiates SPARKlib package "SPARK.Higher_Order.Fold.Sum".

Issue found on 14.0.1 (20240228), but occurs on 13.2.1 as well.

*** Compiler output ***

$ gcc -c reproducer.adb
+===GNAT BUG DETECTED==+
| 14.0.1 20240228 (Red Hat 14.0.1-0) (x86_64-redhat-linux) GCC error:  |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.cc:377  |
| Error detected at reproducer.adb:33:42   |
| Compiling reproducer.adb |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .  |
| 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 command that you entered.  |
| Also include sources listed below.   |
+==+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

reproducer.adb

gcc: internal compiler error: Segmentation fault signal terminated program
gnat1
Please submit a full bug report, with preprocessed source (by using
-freport-bug).

*** Compiler version ***

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-14.0.1-20240228/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240228 (Red Hat 14.0.1-0) (GCC)