public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug pch/65550] [4.8/4.9/5 Regression] ICE (segfault) with pch Date: Tue, 07 Apr 2015 10:55:00 -0000 [thread overview] Message-ID: <bug-65550-4-sIpEoGhGqr@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-65550-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65550 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-valid-code |ice-on-invalid-code Priority|P3 |P2 CC| |jsm28 at gcc dot gnu.org, | |sje at gcc dot gnu.org Known to work|4.9.2 |4.7.4 Target Milestone|5.0 |4.8.5 Summary|[5 Regression] ICE |[4.8/4.9/5 Regression] ICE |(segfault) with pch |(segfault) with pch Known to fail| |4.8.3, 4.9.2 --- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. 0xfb7742 crash_signal /space/rguenther/src/svn/trunk2/gcc/toplev.c:383 0x197315c linemap_add(line_maps*, lc_reason, unsigned int, char const*, unsigned int) /space/rguenther/src/svn/trunk2/libcpp/line-map.c:303 0x1973b1e linemap_line_start(line_maps*, unsigned int, unsigned int) /space/rguenther/src/svn/trunk2/libcpp/line-map.c:566 0x1973d55 linemap_position_for_column(line_maps*, unsigned int) /space/rguenther/src/svn/trunk2/libcpp/line-map.c:611 0x1970744 _cpp_lex_direct /space/rguenther/src/svn/trunk2/libcpp/lex.c:2340 0x197029a _cpp_lex_token /space/rguenther/src/svn/trunk2/libcpp/lex.c:2176 0x197996f cpp_get_token_1 /space/rguenther/src/svn/trunk2/libcpp/macro.c:2442 0x1979db7 cpp_get_token_with_location(cpp_reader*, unsigned int*) /space/rguenther/src/svn/trunk2/libcpp/macro.c:2628 0x9e2ea3 c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int) /space/rguenther/src/svn/trunk2/gcc/c-family/c-lex.c:408 #2 0x000000000197315d in linemap_add (set=0x10000fe000, reason=LC_RENAME, sysp=0, to_file=0x24ad430 "../src/include.h", to_line=3) at /space/rguenther/src/svn/trunk2/libcpp/line-map.c:303 303 linemap_assert (!(set->depth == 0 && reason == LC_RENAME)); (gdb) p set->depth $2 = 0 It's correctly initialized by PCH but re-set at Hardware watchpoint 1: *$10 Old value = 1 New value = 0 linemap_add (set=0x10000fe000, reason=LC_LEAVE, sysp=0, to_file=0x0, to_line=0) at /space/rguenther/src/svn/trunk2/libcpp/line-map.c:311 311 return NULL; (gdb) bt #0 linemap_add (set=0x10000fe000, reason=LC_LEAVE, sysp=0, to_file=0x0, to_line=0) at /space/rguenther/src/svn/trunk2/libcpp/line-map.c:311 #1 0x000000000195e29f in _cpp_do_file_change (pfile=0x249a670, reason=LC_LEAVE, to_file=0x0, file_line=0, sysp=0) at /space/rguenther/src/svn/trunk2/libcpp/directives.c:1067 #2 0x0000000001961a5d in _cpp_pop_buffer (pfile=0x249a670) at /space/rguenther/src/svn/trunk2/libcpp/directives.c:2606 #3 0x00000000019704a7 in _cpp_get_fresh_line (pfile=0x249a670) at /space/rguenther/src/svn/trunk2/libcpp/lex.c:2255 #4 0x0000000001970587 in _cpp_lex_direct (pfile=0x249a670) at /space/rguenther/src/svn/trunk2/libcpp/lex.c:2302 #5 0x000000000197029b in _cpp_lex_token (pfile=0x249a670) at /space/rguenther/src/svn/trunk2/libcpp/lex.c:2176 #6 0x0000000001979970 in cpp_get_token_1 (pfile=0x249a670, location=0x7fffffffdc58) ... #10 0x000000000086afd3 in cp_parser_initial_pragma (first_token=0x7fffffffdc50) at /space/rguenther/src/svn/trunk2/gcc/cp/parser.c:32854 #11 0x000000000082eaf7 in cp_lexer_new_main () at /space/rguenther/src/svn/trunk2/gcc/cp/parser.c:650 #12 0x0000000000831d4a in cp_parser_new () at /space/rguenther/src/svn/trunk2/gcc/cp/parser.c:3484 #13 0x000000000086b787 in c_parse_file () at /space/rguenther/src/svn/trunk2/gcc/cp/parser.c:33189 But note that this is an usupported use of PCH - it's included indirectly. We should have rejected it but we don't. Appearantly my fix for that doesn't trigger: 2009-09-22 Richard Guenther <rguenther@suse.de> PR pch/38987 * files.c (pch_open_file): Disallow non-toplevel PCH inclusion. because of the implicit-preinclude check. (gdb) p pfile->all_files->implicit_preinclude $30 = false (gdb) p pfile->all_files->next_file->implicit_preinclude $31 = true I don't understand why we check two files here... (gdb) p pfile->all_files->name $33 = 0x24ad0c0 "include.h" (gdb) p pfile->all_files->next_file->name $34 = 0x24ac120 "stdc-predef.h" (gdb) p pfile->all_files->next_file->next_file->name $35 = 0x24e3be0 "../src/source.cpp" note how the main file is "last". My patch got two revisions - r192715 by Joseph and r193709 by Steve. I think the code should be changed to sth like /* If the file is not included as first include from either the toplevel file or the command-line it is not a valid use of PCH. */ for (_cpp_file *f = pfile->all_files; f; f = f->next_file) if (f->implicit_preinclude) continue; else if (f->main_file) break; else return false; note the change triggering this bug is in GCC 4.8 already (but not in 4.7). Index: libcpp/files.c =================================================================== --- libcpp/files.c (revision 221891) +++ libcpp/files.c (working copy) @@ -291,11 +291,13 @@ pch_open_file (cpp_reader *pfile, _cpp_f /* If the file is not included as first include from either the toplevel file or the command-line it is not a valid use of PCH. */ - if (pfile->all_files - && pfile->all_files->next_file - && !(pfile->all_files->implicit_preinclude - || pfile->all_files->next_file->implicit_preinclude)) - return false; + for (_cpp_file *f = pfile->all_files; f; f = f->next_file) + if (f->implicit_preinclude) + continue; + else if (f->main_file) + break; + else + return false; flen = strlen (path); len = flen + sizeof (extension);
next prev parent reply other threads:[~2015-04-07 10:55 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-03-25 15:05 [Bug pch/65550] New: [5 " doko at gcc dot gnu.org 2015-03-25 15:43 ` [Bug pch/65550] " trippels at gcc dot gnu.org 2015-03-26 11:40 ` rguenth at gcc dot gnu.org 2015-03-27 14:07 ` howarth at bromo dot med.uc.edu 2015-03-31 13:14 ` rguenth at gcc dot gnu.org 2015-04-04 4:45 ` maltsevm at gmail dot com 2015-04-04 8:26 ` maltsevm at gmail dot com 2015-04-04 13:54 ` trippels at gcc dot gnu.org 2015-04-07 10:55 ` rguenth at gcc dot gnu.org [this message] 2015-04-09 13:38 ` [Bug pch/65550] [4.8/4.9 " rguenth at gcc dot gnu.org 2015-04-09 13:38 ` rguenth at gcc dot gnu.org 2015-06-12 11:39 ` rguenther at suse dot de 2015-06-12 11:56 ` jakub at gcc dot gnu.org 2015-06-12 11:57 ` jakub at gcc dot gnu.org 2015-06-12 11:59 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-65550-4-sIpEoGhGqr@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).