Bug 5135 - Compiler segfault on non public Interfaces
Summary: Compiler segfault on non public Interfaces
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2001-12-16 13:56 UTC by olivier
Modified: 2004-05-20 22:40 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-19 15:27:17


Attachments
a.tgz (386 bytes, application/x-gzip )
2003-05-21 15:17 UTC, olivier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description olivier 2001-12-16 13:56:00 UTC
gcj compilation aborts with a segfault in the following
situation:

Class: 
  a/A.java    a package protected interface.
  a/B.java    a class that implement interface A.
  a/b/C.java  a class in a different package that import
              both A and B and try to use a constant
              defined in interface A.

Note that "A" and therefore "A.Hello" are protected in package "a" and should
not be accessible from class "C". Sun JDK correctly reports:   

  tournesol$ javac a/b/C.java
  a/b/C.java:3: a.A is not public in a; cannot be accessed from outside
  package
  import a.A;
         ^
         a/b/C.java:10: a.A is not public in a; cannot be accessed from
         outside package
               System.out.println(A.HELLO);


but gcj gets confused by the fact that class "B" (also imported) is
public in package "a" and implements "A". It wrongly believes that "A"
is accessible and segfault.

Release:
gcc version 3.1 20011211 (experimental)

Environment:
Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../../program/cvs/gcc/configure --prefix=/usr/local/gcc --enable-shared --enable-threads=posix --enable-languages=c++,java
Thread model: posix
gcc version 3.1 20011211 (experimental)

How-To-Repeat:
gcj -C a/b/C.java
Comment 1 olivier 2001-12-16 13:56:00 UTC
Fix:
Unknown...
Comment 2 Tom Tromey 2001-12-16 18:51:24 UTC
From: Tom Tromey <tromey@redhat.com>
To: olivier@zipworld.com.au
Cc: gcc-gnats@gcc.gnu.org, Alexandre Petit-Bianco <apbianco@cygnus.com>
Subject: Re: java/5135: Compiler segfault on non public Interfaces
Date: 16 Dec 2001 18:51:24 -0700

 Olivier> Note that "A" and therefore "A.Hello" are protected in
 Olivier> package "a" and should not be accessible from class "C".
 
 First, thanks for your report.  It is concise and self-contained --
 exactly how I like bug reports.
 
 I looked at this a bit today.  gcj does correctly detect that A.HELLO
 is inaccessible, but unfortunately it crashes while trying to tell you
 that.
 
 The appended patch fixes the crash, but I think this patch is almost
 certainly incorrect.  I don't really understand the code in this
 function.  Something else I don't understand is that if you get rid of
 class `a.B', then the error in check_pkg_class_access is printed.  Why
 does the presence of B make a difference here?
 
 Tom
 
 Index: parse.y
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
 retrieving revision 1.333
 diff -u -r1.333 parse.y
 --- parse.y 2001/12/16 16:23:49 1.333
 +++ parse.y 2001/12/17 01:40:13
 @@ -9660,10 +9659,9 @@
  	  if (not_accessible_p (TREE_TYPE (decl), decl, type, 0))
  	    {
  	      parse_error_context 
 -		(qual_wfl, "Can't access %s field `%s.%s' from `%s'",
 +		(qual_wfl, "Can't access %s `%s' from `%s'",
  		 java_accstring_lookup (get_access_flags_from_decl (decl)),
 -		 GET_TYPE_NAME (type),
 -		 IDENTIFIER_POINTER (DECL_NAME (decl)),
 +		 GET_TYPE_NAME (TREE_TYPE (decl)),
  		 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
  	      return 1;
  	    }

Comment 3 daniel.bonniot 2003-04-21 23:41:44 UTC
From: Daniel Bonniot <Daniel.Bonniot@inria.fr>
To: gcc-gnats@gcc.gnu.org,  java-prs@gcc.gnu.org,  gcc-bugs@gcc.gnu.org, 
 nobody@gcc.gnu.org,  gcc-prs@gcc.gnu.org,  olivier@zipworld.com.au
Cc:  
Subject: Re: java/5135: Compiler segfault on non public Interfaces
Date: Mon, 21 Apr 2003 23:41:44 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5135
 
 I reproduced this bug in gcc version 3.3 20030412 (Debian prerelease)
 
 Here is the output:
 $ gcj-3.3 -C a/b/C.java
 a/b/C.java: In class `a.b.C':
 a/b/C.java: In method `a.b.C.hello()':
 a/b/C.java:10: internal compiler error: Segmentation fault
 

Comment 4 Dara Hazeghi 2003-05-12 12:50:16 UTC
From: Dara Hazeghi <dhazeghi@yahoo.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: java/5135: Compiler segfault on non public Interfaces
Date: Mon, 12 May 2003 12:50:16 -0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- 
 trail&database=gcc&pr=5135
 
 Hello,
 
 I can confirm this bug still exists on gcc 3.2, 3.3 branch and mainline  
 (20030511).
 
 Dara
Comment 5 Andrew Pinski 2003-05-26 18:47:31 UTC
See Dara's comment.
Comment 6 Andrew Pinski 2004-01-08 08:34:35 UTC
Related to bug 11075.
Comment 7 Andrew Pinski 2004-05-20 22:40:26 UTC
Fixed on the mainline.