https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109806
Sam James <sjames at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at gcc dot gnu.org See Also| |https://bugs.gentoo.org/sho | |w_bug.cgi?id=906380 --- Comment #12 from Sam James <sjames at gcc dot gnu.org> --- I think I'm hitting this on musl too. Reported in Gentoo at https://bugs.gentoo.org/906380. For me, this crashes on x86_64-gentoo-linux-musl: ``` struct SimpleRefCounted { virtual void addRef(); }; struct timespec { long tv_nsec; int : 0; }; struct ClockImpl : SimpleRefCounted { timespec _startTime; }; struct Clock { Clock(); }; Clock::Clock() { ClockImpl(); } ``` with: ``` # g++ /tmp/foo.cxx -O2 -wrapper valgrind ==1239523== Memcheck, a memory error detector ==1239523== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==1239523== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info ==1239523== Command: /usr/libexec/gcc/x86_64-gentoo-linux-musl/13/cc1plus -quiet -D_GNU_SOURCE /tmp/foo.cxx -quiet -dumpdir a- -dumpbase foo.cxx -dumpbase-ext .cxx -mtune=generic -march=x86-64 -O2 -fcf-protection -o /tmp/ccigHfiN.s ==1239523== ==1239523== Invalid read of size 1 ==1239523== at 0x97844C: to_wide (tree.h:6257) ==1239523== by 0x97844C: irange::set_varying(tree_node*) (value-range.h:959) ==1239523== by 0x10C1A45: range_query::get_tree_range(vrange&, tree_node*, gimple*) (value-query.cc:252) ==1239523== by 0x1B52256: gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*) (gimple-range.cc:298) ==1239523== by 0x1B52778: gimple_ranger::register_inferred_ranges(gimple*) (gimple-range.cc:474) ==1239523== by 0x109FB19: rvrp_folder::fold_stmt(gimple_stmt_iterator*) (tree-vrp.cc:1079) ==1239523== by 0xFA9ED3: substitute_and_fold_dom_walker::before_dom_children(basic_block_def*) (tree-ssa-propagate.cc:848) ==1239523== by 0x1B24C2E: dom_walker::walk(basic_block_def*) (domwalk.cc:311) ==1239523== by 0xFA9312: substitute_and_fold_engine::substitute_and_fold(basic_block_def*) (tree-ssa-propagate.cc:971) ==1239523== by 0x109DB80: execute_ranger_vrp(function*, bool, bool) (tree-vrp.cc:1107) ==1239523== by 0xD3A0EA: execute_one_pass(opt_pass*) (passes.cc:2651) ==1239523== by 0xD3A9AF: execute_pass_list_1(opt_pass*) (passes.cc:2760) ==1239523== by 0xD3A9C1: execute_pass_list_1(opt_pass*) (passes.cc:2761) ==1239523== Address 0x4 is not stack'd, malloc'd or (recently) free'd ==1239523== during GIMPLE pass: evrp /tmp/foo.cxx: In constructor 'Clock::Clock()': /tmp/foo.cxx:14:31: internal compiler error: Segmentation fault 14 | Clock::Clock() { ClockImpl(); } | ^ 0xe10df3 crash_signal /usr/src/debug/sys-devel/gcc-13.1.1_p20230513/gcc-13-20230513/gcc/toplev.cc:314 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. ``` (Obviously crashes w/o valgrind too, just the output is way less helpful.) Note that musl has a small default stack size, as I mentioned at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109695#c18.