Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
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: NEW
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: 2021-02-09 15:42 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
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.


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