public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/110510] New: ggc infinite recursion
@ 2023-07-01 11:36 franckbehaghel_gcc at protonmail dot com
  2023-07-01 17:34 ` [Bug middle-end/110510] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: franckbehaghel_gcc at protonmail dot com @ 2023-07-01 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110510
           Summary: ggc infinite recursion
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: franckbehaghel_gcc at protonmail dot com
  Target Milestone: ---

Created attachment 55444
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55444&action=edit
source

Hello,

The attached ada source file fails to build. I got the following result:

$ gcc -c  failed_ggc.adb
failed_ggc.adb:3:11: warning: file name does not match unit name, should be
"main.adb" [enabled by default]

raised STORAGE_ERROR : stack overflow or erroneous memory access


Looking into this with gdb, it gaves me more detailed information :


$ gcc -c  -wrapper gdb,--args failed_ggc.adb

[...]
Program received signal SIGSEGV, Segmentation fault.
0x00000000010592c3 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0410) at
gtype-desc.cc:3582
3582          gt_ggc_m_7rtx_def ((*x).landing_pad);
[...]


backtrace output looks like a infinite recursion :

(gdb) bt
#0  0x00000000010592c3 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0410) at
gtype-desc.cc:3582
#1  gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0438) at gtype-desc.cc:3579
#2  0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0438) at
gtype-desc.cc:3582
#3  gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0460) at gtype-desc.cc:3579
#4  0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0460) at
gtype-desc.cc:3582
#5  gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0488) at gtype-desc.cc:3579
#6  0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0488) at
gtype-desc.cc:3582
#7  gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e04b0) at gtype-desc.cc:3579
#8  0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e04b0) at
gtype-desc.cc:3582
#9  gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e04d8) at gtype-desc.cc:3579
#10 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e04d8) at
gtype-desc.cc:3582
#11 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0500) at gtype-desc.cc:3579
#12 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0500) at
gtype-desc.cc:3582
#13 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0528) at gtype-desc.cc:3579
#14 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0528) at
gtype-desc.cc:3582
#15 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0550) at gtype-desc.cc:3579
#16 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0550) at
gtype-desc.cc:3582
#17 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0578) at gtype-desc.cc:3579
#18 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e0578) at
gtype-desc.cc:3582
#19 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e05a0) at gtype-desc.cc:3579
#20 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e05a0) at
gtype-desc.cc:3582
#21 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffd26e05c8) at gtype-desc.cc:3579


(gdb) bt -50
#4193802 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638c80)
at gtype-desc.cc:3582
#4193803 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638ca8) at gtype-desc.cc:3579
#4193804 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638ca8)
at gtype-desc.cc:3582
#4193805 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638cd0) at gtype-desc.cc:3579
#4193806 0x00000000010592d4 in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638cd0)
at gtype-desc.cc:3582
#4193807 gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638cf8) at gtype-desc.cc:3579
#4193808 0x000000000105939c in gt_ggc_mx_eh_landing_pad_d (x_p=0x7fffca638cf8)
at gtype-desc.cc:3577
#4193809 gt_ggc_mx_eh_region_d (x_p=0x7fffd9141738) at gtype-desc.cc:3567
#4193810 0x00000000010593f0 in gt_ggc_mx_eh_region_d (x_p=0x7fffd9141738) at
gtype-desc.cc:3562
#4193811 gt_ggc_mx_eh_region_d (x_p=0x7fffd91416e0) at gtype-desc.cc:3549
#4193812 0x000000000105a0d0 in gt_ggc_mx_eh_region_d (x_p=0x7fffd91416e0) at
gtype-desc.cc:3614
#4193813 gt_ggc_mx_eh_status (x_p=0x7fffea7522d0) at gtype-desc.cc:2259
#4193814 0x000000000105cefe in gt_ggc_mx_function (x_p=0x7fffe94610b8) at
gtype-desc.cc:1720
#4193815 gt_ggc_mx_function (x_p=0x7fffe94610b8) at gtype-desc.cc:1715
#4193816 0x0000000000a1fc2a in gt_ggc_mx_lang_tree_node (x_p=<optimized out>)
at ./gtype-ada.h:288
#4193817 0x0000000000a1fb87 in gt_ggc_mx_lang_tree_node (x_p=<optimized out>)
at ./gtype-ada.h:277
#4193818 0x0000000000a1f158 in gt_ggc_mx_lang_tree_node (x_p=<optimized out>)
at ./gtype-ada.h:191
#4193819 0x0000000000a1f5be in gt_ggc_mx_lang_tree_node (x_p=<optimized out>)
at ./gtype-ada.h:420
#4193820 0x0000000001059cdf in gt_ggc_mx_gimple (x_p=<optimized out>) at
gtype-desc.cc:1254
#4193821 0x000000000105afba in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1422
#4193822 0x000000000105af9e in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1420
#4193823 0x000000000105af9e in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1420
#4193824 0x000000000105af9e in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1420
#4193825 0x000000000105af9e in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1420
#4193826 0x000000000105af9e in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1420
#4193827 0x000000000105af9e in gt_ggc_mx_cgraph_edge (x_p=<optimized out>) at
gtype-desc.cc:1420
#4193828 0x000000000105ade7 in gt_ggc_mx_symtab_node (x_p=<optimized out>) at
gtype-desc.cc:1368
#4193829 0x0000000000a1f1dd in gt_ggc_mx_lang_tree_node (x_p=<optimized out>)
at ./gtype-ada.h:200
#4193830 0x0000000001057d1a in gt_ggc_mx_rtx_def (x_p=<optimized out>) at
gtype-desc.cc:732
#4193831 0x0000000001059724 in gt_ggc_mx (x=@0x7fffd57c66b8: 0x7fffdaab8810) at
gtype-desc.cc:1701
#4193832 gt_ggc_mx<rtx_def*> (v=<optimized out>) at
/DATA/git/gcc/gcc/gcc/vec.h:1370
#4193833 gt_ggc_mx_vec_rtx_va_gc_ (x_p=0x7fffd57c6000) at gtype-desc.cc:1693
#4193834 gt_ggc_mx_vec_rtx_va_gc_ (x_p=0x7fffd57c6000) at gtype-desc.cc:1688
#4193835 0x0000000000fca426 in ggc_mark_root_tab (rt=<optimized out>) at
/DATA/git/gcc/gcc/gcc/ggc-common.cc:75
#4193836 0x0000000000fca75d in ggc_mark_roots () at
/DATA/git/gcc/gcc/gcc/ggc-common.cc:92
#4193837 0x0000000000decd62 in ggc_collect (mode=GGC_COLLECT_HEURISTIC) at
/DATA/git/gcc/gcc/gcc/ggc-page.cc:2227
#4193838 0x000000000121d947 in execute_one_pass (pass=0x367f170) at
/DATA/git/gcc/gcc/gcc/passes.cc:2743
#4193839 0x000000000121da70 in execute_pass_list_1 (pass=0x367f170) at
/DATA/git/gcc/gcc/gcc/passes.cc:2760
#4193840 0x000000000121da82 in execute_pass_list_1 (pass=0x367de90) at
/DATA/git/gcc/gcc/gcc/passes.cc:2761
#4193841 0x000000000121daa9 in execute_pass_list (fn=0x7fffe94610b8,
pass=<optimized out>) at /DATA/git/gcc/gcc/gcc/passes.cc:2771
#4193842 0x0000000000e78d86 in cgraph_node::expand (this=0x7fffdf8b3990) at
/DATA/git/gcc/gcc/gcc/context.h:48
#4193843 cgraph_node::expand (this=0x7fffdf8b3990) at
/DATA/git/gcc/gcc/gcc/cgraphunit.cc:1794
#4193844 0x0000000000e79f0a in output_in_order () at
/DATA/git/gcc/gcc/gcc/cgraphunit.cc:2191
#4193845 symbol_table::compile (this=0x7fffea68d000) at
/DATA/git/gcc/gcc/gcc/cgraphunit.cc:2395
#4193846 0x0000000000e7cb58 in symbol_table::compile (this=<error reading
variable: dwarf2_find_location_expression: Corrupted DWARF expression.>)
    at /DATA/git/gcc/gcc/gcc/cgraphunit.cc:2583
#4193847 symbol_table::finalize_compilation_unit (this=0x7fffea68d000) at
/DATA/git/gcc/gcc/gcc/cgraphunit.cc:2583
#4193848 0x0000000001323ce2 in compile_file () at
/DATA/git/gcc/gcc/gcc/toplev.cc:471
#4193849 0x00000000009d20ca in do_compile (no_backend=false) at
/DATA/git/gcc/gcc/gcc/toplev.cc:2126



Version 13.1 is fine.
Version 14 until b106f11dc6adb8df15cc5c268896d314c76ca35f "c++: Accept
elaborated-enum-base with pedwarn" is fine.
Version 14 starting from 154c69039571c66b3a6d16ecfa9e6ff22942f59f "RA: Ignore
conflicts for some pseudos from insns throwing a final exception" are affected
by this crash.

Compiler Explorer on trunk is affected too. (https://godbolt.org/) 
gcc -c -I/app/ -g -fdiagnostics-color=always -S -fverbose-asm -masm=intel -o
/app/example.s -I- <source>
gnatmake: "<source>" compilation error
example.adb:3:11: warning: file name does not match unit name, should be
"main.adb" [enabled by default]

raised STORAGE_ERROR : stack overflow or erroneous memory access
Compiler returned: 4


Latent bug or side effect excluded, I would say that gcc-14-1891-g154c6903957
is the change to blame.
I cannot understand just one word of this change. But some skilled gcc
maintainers may.


Best regards,
Franck

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

* [Bug middle-end/110510] ggc infinite recursion
  2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
@ 2023-07-01 17:34 ` pinskia at gcc dot gnu.org
  2023-07-01 17:41 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-01 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It does not look like an infinite recursion but rather the chain of
