https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86636

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this.

Segfault happens here in optrecord_json_writer::location_to_json:

206       obj->set ("file", new json::string (LOCATION_FILE (loc)));

due to a NULL value for LOCATION_FILE (loc).

(gdb) call inform (loc, "")
/tmp/test.c: In function ‘n2._loopfn.0’:
cc1: note: 

(gdb) p /x loc
$2 = 0x80000007

(gdb) p line_table->location_adhoc_data_map.data[7]
$3 = {locus = 0, src_range = {m_start = 0, m_finish = 0}, data =
0x7ffff19ebb40}

which is UNKNOWN_LOCATION wrapped with adhoc data.

Fix appears to be to update this conditional to look through ad-hoc data
wrappers:

386                 if (item->get_location () != UNKNOWN_LOCATION)
387                   json_item->set ("location", location_to_json
(item->get_location ()));

Reply via email to