Bug 28834 - [4.0/4.1/4.2/4.3 Regression] -g crashes sometimes when using may_alias and structs (ICE in splice_child_die)
Summary: [4.0/4.1/4.2/4.3 Regression] -g crashes sometimes when using may_alias and st...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.2.0
: P2 normal
Target Milestone: 4.1.3
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
: 28880 29436 29903 30661 30758 30894 30986 32426 32793 34041 (view as bug list)
Depends on:
Blocks: 28642 29436
  Show dependency treegraph
 
Reported: 2006-08-24 11:04 UTC by Andrew Pinski
Modified: 2019-08-15 11:05 UTC (History)
21 users (show)

See Also:
Host:
Target: dwarf2
Build:
Known to work: 3.4.0
Known to fail: 4.0.0, 4.1.0, 4.2.0
Last reconfirmed: 2007-10-24 19:59:54


Attachments
true (53.40 KB, application/pdf)
2019-08-15 11:05 UTC, nicbrown
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2006-08-24 11:04:23 UTC
Testcase that crashes at -O3 -g:
struct S { short x; };
typedef struct S __attribute__((__may_alias__)) test;

int f() {
  int a=10;
  test *p=(test *)&a;
  p->x = 1;
  return a;
}

int main() {
  if (f() == 10)
    __builtin_abort();
  return 0;
}

---------------------
mayalias-2.c:2: internal compiler error: in splice_child_die, at dwarf2out.c:5513
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2006-08-24 11:06:12 UTC
This worked in 3.4.0 so this is a regression.  Note this is the testcase for 28807 which I was using for testing so the testcase might be added to the testsuite by the time someone gets around to looking into the bug.
Comment 2 Andrew Pinski 2006-08-24 15:50:05 UTC
Janis,
  Could you run a regression hunt on this bug?
Comment 3 Janis Johnson 2006-08-24 23:35:17 UTC
A regression hunt on powerpc-linux identified this patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=87036

    r87036 | dpatel | 2004-09-03 17:10:40 +0000 (Fri, 03 Sep 2004)
Comment 4 Andrew Pinski 2006-08-25 01:20:29 UTC
Confirmed by Janis.
Comment 5 Richard Biener 2006-08-25 10:39:30 UTC
We now have gcc.c-torture/execute/mayalias-2.c which crashes this way on x86_64 at  -O3 -g.
Comment 6 John David Anglin 2006-08-26 23:39:32 UTC
Also fails on PA with -O3 -g.
Comment 7 Andrew Pinski 2006-08-29 04:41:16 UTC
*** Bug 28880 has been marked as a duplicate of this bug. ***
Comment 8 Geoff Keating 2006-08-29 04:48:35 UTC
In the duplicate I explain:

The problem is that the front-end is calling the DWARF output code with two
shallow copies of the same structure, 'S'.  The DWARF code detects that two
different structures have the same members and aborts.
Comment 9 Andrew Pinski 2006-08-30 03:28:29 UTC
Devang,
  Why did you remove your self, you caused this regression.
Yes you might not work on GCC any more for Apple but that does not take you away from fixing the regression you caused.  I am a bit upset at this behavior of going away and not going to fix a regression you caused.

-- Pinski

dpatel@apple.com  	2006-08-29 17:46:15  	CC  	dpatel@gcc.gnu.org
Comment 10 Devang Patel 2006-08-30 07:47:20 UTC
Pinski,

Please do not reinsert my email address in CC list, again (and learn to not jump to conclusion based on biased views)