eh_landing_pad_d is not mentioned to the GC so it does not do an inline-tail
call. 

This might fix the issue:
diff --git a/gcc/except.h b/gcc/except.h
index 378a9e4cb77..087d0004c6d 100644
--- a/gcc/except.h
+++ b/gcc/except.h
@@ -66,7 +66,7 @@ enum eh_region_type
 /* A landing pad for a given exception region.  Any transfer of control
    from the EH runtime to the function happens at a landing pad.  */

-struct GTY(()) eh_landing_pad_d
+struct GTY((chain_next(%h.next_lp))) eh_landing_pad_d
 {
   /* The linked list of all landing pads associated with the region.  */
   struct eh_landing_pad_d *next_lp;

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

* [Bug middle-end/110510] ggc infinite recursion
  2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
  2023-07-01 17:34 ` [Bug middle-end/110510] " pinskia at gcc dot gnu.org
@ 2023-07-01 17:41 ` pinskia at gcc dot gnu.org
  2023-07-01 18:01 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-01 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>+struct GTY((chain_next(%h.next_lp))) eh_landing_pad_d

Should have been:
+struct GTY((chain_next("%h.next_lp"))) eh_landing_pad_d

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

* [Bug middle-end/110510] ggc infinite recursion
  2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
  2023-07-01 17:34 ` [Bug middle-end/110510] " pinskia at gcc dot gnu.org
  2023-07-01 17:41 ` pinskia at gcc dot gnu.org
@ 2023-07-01 18:01 ` pinskia at gcc dot gnu.org
  2023-07-02 12:29 ` franckbehaghel_gcc at protonmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-01 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-07-01
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55445
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55445&action=edit
Patch to try

Can you try this patch? I am doing a full bootstrap/test right now.

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

* [Bug middle-end/110510] ggc infinite recursion
  2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
                   ` (2 preceding siblings ...)
  2023-07-01 18:01 ` pinskia at gcc dot gnu.org
@ 2023-07-02 12:29 ` franckbehaghel_gcc at protonmail dot com
  2023-07-03 21:45 ` cvs-commit at gcc dot gnu.org
  2023-07-03 21:46 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: franckbehaghel_gcc at protonmail dot com @ 2023-07-02 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Franck Behaghel <franckbehaghel_gcc at protonmail dot com> ---
Andrew,thanks.
Impressive !
Tested. Indeed, this patch fixes the issue.

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

* [Bug middle-end/110510] ggc infinite recursion
  2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
                   ` (3 preceding siblings ...)
  2023-07-02 12:29 ` franckbehaghel_gcc at protonmail dot com
@ 2023-07-03 21:45 ` cvs-commit at gcc dot gnu.org
  2023-07-03 21:46 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-03 21:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:d0a333612bfb7faf8d61210c831165388e758768

commit r14-2270-gd0a333612bfb7faf8d61210c831165388e758768
Author: Andrew Pinski <apinski@marvell.com>
Date:   Sat Jul 1 10:52:48 2023 -0700

    Use chain_next on eh_landing_pad_d for GTY (PR middle-end/110510)

    The backtrace in the bug report suggest there is a running out of
    stack during GC collection, because of a long chain of eh_landing_pad_d.
    This might fix that by adding chain_next onto eh_landing_pad_d's GTY
marker.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    gcc/ChangeLog:

            PR middle-end/110510
            * except.h (struct eh_landing_pad_d): Add chain_next GTY.

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

* [Bug middle-end/110510] ggc infinite recursion
  2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
                   ` (4 preceding siblings ...)
  2023-07-03 21:45 ` cvs-commit at gcc dot gnu.org
@ 2023-07-03 21:46 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-03 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed. Thanks for reporting this.

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

end of thread, other threads:[~2023-07-03 21:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-01 11:36 [Bug middle-end/110510] New: ggc infinite recursion franckbehaghel_gcc at protonmail dot com
2023-07-01 17:34 ` [Bug middle-end/110510] " pinskia at gcc dot gnu.org
2023-07-01 17:41 ` pinskia at gcc dot gnu.org
2023-07-01 18:01 ` pinskia at gcc dot gnu.org
2023-07-02 12:29 ` franckbehaghel_gcc at protonmail dot com
2023-07-03 21:45 ` cvs-commit at gcc dot gnu.org
2023-07-03 21:46 ` pinskia 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).