Bug 88666 - GCC 8.2.- gets Internal Compiler Error: seg fault; GCC 8.1.0 works fine
Summary: GCC 8.2.- gets Internal Compiler Error: seg fault; GCC 8.1.0 works fine
Status: RESOLVED DUPLICATE of bug 87099
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 8.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, needs-bisection
Depends on:
Blocks:
 
Reported: 2019-01-02 19:15 UTC by Geir Johansen
Modified: 2019-01-03 09:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 8.1.0, 8.2.1
Known to fail: 8.2.0
Last reconfirmed: 2019-01-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Geir Johansen 2019-01-02 19:15:51 UTC
Simple reproducer code causes a seg fault during compile with gcc 8.2.0. The reproducer does not seg fault for gcc 8.1.0

$ cat repro.c
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

int64_t foo (int64_t max, FILE *in)

{
  int64_t count = 0;
  const int64_t MAXLINE  = 1024;
  char buff[MAXLINE];

  while (!feof(in) && count < max) {
    if (fgets(buff, sizeof(buff), in) != NULL) {

      // gcc 8.2 segfaults !!
      if (strncmp (&buff[0], "QUIT", 4) == 0)
        break;

      // this is OK:
      if (strncmp (buff, "QUIT", 4) == 0)
        break;

    }
  }

  return count;
}
$ gcc --version
gcc (GCC) 8.1.0 20180502 (Cray Inc.)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -c repro.c
$ module swap gcc/8.1.0 gcc/8.2.0
$ gcc --version
gcc (GCC) 8.2.0 20180726 (Cray Inc.)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -c repro.c
during RTL pass: expand
repro.c: In function 'foo':
repro.c:17:11: internal compiler error: Segmentation fault
       if (strncmp (&buff[0], "QUIT", 4) == 0)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0xa8de4f crash_signal
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/toplev.c:325
0x6eeb25 wi::extended_tree<192>::get_len() const
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/tree.h:5572
0x6eeb25 wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::decompose(long*, unsigned int, generic_wide_int<wi::extended_tree<192> > const&)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/wide-int.h:934
0x6eeb25 wide_int_ref_storage<true, false>::wide_int_ref_storage<generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, unsigned int)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/wide-int.h:983
0x6eeb25 generic_wide_int<wide_int_ref_storage<true, false> >::generic_wide_int<generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, unsigned int)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/wide-int.h:758
0x6eeb25 bool wi::lts_p<generic_wide_int<wi::extended_tree<192> >, generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, generic_wide_int<wi::extended_tree<192> > const&)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/wide-int.h:1849
0x6eeb25 wi::binary_traits<generic_wide_int<wi::extended_tree<192> >, generic_wide_int<wi::extended_tree<192> >, wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::precision_type, wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::precision_type>::signed_predicate_result operator< <generic_wide_int<wi::extended_tree<192> >, generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, generic_wide_int<wi::extended_tree<192> > const&)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/wide-int.h:3170
0x6eeb25 tree_int_cst_lt(tree_node const*, tree_node const*)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/tree.h:5728
0x6eeb25 maybe_warn_nonstring_arg(tree_node*, tree_node*)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/calls.c:1716
0x6f053a maybe_warn_nonstring_arg(tree_node*, tree_node*)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/calls.c:1627
0x6f053a initialize_argument_information
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/calls.c:2321
0x6f053a expand_call(tree_node*, rtx_def*, int)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/calls.c:3713
0x6e4286 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/builtins.c:6656
0x7f1679 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/expr.c:11005
0x7fa35b store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/expr.c:5635
0x7fb5b3 expand_assignment(tree_node*, tree_node*, bool)
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/expr.c:5403
0x7015d8 expand_call_stmt
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/cfgexpand.c:2688
0x7015d8 expand_gimple_stmt_1
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/cfgexpand.c:3624
0x7015d8 expand_gimple_stmt
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/cfgexpand.c:3790
0x70287f expand_gimple_basic_block
	../../cray-gcc-8.2.0-201808172015.9a091ef8ec76a/gcc/cfgexpand.c:5819
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
$
Comment 1 Martin Sebor 2019-01-03 00:42:14 UTC
This looks similar to bug 88659 but I'm not able to reproduce it on x86_64 with either the top of the gcc-8-branch or trunk (GCC 9).  Either it's been fixed or it's target-specific.  Please mention your Host and Target triplets and either provide a preprocessing translation unit for the test case or reduce it to one that doesn't include any headers.
Comment 2 Richard Biener 2019-01-03 08:45:52 UTC
Confirmed with GCC 8.2.0, I can't reproduce it on the branch head so I assume it was fixed (and there was likely a duplicate report).  Martin, can you bisect the fix?
Comment 3 Martin Liška 2019-01-03 09:24:14 UTC
(In reply to Richard Biener from comment #2)
> Confirmed with GCC 8.2.0, I can't reproduce it on the branch head so I
> assume it was fixed (and there was likely a duplicate report).  Martin, can
> you bisect the fix?

Doing that.
Comment 4 Martin Liška 2019-01-03 09:42:17 UTC
Dup.

*** This bug has been marked as a duplicate of bug 87099 ***