[Bug plugins/62252] a callback to event PLUGIN_FINISH_TYPE segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62252 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement
[Bug plugins/62252] a callback to event PLUGIN_FINISH_TYPE segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62252 klemen.jan.enova at gmail dot com changed: What|Removed |Added CC||klemen.jan.enova at gmail dot com --- Comment #4 from klemen.jan.enova at gmail dot com --- Created attachment 33391 -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33391action=edit cp-parser-patch Fixes the bug. If I use debug_tree(type) in handle_struct(), it prints a RECORD_TYPE only once, because the type declaration and definition happens only once, other uses of the identifier struct S are variable declarations.
[Bug plugins/62252] a callback to event PLUGIN_FINISH_TYPE segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62252 --- Comment #5 from klemen.jan.enova at gmail dot com --- The build passed make check, but I said invoke_plugin_callback() should be before cp_parser_set_decl_spec_type(), so I will try that way too.
[Bug plugins/62252] a callback to event PLUGIN_FINISH_TYPE segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62252 Manuel López-Ibáñez manu at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2014-08-24 CC||manu at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Manuel López-Ibáñez manu at gcc dot gnu.org --- It seems it is your plugin crashing. Have you tried debugging why it crashes? 0x7f520d010780 handle_struct(void*, void*) /home/kje/example/example.c:20 0x8fb0b9 invoke_plugin_callbacks_full(int, void*)
[Bug plugins/62252] a callback to event PLUGIN_FINISH_TYPE segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62252 --- Comment #2 from klemen.jan.enova at gmail dot com --- TREE_CODE(type) returns an ERROR_MARK. So, (tree) event_data must not alias with a tree. This plugin is from https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/g%2B%2B.dg/plugin/dumb_plugin.c. There are no checks there, it just assumes it is a type represented as a tree.
[Bug plugins/62252] a callback to event PLUGIN_FINISH_TYPE segfaults
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62252 --- Comment #3 from klemen.jan.enova at gmail dot com --- It works on gcc, though. in gcc/c/c-parser.c: if (!typespec_ok) goto out; invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, t.spec); declspecs_add_type (loc, specs, t); in gcc/cp/parser.c: type_spec = cp_parser_class_specifier (parser); invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, type_spec); /* If that worked, we're done. */ if (cp_parser_parse_definitely (parser)) { if (declares_class_or_enum) *declares_class_or_enum = 2; if (decl_specs) cp_parser_set_decl_spec_type (decl_specs, type_spec, token, /*type_definition_p=*/true); return type_spec; } I see a pattern. The call to invoke_plugin_callbacks() should probably be before something_that_adds_the_type_to_decl_spec(). Also, there is a test in both cases (typespec_ok VS cp_parser_parse_definitely). I will try to compile gcc with this patch, and see what comes out.