gmu-swe/phosphor

Error occured when using the instrumented jdk

Opened this issue · 8 comments

Hi all,
I used maven 3.9.6 and openjdk-11.0.21 downloaded from adoptium.
uname -a Linux c83a8f293b33 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux (a new docker container, dockerfile: https://github.com/Yhcrown/zsh-in-docker/blob/master/Dockerfile)

here's the command:
mvn install --- Build Success
java -jar phosphor-driver.jar <jdk-11.0.21> --- finished instrumented (no error occured)

But when I changed the JAVA_HOME to the instrumented jdk directory, mvn command did not work:

mvn -version
Exception in thread "main" java.lang.NoSuchMethodError: 'boolean org.codehaus.plexus.classworlds.launcher.ConfigurationParser.lambda$loadGlob$0(java.lang.String, java.lang.String, java.io.File, java.lang.String, edu.columbia.cs.psl.phosphor.runtime.PhosphorStackFrame)'
        at java.base/java.io.File.listFiles(File.java:1303)
        at java.base/java.io.File.listFiles(File.java)
        at org.codehaus.plexus.classworlds.launcher.ConfigurationParser.loadGlob(ConfigurationParser.java:354)
        at org.codehaus.plexus.classworlds.launcher.ConfigurationParser.parse(ConfigurationParser.java:284)
        at org.codehaus.plexus.classworlds.launcher.Configurator.configure(Configurator.java:131)
        at org.codehaus.plexus.classworlds.launcher.Launcher.configure(Launcher.java:128)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:401)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:348)

I tried using jdk16, jdk17 and maven 3.8.8.
They all failed when i used the command mvn after changing the JAVA_HOME

Thanks for your help!

image

It looks like you are attempting to run Maven itself with Phosphor (Maven is a Java program). This should be supported, but you'll need to pass the flags to enable the java agent when invoking maven.

It looks like you are attempting to run Maven itself with Phosphor (Maven is a Java program). This should be supported, but you'll need to pass the flags to enable the java agent when invoking maven.

I want to use maven with instrumented jre to compile my code.

when i used 0.1.0-dev (https://github.com/gmu-swe/phosphor/tree/phosphor-0.1.0-dev), this issue will not happen.

How to pass the flags to enable the java agent when invoking maven? I tried mvn clean install -DargLine="-javaagent:/workspace/phosphor/Phosphor/target/Phosphor-0.1.0-SNAPSHOT.jar" but it didn't work

You can pass arguments to the JVM used by Maven using the MAVEN_OPTS environmental variable, e.g.

export MAVEN_OPTS="-javaagent:/workspace/phosphor/Phosphor/target/Phosphor-0.1.0-SNAPSHOT.jar"
mvn clean install

You can pass arguments to the JVM used by Maven using the MAVEN_OPTS environmental variable, e.g.

export MAVEN_OPTS="-javaagent:/workspace/phosphor/Phosphor/target/Phosphor-0.1.0-SNAPSHOT.jar"
mvn clean install

After adding this argument, the issue still exists, the error message changed to:
image

java.lang.NoSuchMethodException: java.lang.ClassLoader$$DefineAccessByGuice$$/0x000000080034c000.<init>(edu.columbia.cs.psl.phosphor.runtime.PhosphorStackFrame)
        at java.base/java.lang.Class.getConstructor0(Class.java:3517)
        at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2691)
        at java.base/java.lang.Class.getDeclaredConstructor(Class.java)
        at java.base/edu.columbia.cs.psl.phosphor.runtime.ReflectionMasker.getTaintConstructor(ReflectionMasker.java:119)
        at java.base/edu.columbia.cs.psl.phosphor.runtime.ReflectionMasker.prepareForCall(ReflectionMasker.java:139)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at com.google.inject.internal.aop.UnsafeClassDefiner.accessDefineClass(UnsafeClassDefiner.java:155)
        at com.google.inject.internal.aop.UnsafeClassDefiner$ClassLoaderDefineClassHolder.lambda$static$0(UnsafeClassDefiner.java:84)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
        at com.google.inject.internal.aop.UnsafeClassDefiner.tryPrivileged(UnsafeClassDefiner.java:130)
        at com.google.inject.internal.aop.UnsafeClassDefiner$ClassLoaderDefineClassHolder.<clinit>(UnsafeClassDefiner.java:83)
        at com.google.inject.internal.aop.UnsafeClassDefiner.findClassDefiner(UnsafeClassDefiner.java:119)
        at com.google.inject.internal.aop.UnsafeClassDefiner.define(UnsafeClassDefiner.java:112)
        at com.google.inject.internal.aop.ClassDefining.define(ClassDefining.java:44)
        at com.google.inject.internal.aop.AbstractGlueGenerator.glue(AbstractGlueGenerator.java:119)
        at com.google.inject.internal.aop.ClassBuilding.buildFastClass(ClassBuilding.java:255)
        at com.google.inject.internal.BytecodeGen$1.computeValue(BytecodeGen.java:176)
        at com.google.inject.internal.BytecodeGen$1.computeValue(BytecodeGen.java:173)
        at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
        at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
        at java.base/java.lang.ClassValue.get(ClassValue.java:116)
        at com.google.inject.internal.BytecodeGen.fastClass(BytecodeGen.java:157)
        at com.google.inject.internal.BytecodeGen.fastConstructor(BytecodeGen.java:135)
        at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:51)
        at com.google.inject.internal.ConstructorBindingImpl.<init>(ConstructorBindingImpl.java:73)
        at com.google.inject.internal.BindingBuilder.toConstructor(BindingBuilder.java:184)
        at com.google.inject.internal.BindingBuilder.toConstructor(BindingBuilder.java:158)
        at org.eclipse.sisu.wire.LocatorWiring.bindImplicitType(LocatorWiring.java:240)
        at org.eclipse.sisu.wire.LocatorWiring.bindBeanImport(LocatorWiring.java:222)
        at org.eclipse.sisu.wire.LocatorWiring.wire(LocatorWiring.java:91)
        at org.eclipse.sisu.wire.ElementAnalyzer.apply(ElementAnalyzer.java:150)
        at org.eclipse.sisu.wire.WireModule.configure(WireModule.java:79)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:409)
        at com.google.inject.spi.Elements.getElements(Elements.java:108)
        at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:160)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
        at com.google.inject.Guice.createInjector(Guice.java:87)
        at com.google.inject.Guice.createInjector(Guice.java:69)
        at com.google.inject.Guice.createInjector(Guice.java:59)
        at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:482)
        at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:207)
        at org.apache.maven.cli.MavenCli.container(MavenCli.java:648)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:277)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:206)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:283)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:226)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:407)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:348)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f965d95f7d0, pid=784346, tid=784360
#
# JRE version: OpenJDK Runtime Environment Temurin-16.0.2+7 (16.0.2+7) (build 16.0.2+7)
# Java VM: OpenJDK 64-Bit Server VM Temurin-16.0.2+7 (16.0.2+7, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x55f7d0]  AccessInternal::PostRuntimeDispatch<G1BarrierSet::AccessBarrier<286822ul, G1BarrierSet>, (AccessInternal::BarrierType)3, 286822ul>::oop_access_barrier(oopDesc*, long)+0x0
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /workspace/phosphor-examples/core.784346)
#
# An error report file with more information is saved as:
# /workspace/phosphor-examples/hs_err_pid784346.log
#
# If you would like to submit a bug report, please visit:
#   https://github.com/adoptium/adoptium-support/issues
#
[1]    784346 IOT instruction (core dumped)  mvn install

I see. We are still fighting a lot of compatibility issues with Phosphor's instrumentation and the many different flavors of OpenJDK 16+. If you are able to run your application under Java 8, you will find the greatest compatibility using the branch phosphor-0.0.5-dev. We are working on a set of better fixes to support a wider range of modern JVMs, but can not promise a release for at least 3-4 months.

I see. We are still fighting a lot of compatibility issues with Phosphor's instrumentation and the many different flavors of OpenJDK 16+. If you are able to run your application under Java 8, you will find the greatest compatibility using the branch phosphor-0.0.5-dev. We are working on a set of better fixes to support a wider range of modern JVMs, but can not promise a release for at least 3-4 months.

Thanks!
I switched to 0.0.5-dev and jdk8 (openjdk 1.8.0_392), after using same commands: mvn install, java -jar Phosphor/target/Phosphor-0.0.5-SNAPSHOT.jar /workspace/jdk8u392-b08 /workspace/jre-inst/, and then change JAVA_HOME to jre-inst, the new error occurred when i tried mvn --version:
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: edu/columbia/cs/psl/phosphor/struct/TaintedWithObjTag
image

I saw there's a same issue with #203 , but there's no solution.

You can't use the same command for the older Phosphor - you have to also add the -Xbootclasspath/a:path/to/Phosphor-0.0.5-SNAPSHOT.jar to the MAVEN_OPTS string.

You can't use the same command for the older Phosphor - you have to also add the -Xbootclasspath/a:path/to/Phosphor-0.0.5-SNAPSHOT.jar to the MAVEN_OPTS string.

Thanks, Dr. Jon! It works after adding this argument. (JDK1.8.0_392 and Phosphor-0.0.5, works with maven 3.8.8 but fails with maven 3.9.6)