Bug 111076 - RISC-V: segmentation fault during RTL pass: shorten (debug build)
Summary: RISC-V: segmentation fault during RTL pass: shorten (debug build)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 13.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-19 16:53 UTC by Maksim Shabunin
Modified: 2024-02-22 15:44 UTC (History)
1 user (show)

See Also:
Host:
Target: riscv64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed source file (310.17 KB, application/zip)
2023-08-19 16:53 UTC, Maksim Shabunin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maksim Shabunin 2023-08-19 16:53:37 UTC
Created attachment 55765 [details]
Preprocessed source file

We are experiencing an issue when building the OpenCV library for RISC-V with RVV support in DEBUG configuration using GCC 13.2.1:

    /work/chains/riscv-gcc-13.2.1/bin/riscv64-unknown-linux-gnu-g++ --sysroot=/work/chains/riscv-gcc-13.2.1/sysroot -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/work/opencv/modules/core/include -I/work/build-opencv-rvv/modules/core -I/work/opencv/3rdparty/zlib -I/work/build-opencv-rvv/3rdparty/zlib -isystem /work/build-opencv-rvv -march=rv64gc  -fmax-errors=1 -Wfatal-errors -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -march=rv64gcv1p0 -DCV_RVV_SCALABLE -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG -fPIC -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core.dir/src/count_non_zero.dispatch.cpp.o -MF modules/core/CMakeFiles/opencv_core.dir/src/count_non_zero.dispatch.cpp.o.d -o modules/core/CMakeFiles/opencv_core.dir/src/count_non_zero.dispatch.cpp.o -c /work/opencv/modules/core/src/count_non_zero.dispatch.cpp -freport-bug
    
    <... several -Wsign-compare warnings ...>
    
    during RTL pass: shorten
    In file included from /work/opencv/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp:146:
    /work/opencv/modules/core/include/opencv2/core/hal/intrin_rvv_compat_overloaded.hpp: In function 'cv::hal_baseline::VTraits<__rvv_uint64m1_t>::lane_type cv::hal_baseline::__riscv_vmv_x(const v_uint64&)':
    /work/opencv/modules/core/include/opencv2/core/hal/intrin_rvv_compat_overloaded.hpp:154:1: internal compiler error: Segmentation fault
      154 | }
          | ^
    /work/opencv/modules/core/include/opencv2/core/hal/intrin_rvv_compat_overloaded.hpp:167:1: note: in expansion of macro 'OPENCV_HAL_IMPL_RVV_FUN_EXTRACT'
      167 | OPENCV_HAL_IMPL_RVV_FUN_EXTRACT(v_uint64, u64)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    0xe038c3 crash_signal
    	../.././gcc/gcc/toplev.cc:314
    0x7f445264251f ???
    	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
    0x16038c4 const_csr_operand(rtx_def*, machine_mode)
    	../.././gcc/gcc/config/riscv/predicates.md:44
    0x16038c4 csr_operand(rtx_def*, machine_mode)
    	../.././gcc/gcc/config/riscv/predicates.md:46
    0x166e88d recog_157
    	../.././gcc/gcc/config/riscv/iterators.md:72
    0x167c247 recog(rtx_def*, rtx_insn*, int*)
    	../.././gcc/gcc/config/riscv/iterators.md:58
    0x147f00d recog_memoized(rtx_insn*)
    	../.././gcc/gcc/recog.h:273
    0x147f00d insn_default_length(rtx_insn*)
    	../.././gcc/gcc/config/riscv/riscv.md:451
    0xac4ea5 shorten_branches(rtx_insn*)
    	../.././gcc/gcc/final.cc:1088
    0xac4ef3 rest_of_handle_shorten_branches
    	../.././gcc/gcc/final.cc:4336
    0xac4ef3 execute
    	../.././gcc/gcc/final.cc:4365
    Please submit a full bug report, with preprocessed source.
    Please include the complete backtrace with any bug report.
    See <https://gcc.gnu.org/bugs/> for instructions.
    The bug is not reproducible, so it is likely a hardware or OS problem.

* Version: riscv64-unknown-linux-gnu-g++ (g91a5bdf2941) 13.2.1 20230818
* Preprocessed source file attached.
* The same library version (latest commit on 4.x branch) can be built in Release mode without issues.
Comment 1 xuli1@eswincomputing.com 2023-08-28 02:58:06 UTC

This issue has been resolved.
https://github.com/gcc-mirror/gcc/commit/9f8d1d448e6c10fbad3bb41f4d7322fac8df4cd0
Comment 2 Maksim Shabunin 2024-02-22 15:44:03 UTC
Verified with version riscv64-unknown-linux-gnu-g++ (g128d9cc0599) 13.2.1 20240220 (branch releases/gcc-13).