Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 170075 - Incorrect Call Graph (Method Enter/Leave) instrumentation in JVMTI profiler
Summary: Incorrect Call Graph (Method Enter/Leave) instrumentation in JVMTI profiler
Status: CLOSED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: TPTP (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Alexander N. Alexeev CLA
QA Contact:
URL:
Whiteboard: closed471
Keywords:
Depends on:
Blocks: 148629
  Show dependency tree
 
Reported: 2007-01-10 07:46 EST by Ivan Popov CLA
Modified: 2016-05-05 11:02 EDT (History)
8 users (show)

See Also:


Attachments
Test Case (553 bytes, text/java)
2008-05-04 14:35 EDT, Asaf Yaffe CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Popov CLA 2007-01-10 07:46:13 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Install TPTP profiler 4.3.0 and New Java Profiler
2. Get Harmony JRE snapshot from http://harmony.apache.org
3. Set up New Agent Controller to use Harmony JRE
4. Run Eclipse and create HelloWorld application
5. Start profiling HelloWorld and choose Execution Time Analysis
6. See VerifyError exception dump appeared in output console


More information:
Harmony JVM rejects HelloWorld class instrumented by TPTP JVMTI profiler and throws VerifyError exception:

Uncaught exception in main:
java.lang.VerifyError: (class: HelloWorld, method: <init>()V) Uninitialized reference usage
	at java.lang.VMClassRegistry.defineClass(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:70)
	at java.net.URLClassLoader.findClassImpl(URLClassLoader.java:1137)
	at java.net.URLClassLoader$4.run(URLClassLoader.java:619)
	at java.net.URLClassLoader$4.run(URLClassLoader.java:1)
	at java.security.AccessController.doPrivilegedImpl(Unknown Source)
	at java.security.AccessController.doPrivileged(Unknown Source)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:621)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader$SystemClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
FAILED to invoke JVM.

It looks like that Martini CG instrumentation is incorrect, though it is accepted by Sun and JRockit JRE. Below is explanation from Harmony developers.

-----------------------------------------------------
According Java Specification 1.5 Chapter 4.11.1.1:
“There is never an uninitialized class instance in a local variable in code protected by an exception handler.”

There is a disassembler of instrumented class:

Method name:"<init>" public Signature: 6=()void
Attribute "Code", length:95, max_stack:2, max_locals:1, code_length:45
  0: getstatic #41=<Field mytests.HelloWorld.sm_bAlreadyInvoked70056 boolean>
  3: ldc_w #62=<Integer 70056>
  6: invokestatic #53=<Method org.eclipse.tptp.martini.CGProxy.MethodEnter (boolean,int)void>
  9: getstatic #41=<Field mytests.HelloWorld.sm_bAlreadyInvoked70056 boolean>
 12: ifne 19
 15: iconst_1
 16: putstatic #41=<Field mytests.HelloWorld.sm_bAlreadyInvoked70056 boolean>
 19: aload_0
 20: invokespecial #8=<Method java.lang.Object.<init> ()void>
 23: goto_w 28
 28: nop
 29: ldc_w #62=<Integer 70056>
 32: invokestatic #57=<Method org.eclipse.tptp.martini.CGProxy.MethodLeave (int)void>
 35: nop
 36: return
 37: ldc_w #62=<Integer 70056>
 40: invokestatic #57=<Method org.eclipse.tptp.martini.CGProxy.MethodLeave (int)void>
 43: nop
 44: athrow
Exceptions (count: 1):
  start: 19, end: 29, handler: 37, type: 0 /* finally */
Attribute "LineNumberTable", length:6, count: 1
  line: 3 at pc: 19
Attribute "LocalVariableTable", length:12, count: 1
  slot#0: name: 12=this, type: 13=mytests.HelloWorld (pc: 19 length: 26)

As you can see try block protects a class constructor. Uninitialized reference of class is contained in local variables on this basic block.

Why reference VM doesn’t reject such class, this is a question of investigation. And I could take some time.

I suggest several ways to complete test run:
1.	Change classes instrumentation to correct one. 
2.	Disable verifier and repeat TPTP tests run. 

To disable verifier VM need to give an option in command line: -XDvm.use_verifier=false.
-----------------------------------------------------
Comment 1 Asaf Yaffe CLA 2007-01-10 07:52:06 EST
I have confirmed this to be an issue with the Martini Call Graph instrumentation adaptor.
Comment 2 Ivan Popov CLA 2007-02-16 04:49:36 EST
Verifier in Harmony JVM was updated to follow RI behavior and don't reject those classes which are accepted by RI. Now, the current implementation of TPTP JVMTI profiler works with Harmony as well.
Comment 3 Asaf Yaffe CLA 2007-04-12 01:51:55 EDT
Based on the latest Harmony test results, I recommend to lower the priority of this bug. Retargetting to future.
Comment 4 Asaf Yaffe CLA 2008-04-03 08:16:29 EDT
We found that this issue must be resolved, otherwise the Java 6 verifier will reject instrumented constructors. Adding dependency on the Java 6 support enhancement and targeting for 4.5.i7
Comment 5 Asaf Yaffe CLA 2008-04-13 06:20:59 EDT
In plan for 4.5.i7, pending check-in of Java 6 support (bug 148629)
Comment 6 Asaf Yaffe CLA 2008-05-04 14:35:57 EDT
Created attachment 98566 [details]
Test Case
Comment 7 jkubasta CLA 2008-05-23 09:01:44 EDT
Deferral to future with PMC approval
Comment 8 Harm Sluiman CLA 2009-01-21 10:17:22 EST
cleaning up assignees
Comment 9 Kathy Chan CLA 2009-02-23 13:40:15 EST
Mass update of P1 enhancements and defects targetted to future to P2.
Comment 10 Paul Slauenwhite CLA 2009-06-30 06:56:04 EDT
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. Since this defect is more than 2 years old, it may be no longer relevant. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this defect is resolved as WONTFIX. If this defect is still relevant and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.
Comment 11 Kathy Chan CLA 2010-11-18 18:56:00 EST
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant enhancements/defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this enhancement/defect is verified/closed by the Project Lead since this enhancement/defect has been resolved and unverified for more than 1 year and considered to be fixed. If this enhancement/defect is still unresolved and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.