public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/114398] New: Unexpected storage error when "executing" return statement.
@ 2024-03-19 17:59 d.van.raaij at gmail dot com
  2024-03-20 23:21 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of function returning limited type ebotcazou at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: d.van.raaij at gmail dot com @ 2024-03-19 17:59 UTC (permalink / raw)
  To: 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&action=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 = <error reading variable: Cannot access memory at address 0x17fffffff>

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

(rr) frame
#0  reproducer.pkg."+" (left=..., right=..., <OaddBIPalloc>=0,
<OaddBIPstoragepool>=0x0, <OaddBIPfinalizationmaster>=0x7fffc9c35df0,
<OaddBIPtaskmaster>=-909943160, <OaddBIPactivationchain>=0x7f1d6258d340
<ada.strings.pattern_error>,
    <OaddBIPaccess>=0x17fffffff) 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 ???
0xfffffffffffffffe

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 ???
0xfffffffffffffffe

*** 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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of function returning limited type
  2024-03-19 17:59 [Bug ada/114398] New: Unexpected storage error when "executing" return statement d.van.raaij at gmail dot com
@ 2024-03-20 23:21 ` ebotcazou at gcc dot gnu.org
  2024-03-20 23:22 ` ebotcazou at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-03-20 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
            Summary|Unexpected storage error in |[13/14 regression]
                   |return statement that       |Storage_Error with 'Access
                   |should return a limited     |of function returning
                   |controlled type.            |limited type
                 CC|                            |ebotcazou at gcc dot gnu.org
   Last reconfirmed|                            |2024-03-20

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
This does not compile on the mainline:

eric@localhost:~/Downloads> ~/install/gcc/bin/gcc -c reproducer.adb 
+===========================GNAT BUG DETECTED==============================+
| 14.0.1 20240311 (experimental) [master 1d193fb3484] (x86_64-suse-linux)  |
| Assert_Failure exp_attr.adb:2411                                         |
| Error detected at reproducer.adb:74:13                                   |
| Compiling reproducer.adb     

               pragma Assert
                 (Extra_Formals_Match_OK
                   (E => Entity (Pref), Ref_E => Btyp_DDT));

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of function returning limited type
  2024-03-19 17:59 [Bug ada/114398] New: Unexpected storage error when "executing" return statement d.van.raaij at gmail dot com
  2024-03-20 23:21 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of function returning limited type ebotcazou at gcc dot gnu.org
@ 2024-03-20 23:22 ` ebotcazou at gcc dot gnu.org
  2024-03-25 12:36 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of primitive " rguenth at gcc dot gnu.org
  2024-05-21  9:19 ` [Bug ada/114398] [13/14/15 " jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-03-20 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ebotcazou at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
I'm going to have a look.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of primitive function returning limited type
  2024-03-19 17:59 [Bug ada/114398] New: Unexpected storage error when "executing" return statement d.van.raaij at gmail dot com
  2024-03-20 23:21 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of function returning limited type ebotcazou at gcc dot gnu.org
  2024-03-20 23:22 ` ebotcazou at gcc dot gnu.org
@ 2024-03-25 12:36 ` rguenth at gcc dot gnu.org
  2024-05-21  9:19 ` [Bug ada/114398] [13/14/15 " jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-25 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.3
           Priority|P3                          |P4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/114398] [13/14/15 regression] Storage_Error with 'Access of primitive function returning limited type
  2024-03-19 17:59 [Bug ada/114398] New: Unexpected storage error when "executing" return statement d.van.raaij at gmail dot com
                   ` (2 preceding siblings ...)
  2024-03-25 12:36 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of primitive " rguenth at gcc dot gnu.org
@ 2024-05-21  9:19 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-05-21  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.3                        |13.4

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 13.3 is being released, retargeting bugs to GCC 13.4.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-21  9:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 17:59 [Bug ada/114398] New: Unexpected storage error when "executing" return statement d.van.raaij at gmail dot com
2024-03-20 23:21 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of function returning limited type ebotcazou at gcc dot gnu.org
2024-03-20 23:22 ` ebotcazou at gcc dot gnu.org
2024-03-25 12:36 ` [Bug ada/114398] [13/14 regression] Storage_Error with 'Access of primitive " rguenth at gcc dot gnu.org
2024-05-21  9:19 ` [Bug ada/114398] [13/14/15 " jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).