java/5691: super flag lost during method patching

toddastock@yahoo.com toddastock@yahoo.com
Thu Feb 14 08:46:00 GMT 2002


>Number:         5691
>Category:       java
>Synopsis:       super flag lost during method patching
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 14 08:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.1 20020213 (experimental)
>Organization:
>Environment:
System: Linux escher 2.4.9-21 #1 Thu Jan 17 14:16:30 EST 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure -enable-threads=posix --prefix=/home/tstock/local --disable-shared --enable-languages=c++,java
>Description:
In the processs of performing a patch on a expression within a synchronized block the CALL_USING_SUPER flag that was set is lost.  Leading to a recursive call of the function.  The difference being in the Java Assembler output where the super call to printStackTrace is done with invokevirtual instead of invokespecial.
>How-To-Repeat:
import java.io.*;
import java.util.*;

public class Test extends RuntimeException
  {

  private Throwable cause;

  public static void main(String[] args)
    {
      new Test().printStackTrace(new PrintWriter(new OutputStreamWriter(System.err)));
    }

  public void printStackTrace(PrintWriter pw)
    {
      synchronized (pw)
        {
          super.printStackTrace(pw);
          if (cause != null)
            {
              pw.println("--- Nested Exception ---");
              cause.printStackTrace(pw);
            }
        }
    }
  }
>Fix:
Index: parse.y
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.350
diff -u -r1.350 parse.y
--- parse.y	4 Feb 2002 02:38:16 -0000	1.350
+++ parse.y	14 Feb 2002 16:39:25 -0000
@@ -9395,6 +9395,7 @@
       tree qual_wfl = QUAL_WFL (q);
       tree ret_decl;		/* for EH checking */
       int location;		/* for EH checking */
+      int save_flag;
 
       /* 15.10.1 Field Access Using a Primary */
       switch (TREE_CODE (qual_wfl))
@@ -9442,9 +9443,11 @@
 	    CALL_USING_SUPER (qual_wfl) = 1;
 	  location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
 		      EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
+          save_flag = CALL_USING_SUPER (qual_wfl);
 	  *where_found = patch_method_invocation (qual_wfl, decl, type,
 						  from_super,
 						  &is_static, &ret_decl);
+          CALL_USING_SUPER(*where_found) = save_flag;
 	  if (*where_found == error_mark_node)
 	    {
 	      RESTORE_THIS_AND_CURRENT_CLASS;
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Java-prs mailing list