Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occured when using the instrumented jdk #211

Open
Yhcrown opened this issue Jan 13, 2024 · 12 comments
Open

Error occured when using the instrumented jdk #211

Yhcrown opened this issue Jan 13, 2024 · 12 comments

Comments

@Yhcrown
Copy link

Yhcrown commented Jan 13, 2024

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

@jon-bell
Copy link
Collaborator

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.

@Yhcrown
Copy link
Author

Yhcrown commented Jan 14, 2024

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

@jon-bell
Copy link
Collaborator

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

@Yhcrown
Copy link
Author

Yhcrown commented Jan 18, 2024

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

@jon-bell
Copy link
Collaborator

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.

@Yhcrown
Copy link
Author

Yhcrown commented Jan 21, 2024

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.

@jon-bell
Copy link
Collaborator

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.

@Yhcrown
Copy link
Author

Yhcrown commented Jan 22, 2024

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)

@Yhcrown
Copy link
Author

Yhcrown commented Nov 11, 2024

I recently found that The Maven still crashes if I use control flow tracking instrumented jdk. I tried Phosphor-0.0.5 with mvn 3.8.8, 3.9.5 and 3.9.9, all of them fail when initialize the mvn command. The error log is too long, can be reproduced by just mvn -version

@jon-bell
Copy link
Collaborator

Would you please try using a version of maven prior to 3.6.3?

@Yhcrown
Copy link
Author

Yhcrown commented Nov 12, 2024

Thanks for the reply.

mvn 3.6.3 still not works well when executingmvn testfor most projects. The error message said there are verifyerror mainly from org/codehaus/plexus/.

Also, even when i tried control tracking phosphor just by command, some verification errors often occurred, and the error log always show the different reason, some are related to register. Is that normal? I' not 100% sure if this is caused by my code or Phosphor. Does the version after 0.0.5 improve the compatibility of control tracking?

@jon-bell
Copy link
Collaborator

It is very challenging to support newer versions of Java with Phosphor. Hence, I am able to offer to help with basic troubleshooting, but development for this project is effectively in retirement right now. It is not normal to receive VerifyError exceptions. Without knowing what your code is (but guessing that you are writing some other instrumentation to integrate with Phosphor, based on your issue #212 ), it is extremely challengintg to offer insights or suggestions on how to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants