runtimeverification / javamop

Runtime verification system for Java, using AspectJ for instrumentation.
http://fsl.cs.illinois.edu/javamop
MIT License
45 stars 37 forks source link

JavaMOP not working with tradebeans and tradesoap #250

Open JesperStromblad opened 6 years ago

JesperStromblad commented 6 years ago

Hi, I am trying to run JavaMOP on Dacapo benchmark. However, I am getting this exception only on two workloads.

Exception initializing client: org.apache.geronimo.kernel.config.LifecycleException: load of org.apache.geronimo.daytrader/daytrader-dacapo/2.2-SNAPSHOT/car failedorg.apache.geronimo.kernel.config.LifecycleException: load of org.apache.geronimo.daytrader/daytrader-dacapo/2.2-SNAPSHOT/car failed at org.apache.geronimo.kernel.config.SimpleConfigurationManager.loadConfiguration(SimpleConfigurationManager.java:328) at org.apache.geronimo.kernel.config.SimpleConfigurationManager.loadConfiguration(SimpleConfigurationManager.java:281) at org.apache.geronimo.kernel.config.SimpleConfigurationManager.loadConfiguration(SimpleConfigurationManager.java:256) at org.apache.geronimo.kernel.config.KernelConfigurationManager.loadConfiguration(KernelConfigurationManager.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.geronimo.gbean.runtime.ReflectionMethodInvoker.invoke(ReflectionMethodInvoker.java:34) at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:124) at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:832) at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57) at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35) at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96) at org.apache.geronimo.kernel.config.EditableConfigurationManager$$EnhancerByCGLIB$$6b66b72e.loadConfiguration() at org.dacapo.daytrader.DaCapoClientRunner.initialize(DaCapoClientRunner.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.dacapo.daytrader.Launcher.initialize(Launcher.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.dacapo.harness.Tradesoap.prepare(Tradesoap.java:45) at org.dacapo.harness.Benchmark.run(Benchmark.java:163) at org.dacapo.harness.TestHarness.runBenchmark(TestHarness.java:199) at org.dacapo.harness.TestHarness.main(TestHarness.java:152) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at Harness.main(Unknown Source) Caused by: org.apache.geronimo.kernel.config.InvalidConfigException: Error starting configuration gbean org.apache.geronimo.daytrader/daytrader-dacapo/2.2-SNAPSHOT/car at org.apache.geronimo.kernel.config.KernelConfigurationManager.load(KernelConfigurationManager.java:181) at org.apache.geronimo.kernel.config.SimpleConfigurationManager.loadConfiguration(SimpleConfigurationManager.java:313) ... 33 more Caused by: org.apache.geronimo.gbean.InvalidConfigurationException: Configuration gbean failed to start org.apache.geronimo.daytrader/daytrader-dacapo/2.2-SNAPSHOT/car reason: Unable to deserialize GBeanState in classloader: [org.apache.geronimo.kernel.config.MultiParentClassLoader id=org.apache.geronimo.daytrader/daytrader-dacapo/2.2-SNAPSHOT/car] at org.apache.geronimo.kernel.config.KernelConfigurationManager.load(KernelConfigurationManager.java:164) ... 34 more

Instrumentation code is -

aspect BaseAspect { pointcut notwithin() : !within(sun..) && !within(java..) && !within(javax..) && !within(com.sun..) && !within(org.dacapo.harness..) && !within(org.apache.commons..) && !within(org.apache.geronimo..) && !within(net.sf.cglib..) && !within(mop..) && !within(javamoprt..) && !within(rvmonitorrt..) && !within(com.runtimeverification..); }

public aspect ArrayDeque_NonNullMonitorAspect implements com.runtimeverification.rvmonitor.java.rt.RVMObject { public ArrayDeque_NonNullMonitorAspect(){ }

    // Declarations for the Lock
  static ReentrantLock ArrayDeque_NonNull_MOPLock = new ReentrantLock();
   static Condition ArrayDeque_NonNull_MOPLock_cond = ArrayDeque_NonNull_MOPLock.newCondition();

   pointcut MOP_CommonPointCut() : !within(com.runtimeverification.rvmonitor.java.rt.RVMObject+) && !adviceexecution() && BaseAspect.notwithin();
    pointcut ArrayDeque_NonNull_insertnull(Object e) : ((call(* ArrayDeque.add*(..)) || call(* ArrayDeque.offer*(..)) || call(* ArrayDeque.push(..))) && args(Object+) && args(e)) && MOP_CommonPoin    tCut();
    before (Object e) : ArrayDeque_NonNull_insertnull(e) {
           ArrayDeque_NonNullRuntimeMonitor.insertnullEvent(e);
     }

}

Thank you.

jtoman commented 6 years ago

This is an old bug, but I recently ran into this as well. FWIW, the solution is as follows.

The issue is caused by the fact that the GBeans are serialized by Java's writeObject but the classes do not declare a serialUID. As a result, at runtime the Java runtime computes its own serialUID, which is based off of the non-private members of the class declaration. By adding non-private fields (as I believe your example is doing) the serial UID computed by Java ends up being different than the one stored in the serialized GBean, causing an "InvalidClassException" which eventually causes the error you see.

There are two solutions: do not add any members that can change the UID computed by Java (the exact algorithm can be found here https://docs.oracle.com/javase/6/docs/platform/serialization/spec/class.html#4100) or before any instrumentation compute the default UID according to the current members of the class, insert it into the class definition, and then perform your instrumentation.

john5f35 commented 6 years ago

I'm currently maintaining DaCapo, I'm looking into this at the moment.

A few things:

jtoman commented 6 years ago

Hello @johnjiabinzhang, are you a maintainer of javamop? If not, we should probably have this discussion on in the dacapo issue tracker.

john5f35 commented 6 years ago

Hi @jtoman, I'm not a maintainer of JavaMOP. Let's do it in the DaCapo issue tracker.