> I've find out that compiler may crash with SEGFAULT on some openmp-enabled > code (attached as debug-1.c) called with the following flags: > -g -fopenmp -gdwarf-2 -femit-struct-debug-reduced > Also, can be reproduced with -femit-struct-debug-baseonly > > The problem is in dwarf2out.c:350:should_emit_struct_debug() at this line: > 366 type_decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (type)); > > In some cases type_decl can be NULL and this causes ICE in the following code: > 368 if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER > (type_decl)) > 369 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true); > 370 > 371 if (matches_main_base (DECL_SOURCE_FILE (type_decl))) > 372 return DUMP_GSTRUCT (type, usage, criterion, generic, true, true); > > Can be fixed with checking for type_decl is not NULL. > > I've attached patch to fix this. Could you check, is it ok?
The patch looks OK to me. Do you have a copyright assignment on file with FSF? For a patch this size, I don't think you need one, but I'd appreciate confirmation from the more legally-inclined (Danny, Ian?). Do you need someone to commit it for you? > This is very straightforward fix, can the problem be in incorrect debug info > generation on early stages? Sorry, I'm not sure what you're asking here. -cary