Bug 111393 - ICE: Segmentation fault src/gcc/toplev.cc:314
Summary: ICE: Segmentation fault src/gcc/toplev.cc:314
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 13.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-12 18:41 UTC by AK
Modified: 2023-09-15 07:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-09-12 00:00:00


Attachments
GlobalModuleIndex.cpp preprocessed files (528.92 KB, application/zip)
2023-09-12 22:03 UTC, AK
Details

Note You need to log in before you can comment on or make changes to this bug.
Description AK 2023-09-12 18:41:46 UTC
riscv64-gnu-linux (version Debian 13.1) building llvm-project (GlobalModuleIndex.cpp) crashed with ICE.

src/gcc/toplev.cc:314
profile_count::operator==(proile_count const&) const
     ../../src/gcc/profile-count.h:865
profile_count::apply_probability(proile_probability) const
     ../../src/gcc/profile-count.h:1104
Comment 1 AK 2023-09-12 18:44:29 UTC
oot/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/build# ninja clang check-clang
[100/845] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o
FAILED: tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_LIBCPP_ENABLE_HARDENED_MODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/build/tools/clang/lib/Serialization -I/media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/clang/lib/Serialization -I/media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/clang/include -I/media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/build/tools/clang/include -I/media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/build/include -I/media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o -MF tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o.d -o tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o -c /media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/clang/lib/Serialization/GlobalModuleIndex.cpp
In file included from /media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/llvm/include/llvm/ADT/DenseMapInfo.h:20,
                 from /media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/llvm/include/llvm/ADT/DenseMap.h:17,
                 from /media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/clang/include/clang/Serialization/GlobalModuleIndex.h:18,
                 from /media/root/d2fc9f48-c166-4a9e-9868-133a1db7af88/llvm-project/clang/lib/Serialization/GlobalModuleIndex.cpp:13:
/usr/include/c++/13/tuple: In instantiation of ‘struct std::_Tuple_impl<0, clang::ModuleFileExtensionReader*, std::default_delete<clang::ModuleFileExtensionReader> >’:
/usr/include/c++/13/tuple:1232:11:   required from ‘class std::tuple<clang::ModuleFileExtensionReader*, std::default_delete<clang::ModuleFileExtensionReader> >’
/usr/include/c++/13/bits/unique_ptr.h:232:27:   required from ‘class std::__uniq_ptr_impl<clang::ModuleFileExtensionReader, std::default_delete<clang::ModuleFileExtensionReader> >’
/usr/include/c++/13/bits/unique_ptr.h:239:12:   required from ‘struct std::__uniq_ptr_data<clang::ModuleFileExtensionReader, std::default_delete<clang::ModuleFileExtensionReader>, true, true>’
/usr/include/c++/13/bits/unique_ptr.h:283:33:   required from ‘class std::unique_ptr<clang::ModuleFileExtensionReader>’
/usr/include/c++/13/bits/stl_vector.h:367:35:   required from ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::unique_ptr<clang::ModuleFileExtensionReader>; _Alloc = std::allocator<std::unique_ptr<clang::ModuleFileExtensionReader> >]’
/usr/include/c++/13/bits/stl_vector.h:528:7:   required from here
/usr/include/c++/13/tuple:269:7: internal compiler error: Segmentation fault
  269 |       _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
      |       ^~~~~~~
0x85d7c5 crash_signal
	../../src/gcc/toplev.cc:314
0xa0d5e0 profile_count::operator==(profile_count const&) const
	../../src/gcc/profile-count.h:865
0xa0d5e0 profile_count::apply_probability(profile_probability) const
	../../src/gcc/profile-count.h:1104
0xa0d5e0 edge_def::count() const
	../../src/gcc/basic-block.h:639
0xa0d5e0 eliminate_tail_call
	../../src/gcc/tree-tailcall.cc:982
0xa0d5e0 optimize_tail_call
	../../src/gcc/tree-tailcall.cc:1053
0xa0d5e0 tree_optimize_tail_calls_1
	../../src/gcc/tree-tailcall.cc:1193
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-13/README.Bugs> for instructions.
Comment 2 Andrew Pinski 2023-09-12 19:00:34 UTC
Can you provide the preprocessed source?

Also provide the output of `gcc -v`?
Comment 3 AK 2023-09-12 21:34:10 UTC
gcc -v

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-linux-gnu/13/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 13.1.0-6' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=riscv64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=32
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.0 (Debian 13.1.0-6) 
root@lpi4a:/media/root/d2fc9f48-c166-4a9
Comment 4 Andrew Pinski 2023-09-12 21:42:08 UTC
Did you first report this to Debian also:
See <file:///usr/share/doc/gcc-13/README.Bugs> for instructions.
Comment 5 AK 2023-09-12 22:03:44 UTC
Created attachment 55890 [details]
GlobalModuleIndex.cpp preprocessed files

Everytime the crash is in a different file. it could be just because of memory issues.
Comment 6 Andrew Pinski 2023-09-12 22:07:11 UTC
(In reply to AK from comment #5)
> Created attachment 55890 [details]
> GlobalModuleIndex.cpp preprocessed files
> 
> Everytime the crash is in a different file. it could be just because of
> memory issues.

this does seem like a HW issue. Are you sure you have a decent RISCV machine without any memory issues?

I suspect ninja is building with all of the cores which pushes the memory usage high.

Maybe lower the clock speed of the CPU you are using.
Try with a cross compile also.
Comment 7 Richard Biener 2023-09-13 07:04:51 UTC
You might also want to update the compiler, GCC 13.1.0 is old, 13.2.0 exists for quite a while.
Comment 8 AK 2023-09-13 15:59:32 UTC
> this does seem like a HW issue. Are you sure you have a decent RISCV machine without any memory issues?
> I suspect ninja is building with all of the cores which pushes the memory usage high.

possible. I have the https://sipeed.com/licheepi4a (licheepi 4a board)


> Maybe lower the clock speed of the CPU you are using.

will do. thanks
Comment 9 AK 2023-09-14 18:55:51 UTC
i think it is okay to close this bug as this doesn't seem to be related to gcc.
Comment 10 Andrew Pinski 2023-09-14 19:03:47 UTC
Invalid as it is hw issue it seems
Comment 11 Xi Ruoyao 2023-09-15 07:33:14 UTC
Read https://www.bitwizard.nl/sig11/.

Though it was written for ancient 386 systems I find much of its points are still valid today for modern x86 or non-x86 systems.