From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11267 invoked by alias); 6 Mar 2014 02:05:11 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9946 invoked by uid 48); 6 Mar 2014 02:05:04 -0000 From: "dan.doel at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/60436] New: C preprocessor segfaults on assembly file Date: Thu, 06 Mar 2014 02:05:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dan.doel at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg00410.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60436 Bug ID: 60436 Summary: C preprocessor segfaults on assembly file Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: dan.doel at gmail dot com Greetings, While testing the latest GHC, I came across a segfault in GCC. I've tracked it down to the preprocessor segfaulting on an intermediate assembly file produced during compilation. I've also reproduced the segfault using the stock 4.8.2 release, although I first encountered it on the 2014-02-06 snapshot which is currently distributed on Arch. The assembly file is very large, but I have no smaller test case. I cannot attach it here, because xz -9e only compresses it to ~2MiB. However, you can find it at the Arch bug report I'll link below. Various bits about the reproduction of the segfault are also quite odd: The assembly file contains no macros or includes. A macro must be defined to produce the segfault. The one GHC uses is -DTABLES_NEXT_TO_CODE. One can also get the segfault by putting '#define TABLES_NEXT_TO_CODE' at the top of the file TABLES_NEXT_TO_CODE is meaningless, though. Any macro definition of 13 letters or more triggers the segfault. But 12 or fewer seems to work fine. Adding a blank line anywhere before line 395,848 stops the segfault, but adding blank lines after does nothing. Truncating the file before line 4,400,769 stops the segfault, but truncating after does nothing. Here's the crash output of running `cpp -v -DABCDEFGHIJKLM` on the file: ---- Using built-in specs. COLLECT_GCC=cpp Target: x86_64-unknown-linux-gnu Configured with: ./configure Thread model: posix gcc version 4.8.2 (GCC) COLLECT_GCC_OPTIONS='-E' '-v' '-D' 'ABCDEFGHIJKLM' '-o' 'ghc3240_8.pps' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/cc1 -E -lang-asm -quiet -v -D ABCDEFGHIJKLM ghc3240_8.s -o ghc3240_8.pps -mtune=generic -march=x86-64 -fno-directives-only ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include /usr/local/include /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include-fixed /usr/include End of search list. ghc3240_8.s:1:0: internal compiler error: Segmentation fault .section .rodata ^ 0x80cdcf crash_signal ../.././gcc/toplev.c:332 0xc4916e get_data_from_adhoc_loc(line_maps*, unsigned int) ../.././libcpp/line-map.c:156 0xc371db expand_location_1 ../.././gcc/input.c:57 0xc3740d expand_location(unsigned int) ../.././gcc/input.c:150 0x578c1d scan_translation_unit ../.././gcc/c-family/c-ppoutput.c:214 0x578c1d preprocess_file(cpp_reader*) ../.././gcc/c-family/c-ppoutput.c:101 0x5774d0 c_common_init() ../.././gcc/c-family/c-opts.c:1026 0x52e59d c_objc_common_init() ../.././gcc/c/c-objc-common.c:63 0x80e7c6 lang_dependent_init ../.././gcc/toplev.c:1688 0x80e7c6 do_compile ../.././gcc/toplev.c:1850 ---- Here is a link to the Arch bug I've filed. You can find the offending file (compressed) there: https://bugs.archlinux.org/task/39180 If any further information is desired, let me know. Thanks.