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

            Bug ID: 88219
           Summary: Precompiled headers Segmentation fault in Cygwin
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: pch
          Assignee: unassigned at gcc dot gnu.org
          Reporter: EngyCZ at gmail dot com
  Target Milestone: ---

Created attachment 45099
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45099&action=edit
Sample

Hi,
 Precompiled headers feature doesn't work in Cygwin. Compilation terminates
with Segmentation fault in cc1. Sample file attached. Same file is working in
Linux

I searched why and found that the result here
https://github.com/gcc-mirror/gcc/blob/gcc-7_3_0-release/gcc/ggc-common.c#L626
is 1 in Linux and -1 in CygWin.

GCC had to relocate PCH but it fails in fatal_error function call on line 629.

Cygwin behavior can be "emulated" by commenting out "if (result < 0)" on line
628
With this the Linux version also fails with Segmentation fault.

Thread 1 "cc1" received signal SIGSEGV, Segmentation fault.
linemap_macro_map_lookup (line=480, set=0xffbdda40) at
../../gcc-7.3.0/libcpp/line-map.c:1021
1021      if (line >= MAP_START_LOCATION (cached))
(gdb) backtrace
#0  linemap_macro_map_lookup (line=480, set=0xffbdda40) at
../../gcc-7.3.0/libcpp/line-map.c:1021
#1  linemap_lookup (set=set@entry=0xffbdda40, line=<optimized out>,
line@entry=480) at ../../gcc-7.3.0/libcpp/line-map.c:946
#2  0x00f5467b in linemap_macro_loc_to_def_point (original_map=<optimized out>,
location=480, set=<optimized out>) at ../../gcc-7.3.0/libcpp/line-map.c:1450
#3  linemap_resolve_location (set=0xffbdda40, loc=loc@entry=480,
lrk=lrk@entry=LRK_MACRO_DEFINITION_LOCATION, map=map@entry=0xd43c2ac) at
../../gcc-7.3.0/libcpp/line-map.c:1582
#4  0x00f2f411 in diagnostic_report_current_module
(context=context@entry=0x182fec0 <global_diagnostic_context>, where=480) at
../../gcc-7.3.0/gcc/diagnostic.c:551
#5  0x008a406a in diagnostic_report_current_function
(context=context@entry=0x182fec0 <global_diagnostic_context>,
diagnostic=diagnostic@entry=0xd43c3ec) at
../../gcc-7.3.0/gcc/tree-diagnostic.c:39
#6  0x008a40c9 in default_tree_diagnostic_starter (context=0x182fec0
<global_diagnostic_context>, diagnostic=0xd43c3ec) at
../../gcc-7.3.0/gcc/tree-diagnostic.c:48
#7  0x00f3017d in diagnostic_report_diagnostic (context=<optimized out>,
diagnostic=<optimized out>, diagnostic@entry=0xd43c3ec) at
../../gcc-7.3.0/gcc/diagnostic.c:962
#8  0x00f306af in diagnostic_impl (richloc=richloc@entry=0xd43c444,
opt=opt@entry=-1, gmsgid=gmsgid@entry=0x11223ba <(anonymous
namespace)::pass_data_rtl_pre+122> "had to relocate PCH",
ap=ap@entry=0xd43c440, kind=kind@entry=DK_FATAL)
    at ../../gcc-7.3.0/gcc/diagnostic.c:1084
#9  0x00f30f6d in fatal_error (loc=480, gmsgid=gmsgid@entry=0x11223ba
<(anonymous namespace)::pass_data_rtl_pre+122> "had to relocate PCH") at
../../gcc-7.3.0/gcc/diagnostic.c:1379
#10 0x006382ad in gt_pch_restore (f=f@entry=0x20052d80) at
../../gcc-7.3.0/gcc/ggc-common.c:629
#11 0x004a9104 in c_common_read_pch (pfile=0x2007dfe0, name=0x20109128
"largefile.h.gch", fd=4, orig_name=0x20109110 "largefile.h") at
../../gcc-7.3.0/gcc/c-family/c-pch.c:368
#12 0x00f4c86f in should_stack_file (loc=40964908, import=false,
file=0x20109300, pfile=0x2007dfe0) at ../../gcc-7.3.0/libcpp/files.c:814
#13 _cpp_stack_file (pfile=0x2007dfe0, file=0x20109300, import=false,
loc=40964908) at ../../gcc-7.3.0/libcpp/files.c:900
#14 0x00f4cd71 in _cpp_stack_include (pfile=pfile@entry=0x2007dfe0,
fname=fname@entry=0x201090a8 "largefile.h", angle_brackets=0,
type=type@entry=IT_INCLUDE, loc=40964908) at
../../gcc-7.3.0/libcpp/files.c:1049
#15 0x00f41f80 in do_include_common (pfile=0x2007dfe0, type=IT_INCLUDE) at
../../gcc-7.3.0/libcpp/directives.c:858
#16 0x00f429bd in _cpp_handle_directive (pfile=pfile@entry=0x2007dfe0,
indented=0) at ../../gcc-7.3.0/libcpp/directives.c:547
#17 0x00f530b5 in _cpp_lex_token (pfile=pfile@entry=0x2007dfe0) at
../../gcc-7.3.0/libcpp/lex.c:2566
#18 0x00f5888d in cpp_get_token_1 (pfile=pfile@entry=0x2007dfe0,
location=location@entry=0xd43c8a8) at ../../gcc-7.3.0/libcpp/macro.c:2462
#19 0x00f58d5d in cpp_get_token_with_location (pfile=0x2007dfe0,
loc=loc@entry=0xd43c8a8) at ../../gcc-7.3.0/libcpp/macro.c:2648
#20 0x004a2805 in c_lex_with_flags (value=value@entry=0xd43c8ac,
loc=loc@entry=0xd43c8a8, cpp_flags=cpp_flags@entry=0xd43c8b0 "", lex_flags=0)
at ../../gcc-7.3.0/gcc/c-family/c-lex.c:398
#21 0x00437790 in c_lex_one_token (parser=parser@entry=0xd43c8a0,
token=token@entry=0xd43c8a4) at ../../gcc-7.3.0/gcc/c/c-parser.c:248
#22 0x0045da0d in c_parser_peek_token (parser=0xd43c8a0) at
../../gcc-7.3.0/gcc/c/c-parser.c:435
#23 c_parse_file () at ../../gcc-7.3.0/gcc/c/c-parser.c:18171
#24 0x004a85fd in c_common_parse_file () at
../../gcc-7.3.0/gcc/c-family/c-opts.c:1107
#25 0x00865442 in compile_file () at ../../gcc-7.3.0/gcc/toplev.c:467
#26 0x01094f94 in do_compile () at ../../gcc-7.3.0/gcc/toplev.c:2003
#27 toplev::main (this=this@entry=0xd43c9fe, argc=<optimized out>,
argc@entry=33, argv=<optimized out>, argv@entry=0xd43ca2c) at
../../gcc-7.3.0/gcc/toplev.c:2138
#28 0x010b4632 in main (argc=33, argv=0xd43ca2c) at
../../gcc-7.3.0/gcc/main.c:39

Reply via email to