Bug 1918767 - gcc crashes: lto1: fatal error: Cgraph edge statement index out of range
Summary: gcc crashes: lto1: fatal error: Cgraph edge statement index out of range
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 34
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs
TreeView+ depends on / blocked
 
Reported: 2021-01-21 14:27 UTC by Richard W.M. Jones
Modified: 2022-06-07 22:02 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2022-06-07 22:02:48 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 98599 0 P3 WAITING fatal error: Cgraph edge statement index out of range with -Os -flto -fanalyzer 2021-01-29 09:52:10 UTC

Description Richard W.M. Jones 2021-01-21 14:27:07 UTC
Description of problem:

gcc crashes compiling a small test program.

Version-Release number of selected component (if applicable):

gcc-11.0.0-0.14.fc34.x86_64

How reproducible:

100%

Steps to Reproduce:
1. Download https://github.com/libguestfs/libguestfs/blob/master/lib/libvirt-is-version.c
2. Remove <config.h> include at the top.
3. Remove lines 41 and 42 which refer to "PACKAGE".
4. Compile it like this:

$ gcc -fanalyzer -fno-common -Wall -Warith-conversion -Wbad-function-cast -Wcast-align=strict -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches -Wduplicated-cond -Wextra -Wformat-signedness -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnull-dereference -Wold-style-definition -Wopenmp-simd -Wpointer-arith -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=cold -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand -Wtrampolines -Wuninitialized -Wunknown-pragmas -Wunused-macros -Wvariadic-macros -Wvector-operation-performance -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wformat-overflow=2 -Wformat=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wunused-const-variable=2 -Wno-analyzer-double-free -Wno-analyzer-malloc-leak -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free -Wno-unused-parameter -Wno-missing-field-initializers -fdiagnostics-show-option -Wframe-larger-than=6000 -Wstack-usage=10000 -Wimplicit-fallthrough=4 -Wformat-truncation=1 -Wformat-overflow=1 -Wno-pragmas -Werror -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fno-strict-overflow -Wno-strict-overflow -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o libvirt-is-version libvirt-is-version.c  -lvirt
In function ‘argtoint’:
lto1: fatal error: Cgraph edge statement index out of range
compilation terminated.

Comment 1 Marek Polacek 2021-01-21 14:31:02 UTC
Patch available upstream:
https://gcc.gnu.org/pipermail/gcc-patches/2021-January/563416.html

Comment 2 Richard W.M. Jones 2021-01-21 14:32:31 UTC
Smaller test case:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <error.h>

static unsigned int argtoint (const char *prog, const char *arg);

int main (void) { printf ("%u\n", argtoint ("hello", "world")); exit (0); }

static unsigned int
argtoint (const char *prog, const char *arg)
{
  long int res;
  char *endptr;

  errno = 0;
  res = strtol (arg, &endptr, 10);
  if (errno || *endptr)
    error (EXIT_FAILURE, 0, "cannot parse integer argument '%s'", arg);

  return (unsigned int) res;
}

-----

$ gcc -fanalyzer -fno-common -Wall -Warith-conversion -Wbad-function-cast -Wcast-align=strict -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches -Wduplicated-cond -Wextra -Wformat-signedness -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnull-dereference -Wold-style-definition -Wopenmp-simd -Wpointer-arith -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=cold -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand -Wtrampolines -Wuninitialized -Wunknown-pragmas -Wunused-macros -Wvariadic-macros -Wvector-operation-performance -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wformat-overflow=2 -Wformat=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wunused-const-variable=2 -Wno-analyzer-double-free -Wno-analyzer-malloc-leak -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free -Wno-unused-parameter -Wno-missing-field-initializers -fdiagnostics-show-option -Wframe-larger-than=6000 -Wstack-usage=10000 -Wimplicit-fallthrough=4 -Wformat-truncation=1 -Wformat-overflow=1 -Wno-pragmas -Werror -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fno-strict-overflow -Wno-strict-overflow -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o argtoint argtoint.c 
argtoint.c: In function ‘argtoint’:
argtoint.c:9:5: fatal error: Cgraph edge statement index out of range
    9 | int main (void) { printf ("%u\n", argtoint ("hello", "world")); exit (0); }
      |     ^
compilation terminated.
make: *** [/tmp/ccuwY2M0.mk:2: /tmp/ccDvJlVX.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Comment 3 Richard W.M. Jones 2021-01-21 14:33:42 UTC
Thanks, is this going to be fixed by
https://koji.fedoraproject.org/koji/buildinfo?buildID=1671837 ?

It doesn't look like this fix is mentioned in the %changelog.

Comment 4 Marek Polacek 2021-01-21 14:37:16 UTC
(In reply to Richard W.M. Jones from comment #3)
> Thanks, is this going to be fixed by
> https://koji.fedoraproject.org/koji/buildinfo?buildID=1671837 ?
> 
> It doesn't look like this fix is mentioned in the %changelog.

Right, I think the patch hasn't yet been approved.  But hopefully it will be soon.  A workaround is to turn off -fanalyzer.

Comment 5 Dave Malcolm 2021-01-21 14:37:33 UTC
The patch isn't in upstream git yet; looks like I need to respond to comments from Honza on the upstream mailing list

Comment 6 Ben Cotton 2021-02-09 15:42:04 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 7 Ben Cotton 2022-05-12 15:31:39 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '34'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 8 Ben Cotton 2022-06-07 22:02:48 UTC
Fedora Linux 34 entered end-of-life (EOL) status on 2022-06-07.

Fedora Linux 34 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.