https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115635
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #1)
> "make selftest-valgrind" is clean for me. Note that if you can reproducer
> this standalone, "make selftest-gdb" is a handy way to run the selftests
> under the debugger.
Thanks, this is helpful. I can reproduce it consistently when running gcc
manually once the PM has built it, but not yet managed to reproduce with a
manual build yet.
>
> FWIW, the output suggests that the assertion at line 1153 is failing:
>
> 1147 /* Verify that empty paths are handled gracefully. */
> 1148
> 1149 static void
> 1150 test_empty_path (pretty_printer *event_pp)
> 1151 {
> 1152 test_diagnostic_path path (event_pp);
> ->1153 ASSERT_FALSE (path.interprocedural_p ());
> 1154
>
> "path" is empty i.e. num_events ought to be returning 0.
>
> Hence I'd expect diagnostic_path::interprocedural_p:
>
> 184 bool
> 185 diagnostic_path::interprocedural_p () const
> 186 {
> 187 /* Ignore leading events that are outside of any function. */
> 188 unsigned first_fn_event_idx;
> 189 if (!get_first_event_in_a_function (&first_fn_event_idx))
> 190 return false;
>
> to call get_first_event_in_a_function, and for that to get 0 for "num", and
> thus bail out with num == 0 again, never entering the loop here:
>
OK, I set a breakpoint for interprocedural_p, and I hit it immediately:
(gdb) n
189 if (!get_first_event_in_a_function (&first_fn_event_idx))
(gdb) p first_fn_event_idx
$8 = 0
First, we don't know num:
(gdb) s
diagnostic_path::get_first_event_in_a_function (this=this@entry=0x7fffffffd078,
out_idx=out_idx@entry=0x7fffffffd014)
at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/diagnostic-path.cc:167
167 const unsigned num = num_events ();
(gdb) p num
$9 = <optimized out>
Stepping a handful of times, we get to the for loop for the first time:
(gdb) s
diagnostic_path::get_first_event_in_a_function (this=this@entry=0x7fffffffd078,
out_idx=out_idx@entry=0x7fffffffd014)
at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/diagnostic-path.cc:168
168 for (unsigned i = 0; i < num; i++)
(gdb) p num
$11 = 0
(gdb) bt
#0 diagnostic_path::get_first_event_in_a_function
(this=this@entry=0x7fffffffd078, out_idx=out_idx@entry=0x7fffffffd014)
at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/diagnostic-path.cc:168
#1 0x0000555556ebc723 in diagnostic_path::interprocedural_p
(this=this@entry=0x7fffffffd078) at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/diagnostic-path.cc:189
#2 0x0000555556ee1bf3 in selftest::test_empty_path
(event_pp=event_pp@entry=0x5555587648f0) at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/diagnostic-path.cc:1153
#3 0x0000555556ee2804 in selftest::diagnostic_path_cc_tests () at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/diagnostic-path.cc:2379
#4 0x0000555556e8584c in selftest::run_tests () at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/selftest-run-tests.cc:105
#5 0x000055555675cb73 in toplev::run_self_tests (this=<optimized out>) at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/toplev.cc:2223
#6 0x00005555577b0009 in toplev::main (this=this@entry=0x7fffffffd416,
argc=<optimized out>, argv=<optimized out>)
at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/toplev.cc:2327
#7 0x00005555577ae5ee in main (argc=<optimized out>, argv=<optimized out>) at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/main.cc:39
(gdb)
(gdb) s
selftest::test_empty_path (event_pp=event_pp@entry=0x5555587648f0) at
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/selftest.h:38
38 location (const char *file, int line, const char *function)
(gdb) s
1153 ASSERT_FALSE (path.interprocedural_p ());
(gdb)
(gdb) p path
$13 = {<diagnostic_path> = {_vptr.diagnostic_path = 0x5555584b5cc0 <vtable for
selftest::test_diagnostic_path+16>},
m_threads = {<auto_vec<selftest::test_diagnostic_thread*, 0>> =
{<vec<selftest::test_diagnostic_thread*, va_heap, vl_ptr>> = {
m_vec = 0x555558840780}, <No data fields>}, <No data fields>},
m_events = {<auto_vec<selftest::test_diagnostic_event*, 0>> =
{<vec<selftest::test_diagnostic_event*, va_heap, vl_ptr>> = {m_vec = 0x0}, <No
data fields>}, <No data fields>},
m_event_pp = 0x5555587648f0}