https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123368
Bug ID: 123368
Summary: ICE: Segmentation fault in lower_nested_functions /
mark_addressable with multiple nested functions and
section attribute
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
It is only reproducible with the optimization flag.
Reproducer: https://godbolt.org/z/be7vcozhW
The ICE occurs during the lowering of nested functions. When multiple nested
functions are present (e.g., both g() and h()), the compiler is forced to
construct a formal frame structure and a call graph for the parent function.
Program:
```c
void outer() {
void __attribute__((section(".text"))) g() {}
g();
void h() {}
}
```
Part of the traceback:
```
internal compiler error: Segmentation fault
7 | void outer() {
| ^~~~~
0x569ce3c internal_error(char const*, ...)
/workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:517
0x204477c crash_signal
/workspace/install/gcc/src/gcc/gcc/toplev.cc:322
0x7ffff79d932f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x172949c mark_addressable(tree_node*)
/workspace/install/gcc/src/gcc/gcc/gimple-expr.cc:950
0x2210ac3 build_addr(tree_node*)
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:286
0x2215316 get_static_chain
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:1000
0x22216f5 convert_gimple_call
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:3007
0x17d8642 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
/workspace/install/gcc/src/gcc/gcc/gimple-walk.cc:618
0x17d57b4 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
/workspace/install/gcc/src/gcc/gcc/gimple-walk.cc:51
0x17d88c1 walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
/workspace/install/gcc/src/gcc/gcc/gimple-walk.cc:645
0x17d57b4 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
/workspace/install/gcc/src/gcc/gcc/gimple-walk.cc:51
0x221452b walk_body
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:820
0x22145c7 walk_function
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:831
0x2222ae5 convert_all_function_calls
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:3190
0x222721d lower_nested_functions(tree_node*)
/workspace/install/gcc/src/gcc/gcc/tree-nested.cc:3859
0x135ab3d cgraph_node::analyze()
/workspace/install/gcc/src/gcc/gcc/cgraphunit.cc:695
0x135ece9 analyze_functions
/workspace/install/gcc/src/gcc/gcc/cgraphunit.cc:1265
0x13652a7 symbol_table::finalize_compilation_unit()
/workspace/install/gcc/src/gcc/gcc/cgraphunit.cc:2574
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```