May be it is not a good idea to ask dwarf generator to handle a case where two shallow copy of same struct refers same field ? May be equate_decl_number_to_die() should handle it properly ? May be it is appropriate to have one field be a member of multiple structures ?
Comment 11 Mark Mitchell 2006-09-01 21:53:34 UTC
Yet another problem showing problems with attributes on typedefs for structure types...
Comment 12 Andrew Pinski 2006-09-02 00:02:18 UTC
(In reply to comment #11)
> Yet another problem showing problems with attributes on typedefs for structure
> types...
Except this is with C and not C++ unlike the other ones.
Comment 13 Geoff Keating 2006-09-02 05:31:38 UTC
Subject: Re:  [4.0/4.1/4.2 Regression] -O3 -g crashes sometimes when using may_alias and structs


On 01/09/2006, at 2:53 PM, mmitchel at gcc dot gnu dot org wrote:

> ------- Comment #11 from mmitchel at gcc dot gnu dot org   
> 2006-09-01 21:53 -------
> Yet another problem showing problems with attributes on typedefs  
> for structure
> types...

The question I asked is "why doesn't this happen for 'const'"?  That  
turned out to be a good question, because it leads to the better  
question of "what debugging output did you expect for this code,  
anyway"?

It seems to me that __noalias__ is an interesting attribute that  
should be somehow reflected in the DWARF.  That would require a GNU  
extension, of course.
Comment 14 Richard Sandiford 2006-10-07 12:56:30 UTC
The mayalias-2.c failure shows up on MIPS too.
Comment 15 Eric Botcazou 2006-10-15 11:38:56 UTC
Also fails on SPARC with -O3 -g.
Comment 16 Andrew Pinski 2006-11-20 00:49:58 UTC
*** Bug 29903 has been marked as a duplicate of this bug. ***
Comment 17 Albert Cahalan 2006-11-24 00:11:14 UTC
(In reply to comment #13)

> The question I asked is "why doesn't this happen for 'const'"?  That  
> turned out to be a good question, because it leads to the better  
> question of "what debugging output did you expect for this code,  
> anyway"?
> 
> It seems to me that __noalias__ is an interesting attribute that  
> should be somehow reflected in the DWARF.  That would require a GNU  
> extension, of course.

Rather than comparing this with "const", compare it with "restrict".
This deserves representation in DWARF if and only if restrict deserves it.
(and that I can't answer, but my gut feeling is that such representation
should be only for things that C++ would put into name mangling)
Comment 18 Andrew Pinski 2007-02-01 08:49:50 UTC
*** Bug 30661 has been marked as a duplicate of this bug. ***
Comment 19 Gabriel Dos Reis 2007-02-03 19:35:46 UTC
won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 20 Hans-Peter Nilsson 2007-02-05 13:51:52 UTC
I see this for cris-elf (r121581) and mmix-knuth-mmixware (r121569) too, both mayalias-2 and -3 both at "-O3 -g" like for x86_64.
As we have this PR, I intend to XFAIL it for these ports with those options;
IIRC that's protocol.
Comment 21 Andrew Pinski 2007-02-10 19:23:13 UTC
*** Bug 30758 has been marked as a duplicate of this bug. ***
Comment 22 Richard Biener 2007-02-20 21:49:45 UTC
*** Bug 30894 has been marked as a duplicate of this bug. ***
Comment 23 Andrew Pinski 2007-02-27 21:48:18 UTC
*** Bug 30986 has been marked as a duplicate of this bug. ***
Comment 24 Andreas Schwab 2007-02-27 21:54:28 UTC
ICE's with every optimization level.
Comment 25 Andrew Pinski 2007-06-20 14:30:53 UTC
*** Bug 32426 has been marked as a duplicate of this bug. ***
Comment 26 Andrew Pinski 2007-07-17 12:51:18 UTC
*** Bug 32793 has been marked as a duplicate of this bug. ***
Comment 27 Tim Prince 2007-07-29 18:00:27 UTC
same failure for gcc-4.3 mainline on i686-pc-cygwin
Comment 28 Andrew Pinski 2007-11-09 18:21:30 UTC
*** Bug 34041 has been marked as a duplicate of this bug. ***
Comment 29 Jason Merrill 2007-11-19 21:24:58 UTC
*** Bug 29436 has been marked as a duplicate of this bug. ***
Comment 30 Jason Merrill 2007-11-19 22:32:41 UTC
Subject: Bug 28834

Author: jason
Date: Mon Nov 19 22:32:30 2007
New Revision: 130298

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130298
Log:
note PR 28834

Modified:
    trunk/gcc/ChangeLog

Comment 31 Jason Merrill 2007-11-19 22:34:46 UTC
The crash is fixed by ignoring the attribute on the typedef.  If you want to apply may_alias to a struct type, you need to specify it in the type definition, either as

struct __attribute ((may_alias)) name { ... };

or

struct name { ... } __attribute ((may_alias));
Comment 32 Kaveh Ghazi 2008-02-07 19:14:19 UTC
Jason - Should the fix for PR28834 (AKA PR29436) be backported to 4.2/4.1?

I still see errors from mayalias-2.c on 4.2.  (4.1 doesn't have the testcase, but I suspect it still has the bug.)



Comment 33 nicbrown 2019-08-15 11:05:51 UTC Comment hidden (spam)