3 Replies Latest reply on Sep 13, 2019 4:36 AM by fercoli

    Testing Byteman on OpenJDK version 9-ea+170

    sannegrinovero

      Hello all,

       

      by reading the jigsaw-dev mailing list I'm aware that several things have been changing around agents, but I didn't see a conclusion.

       

      Testing now the Hibernate Search build on latest OpenJDK build 9-ea+170 I have the following errors:

       

      java.io.IOException: Can not attach to current VM
      at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.(HotSpotVirtualMachine.java:75)
      at jdk.attach/sun.tools.attach.VirtualMachineImpl.(VirtualMachineImpl.java:56)
      at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58)
      at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207)
      at org.jboss.byteman.agent.install.Install.attach(Install.java:451)
      at org.jboss.byteman.agent.install.Install.install(Install.java:161)
      at org.jboss.byteman.agent.install.Install.install(Install.java:116)
      at org.jboss.byteman.contrib.bmunit.BMUnitConfigState.loadAgent(BMUnitConfigState.java:516)
      at org.jboss.byteman.contrib.bmunit.BMUnitConfigState.pushConfigurationState(BMUnitConfigState.java:669)
      at org.jboss.byteman.contrib.bmunit.BMUnitRunner$1.evaluate(BMUnitRunner.java:73)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
      at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

       

      Running org.hibernate.search.test.backend.lucene.ScheduledCommitPolicyTest
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE! - in org.hibernate.search.test.backend.lucene.ScheduledCommitPolicyTest
      org.hibernate.search.test.backend.lucene.ScheduledCommitPolicyTest(org.hibernate.search.test.backend.lucene.ScheduledCommitPolicyTest) Time elapsed: 0 sec  <<< ERROR!
      java.lang.Exception: BMUnit test class configuration pushed without prior pop!
      at org.jboss.byteman.contrib.bmunit.BMUnitConfigState.pushConfigurationState(BMUnitConfigState.java:657)
      at org.jboss.byteman.contrib.bmunit.BMUnitRunner$1.evaluate(BMUnitRunner.java:73)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
      at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

       

      Running org.hibernate.search.test.backend.lucene.SharedReleasesLocksTest
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE! - in org.hibernate.search.test.backend.lucene.SharedReleasesLocksTest
      org.hibernate.search.test.backend.lucene.SharedReleasesLocksTest(org.hibernate.search.test.backend.lucene.SharedReleasesLocksTest)  Time elapsed: 0 sec  <<< ERROR!
      java.lang.Exception: BMUnit test class configuration pushed without prior pop!
      at org.jboss.byteman.contrib.bmunit.BMUnitConfigState.pushConfigurationState(BMUnitConfigState.java:657)
      at org.jboss.byteman.contrib.bmunit.BMUnitRunner$1.evaluate(BMUnitRunner.java:73)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
      at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

       

      I hope I'm simply missing an argument to be passed to the JVM ?

       

      Thanks

        • 1. Re: Testing Byteman on OpenJDK version 9-ea+170
          adinn

          HI Sanne,

           

          Thanks for reporting this. I believe this is caused by a recent restriction to control 'self-hoisting' (i.e. loading of an agent into the current JVM process) without advance warning. Self-hoisting is exactly what the BMUnit runner class does. BMUnit ensures that a  Byteman agent is loaded into the running test JVM before it executes any tests labelled with BMRule or BMScript annotations.

           

          The restriction on self-hoisting was introduced into JDK9 so users could guarantee that deployed code would fail if it attempted install an agent to augment its own privileges. Personally, I agree with the readily offered argument that this an unnecessary sop to the paranoid or, perhaps even, incompetent (if you don't know what your deployed code might get up to then perhaps you ought not to be in charge of a deployment ;-). Still, some people really think a tin-foil hat suits them.

           

          Yet, I will also happily admit that this is a pretty harmless restriction (much less so than tin-foil headgear -- those metal edges can cut!) in that it can be disabled by giving suitable advance warning when the JVM is started. If you set the system property jdk.attach.allowSelfAttach to the String true when you start up the test JVM then the restriction will be lifted and BMUNit will be allowed to hoist the Byteman agent into the test JVM.

           

          If you are running with maven then modify your pom to set this property in your surefire or failsafe configuration

           

            ...

            <configuration>

              ...

              <systemProperties>

                <property>

                  <name>jdk.attach.allowAttachSelf</name>

                  <value>true</value>

                </property>

                ...

              <systemProperties>

              ...

           

           

          If you are running from a script or using command line arguments to run the test form maven then set the property using the -D command line flag

           

            java -Djdk.attach.allowAttachSelf=true ...

           

          Note that you cannot fix this by setting the property from your code after JVM startup. jdk.attach.allowAttachSelf is a read-only property.

           

          regards,

           

           

          Andrew Dinn

          1 of 1 people found this helpful
          • 2. Re: Testing Byteman on OpenJDK version 9-ea+170
            sannegrinovero

            Thanks! I've set the new property and can confirm it works fine.

            1 of 1 people found this helpful
            • 3. Re: Testing Byteman on OpenJDK version 9-ea+170
              fercoli

              +1

              1 of 1 people found this helpful