This testcase segfaults for c and c++. --cut here-- # 1 "/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.0/include/stddef.h" 1 3 4 --cut here-- gcc express-min.i In file included from express-min.i:1: /usr/local/lib/gcc/i686-pc-linux-gnu/4.1.0/include/stddef.h:1: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. This behaviour is quite annoying: if delta tool is used to minimize a preprocessed file that segfaults, it always produces this kind of one-line minimized testcase.
Confirmed, backtrace: #0 0x0804bc76 in fe_file_change (new_map=0xa30cce4) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/c-lex.c:236 #1 0x080997a5 in cb_file_change (pfile=0xa303928, new_map=0xa30cce4) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/c-opts.c:1405 #2 0x084f04f3 in _cpp_do_file_change (pfile=0xa303928, reason=LC_ENTER, to_file=0xa30e720 "/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.0/include/stddef.h", file_line=1, sysp=2) at /home/peshtigo/pinskia/src/gnu/gcc/src/libcpp/directives.c:921 #3 0x084f03e8 in do_linemarker (pfile=0xa303928) at /home/peshtigo/pinskia/src/gnu/gcc/src/libcpp/directives.c:903 #4 0x084efafd in _cpp_handle_directive (pfile=0xa303928, indented=0) at /home/peshtigo/pinskia/src/gnu/gcc/src/libcpp/directives.c:430 #5 0x084f609b in read_original_filename (pfile=0xa303928) at /home/peshtigo/pinskia/src/gnu/gcc/src/libcpp/init.c:506 #6 0x084f6015 in cpp_read_main_file (pfile=0xa303928, fname=0xbfff8c42 "t.i") at /home/peshtigo/pinskia/src/gnu/gcc/src/libcpp/init.c:480 #7 0x0809a0db in c_common_post_options (pfilename=0x86373a8) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/c-opts.c:1046 : Search converges between 2004-02-01-trunk (#445) and 2004-03-01-trunk (#446). : Search converges between 2004-02-02-3.4 (#1) and 2004-03-01-3.4 (#2).
A regression hunt identified this patch from bothner@gcc.gnu.org: http://gcc.gnu.org/ml/gcc-cvs/2004-02/msg00236.html
The testcase could be furhter reduced into perhaps the smallest testcase that ICEs, ever (name this file for example ttt.i): --cut here-- # --cut here-- gcc ttt.i ttt.i:1: internal compiler error: Segmentation fault
Leaving as P2. This really should be fixed.
The two test cases appear to be unrelated problems. The inital report is because an invalid line marker is seen before debug_hooks is set in process_options. fe_enter doesn't normally see an LC_ENTER during read_original_filename. One possible fix to to initialize debug_hooks statically in toplev.c: const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks; The other testcase is because _cpp_pop_buffer is called prematurely, because the code doesn't know we're in a directive. A possible fix for that is to set/clear pfile->state.in_directive areound the second _cpp_lex_direct in read_original_filename: if (token->type == CPP_HASH) { pfile->state.in_directive = 1; token1 = _cpp_lex_direct (pfile); _cpp_backup_tokens (pfile, 1); pfile->state.in_directive = 0; I haven't updated my cvs archive yet, but if someone coudl volunteer to test these fixes that woudl be appreciated.
I can test the first one since it is an easy one to test.
Created attachment 10088 [details] proposed patch for initial testcase
Created attachment 10090 [details] proposed patch for second testcase
Patch here: http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00498.html
Subject: Bug 24101 Author: uros Date: Wed Nov 9 06:30:03 2005 New Revision: 106677 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106677 Log: libcpp/ PR c/24101 * init.c (read_original_filename): Temporarily set state.in_directive before calling _cpp_lex_direct for CPP_HASH tokens. gcc/ PR c/24101 * toplev.c (process_options): Initialize debug_hooks early in case lang_hooks.post_options ends up calling a debug_hook. gcc/testsuite/ PR c/24101 * gcc.dg/pr24101-1.i, gcc.dg/pr24101-2.i: New tests. * gcc.dg/dg.exp: Run main loop also for *.i files. Added: trunk/gcc/testsuite/gcc.dg/pr24101-1.i trunk/gcc/testsuite/gcc.dg/pr24101-2.i Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/dg.exp trunk/gcc/toplev.c trunk/libcpp/ChangeLog trunk/libcpp/init.c
Subject: Bug 24101 Author: uros Date: Wed Nov 9 06:42:53 2005 New Revision: 106678 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106678 Log: libcpp/ PR c/24101 * init.c (read_original_filename): Temporarily set state.in_directive before calling _cpp_lex_direct for CPP_HASH tokens. gcc/ PR c/24101 * toplev.c (process_options): Initialize debug_hooks early in case lang_hooks.post_options ends up calling a debug_hook. gcc/testsuite/ PR c/24101 * gcc.dg/pr24101-1.i, gcc.dg/pr24101-2.i: New tests. * gcc.dg/dg.exp: Run main loop also for *.i files. Added: branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/pr24101-1.i - copied unchanged from r106677, trunk/gcc/testsuite/gcc.dg/pr24101-1.i branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/pr24101-2.i - copied unchanged from r106677, trunk/gcc/testsuite/gcc.dg/pr24101-2.i Modified: branches/gcc-4_0-branch/gcc/ChangeLog branches/gcc-4_0-branch/gcc/testsuite/ChangeLog branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/dg.exp branches/gcc-4_0-branch/gcc/toplev.c branches/gcc-4_0-branch/libcpp/ChangeLog branches/gcc-4_0-branch/libcpp/init.c
Subject: Bug 24101 Author: uros Date: Wed Nov 9 07:51:51 2005 New Revision: 106679 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106679 Log: gcc/ PR c/24101 * toplev.c (process_options): Initialize debug_hooks early in case lang_hooks.post_options ends up calling a debug_hook. * cppinit.c (read_original_filename): Temporarily set state.in_directive before calling _cpp_lex_direct for CPP_HASH tokens. gcc/testsuite/ PR c/24101 * gcc.dg/pr24101-1.i, gcc.dg/pr24101-2.i: New tests. * gcc.dg/dg.exp: Run main loop also for *.i files. Added: branches/gcc-3_4-branch/gcc/testsuite/gcc.dg/pr24101-1.i - copied unchanged from r106677, trunk/gcc/testsuite/gcc.dg/pr24101-1.i branches/gcc-3_4-branch/gcc/testsuite/gcc.dg/pr24101-2.i - copied unchanged from r106677, trunk/gcc/testsuite/gcc.dg/pr24101-2.i Modified: branches/gcc-3_4-branch/gcc/ChangeLog branches/gcc-3_4-branch/gcc/cppinit.c branches/gcc-3_4-branch/gcc/testsuite/ChangeLog branches/gcc-3_4-branch/gcc/testsuite/gcc.dg/dg.exp branches/gcc-3_4-branch/gcc/toplev.c
Fixed everywhere.