Bug 84682 - [7 Regression] internal compiler error: Segmentation fault (process_address_1)
Summary: [7 Regression] internal compiler error: Segmentation fault (process_address_1)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 8.0.1
: P2 normal
Target Milestone: 8.0
Assignee: Alexandre Oliva
URL:
Keywords: patch
: 84677 92368 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-03-02 20:21 UTC by Vegard Nossum
Modified: 2019-11-14 11:16 UTC (History)
4 users (show)

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work: 8.0
Known to fail: 7.5.0
Last reconfirmed: 2018-03-02 00:00:00


Attachments
candidate patch (2.36 KB, patch)
2018-03-08 08:35 UTC, Alexandre Oliva
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vegard Nossum 2018-03-02 20:21:46 UTC
Input:

void b(char a) {
        asm("" : : "pIr" (a));
}

Output:

$ xgcc -x c++ -S -Wall -
during RTL pass: reload
<stdin>: In function 'void b(char)':
<stdin>:3:1: internal compiler error: Segmentation fault
0x3155789 crash_signal
        /home/vegard/git/gcc/gcc/toplev.c:325
0x28a3e20 process_address_1
        /home/vegard/git/gcc/gcc/lra-constraints.c:3424
0x28a7ba3 process_address
        /home/vegard/git/gcc/gcc/lra-constraints.c:3521
0x28a7ba3 curr_insn_transform
        /home/vegard/git/gcc/gcc/lra-constraints.c:3836
0x28bbf56 lra_constraints(bool)
        /home/vegard/git/gcc/gcc/lra-constraints.c:4877
0x282c524 lra(_IO_FILE*)
        /home/vegard/git/gcc/gcc/lra.c:2419
0x260b334 do_reload
        /home/vegard/git/gcc/gcc/ira.c:5465
0x260b334 execute
        /home/vegard/git/gcc/gcc/ira.c:5649

$ xgcc --version
xgcc (GCC) 8.0.1 20180301 (experimental)

Built from git c435a9e730c6e8f10da09d58b4fc9aaeb401b0d5 (r258097).

Seems to have been introduced between 4.8.5 and 4.9.0.

Test case was minimised by C-Reduce.
Comment 1 David Malcolm 2018-03-02 21:39:56 UTC
Confirmed.

Segfault reading through NULL in reload here:

process_address_1 (nop=nop@entry=0, check_only_p=check_only_p@entry=false, before=before@entry=0x7fffffffcea0, 
    after=after@entry=0x7fffffffcea8) at ../../src/gcc/lra-constraints.c:3424
3424		  if (poly_int_rtx_p (*ad.disp, &orig_offset)

(gdb) p ad.disp
$1 = (rtx *) 0x0
Comment 2 Vegard Nossum 2018-03-02 22:05:21 UTC
I'm also seeing a different crash with this (using -O3):

int a;
void b() {
  float c;
  for (int d; d;)
    ;
  a = c;
  asm("" : : "pIr"(c));
}

Output:

$ xgcc -x c++ -S -Wall -fpermissive -O3 -
<stdin>: In function 'void b()':
<stdin>:4:15: warning: 'd' is used uninitialized in this function [-Wuninitialized]
<stdin>:6:5: warning: 'c' is used uninitialized in this function [-Wuninitialized]
during RTL pass: reload
<stdin>:8:1: internal compiler error: in emit_move_insn, at expr.c:3717
0x1e906d7 emit_move_insn(rtx_def*, rtx_def*)
        /home/vegard/git/gcc/gcc/expr.c:3716
0x280edaa lra_emit_move(rtx_def*, rtx_def*)
        /home/vegard/git/gcc/gcc/lra.c:497
0x28a3871 process_address_1
        /home/vegard/git/gcc/gcc/lra-constraints.c:3368
0x28a7ba3 process_address
        /home/vegard/git/gcc/gcc/lra-constraints.c:3521
0x28a7ba3 curr_insn_transform
        /home/vegard/git/gcc/gcc/lra-constraints.c:3836
0x28bbf56 lra_constraints(bool)
        /home/vegard/git/gcc/gcc/lra-constraints.c:4877
0x282c524 lra(_IO_FILE*)
        /home/vegard/git/gcc/gcc/lra.c:2419
0x260b334 do_reload
        /home/vegard/git/gcc/gcc/ira.c:5465
0x260b334 execute
        /home/vegard/git/gcc/gcc/ira.c:5649

I'm not opening a new bug because the stack trace is quite similar and also it seems that making very small changes to this test case makes it crash in the original way, so I figure it's probably related.
Comment 3 Jakub Jelinek 2018-03-03 12:25:30 UTC
Started with r198344.
Comment 4 Alexandre Oliva 2018-03-08 07:58:10 UTC
Mine
Comment 5 Alexandre Oliva 2018-03-08 08:35:59 UTC
Created attachment 43594 [details]
candidate patch

Here's what I'm testing
Comment 6 Alexandre Oliva 2018-03-09 06:51:24 UTC
Improved patch posted
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00416.html
Comment 7 Jeffrey A. Law 2018-03-09 18:51:27 UTC
Author: law
Date: Fri Mar  9 18:50:56 2018
New Revision: 258393

URL: https://gcc.gnu.org/viewcvs?rev=258393&root=gcc&view=rev
Log:
	PR rtl-optimization/84682
	* lra-constraints.c (process_address_1): Check is_address flag
	for address constraints.
	(process_alt_operands): Likewise.
	* lra.c (lra_set_insn_recog_data): Pass asm operand locs to
	preprocess_constraints.
	* recog.h (preprocess_constraints): Add oploc parameter.
	Adjust callers.

	PR rtl-optimization/84682
	* gcc.dg/torture/pr84682-1.c: New.
	* gcc.dg/torture/pr84682-2.c: New.
	* gcc.dg/torture/pr84682-3.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr84682-1.c
    trunk/gcc/testsuite/gcc.dg/torture/pr84682-2.c
    trunk/gcc/testsuite/gcc.dg/torture/pr84682-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lra-constraints.c
    trunk/gcc/lra.c
    trunk/gcc/recog.c
    trunk/gcc/recog.h
    trunk/gcc/testsuite/ChangeLog
Comment 8 Jeffrey A. Law 2018-03-09 18:52:01 UTC
Fixed on trunk so far.
Comment 9 Jakub Jelinek 2018-10-26 10:14:52 UTC
GCC 6 branch is being closed
Comment 10 Richard Biener 2018-11-22 08:55:37 UTC
*** Bug 84677 has been marked as a duplicate of this bug. ***
Comment 11 Andrew Pinski 2019-11-05 09:32:39 UTC
*** Bug 92368 has been marked as a duplicate of this bug. ***
Comment 12 Richard Biener 2019-11-14 11:16:01 UTC
Fixed in GCC 8.