https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105663
Bug ID: 105663
Summary: Segmentation Fault on optimization level O2/O3
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: r.j.dejong at student dot utwente.nl
Target Milestone: ---
Created attachment 53000
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53000&action=edit
source.c
Source file of STM32U5 HAL library fails to compile on arm-none-eabi-gcc 12.1.0
with optimization levels O2 or O3. Command used to reproduce: arm-none-eabi-gcc
-O2 -c source.c -o foo .
The error also occurs for x86-64 GCC. Using godbolt.org compiler explorer, I
found that the minimum GCC version is 11.1 for this segfault to occur.
Preprocessed source code is attached (file source.c). The backtrace is:
> arm-none-eabi-gcc -O2 -c source.c -o foo
during GIMPLE pass: evrp
./stm32u5xx_hal_dma_ex.c: In function 'HAL_DMAEx_List_ReplaceNode_Head':
./stm32u5xx_hal_dma_ex.c:4689:1: internal compiler error: Segmentation fault
4689 | }
| ^
0x165320d internal_error(char const*, ...)
???:0
0x158bc83 operator_bitwise_not::fold_range(irange&, tree_node*, irange const&,
irange const&, tree_code) const
???:0
0x149a439 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
???:0
0x149bfcb fold_using_range::fold_stmt(irange&, gimple*, fur_source&,
tree_node*)
???:0
0x1490448 gimple_ranger::range_of_stmt(irange&, gimple*, tree_node*)
???:0
0x1490d43 gimple_ranger::range_of_expr(irange&, tree_node*, gimple*)
???:0
0xe3f061 range_query::value_of_expr(tree_node*, gimple*)
???:0
0xe1f5d6 rvrp_folder::value_of_expr(tree_node*, gimple*)
???:0
0xd30f2e substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
???:0
0x1462b37 dom_walker::walk(basic_block_def*)
???:0
0xd301fd substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
???:0
0xe15b7a execute_ranger_vrp(function*, bool)
???:0
Version information:
> arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arch Repository) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> gcc --version
gcc (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
OS information:
> lsb_release -a
LSB Version: n/a
Distributor ID: ManjaroLinux
Description: Manjaro Linux
Release: 21.2.6
Codename: Qonos
--------------
My attempts to localize the offending source code were not very successful.
Although the error suggests something is wrong with
HAL_DMAEx_List_InsertNode_Head, if that function is removed the segfault jumps
to another function (with varying backtraces). By some trial and error I was
able to minimize the LOC to be removed to the function
DMA_List_CheckNodesBaseAddresses, lines 11827 till 11844. When these are
commented out, the segfault disappears. However, solely that function does not
seem to be responsible for the error, so I am unsure how useful this
information is for chasing a moving target, so therefore I included the
complete file.