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

Disable late attach to self by default #18

Closed
wants to merge 43 commits into from

Conversation

pdbain-ibm
Copy link
Contributor

@pdbain-ibm pdbain-ibm commented Sep 14, 2017

Prevent a JVM from late attaching to itself unless a system property is set
either to "true" or an empty string, per the reference implementation. Enforce
this in Java 9 only. Update existing tests to enable this feature by default so
they will continue to run. Add new Java 9 tests to exercise this feature.

Fixes #126

Signed-off-by: Peter Bain [email protected]

@@ -102,6 +102,12 @@
private static String nameProperty;
private static String pidProperty;
private static int numberOfTargets;
/*[IF Sidecar19-SE]*/
/*[PR 132828 don't allow VM to attach to itself unless explicitly enabled ]*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely an internal ticket number - can you remove it and add any necessary context to the code or the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


<test>
<featureIds>
<featureId>113813</featureId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this featureId mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the Jazz work item for the refactoring of the Attach API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an OpenJ9 issue number rather than a internal Jazz #.

@DanHeidinga
Copy link
Member

I haven't looked at the test code yet - @smlambert can someone on your team take the lead on that?

@genie-openj9
Copy link

Can one of the admins verify this patch?

2 similar comments
@genie-openj9
Copy link

Can one of the admins verify this patch?

@genie-openj9
Copy link

Can one of the admins verify this patch?

Nicholas Coughlin and others added 2 commits September 21, 2017 11:11
Escape analysis may have to create initialization
code at the method start. If the first block is
part of a loop, it will create a new block to hold
these trees. However, the block test did not consider
whether the first block was in an improper region,
resulting in init code being placed inside a loop.

Signed-off-by: Nicholas Coughlin <[email protected]>
Adds missing arguments for Java 9 compile to allow visibility to
com.ibm.oti.util package.
Adds fork=true argument to ensure compiler uses correct Java version and
not Ant Java version
These changes ensure the tests are compiled with the Java version we
specified in the JAVA_BIN environment variable.

Signed-off-by: Mike Zhang <[email protected]>
exc.initCause(e);
throw exc;
}

if (descriptor.id().equals(AttachHandler.getVmId())) {
/*[IF Sidecar19-SE]*/
String allowattachselfValue = AttachHandler.allowAttachSelf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this mixed all lower case with camelCase. Can this be named allowAttachSelfValue for better readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, though I inserted an underscore before "value" to indicate that it's the value of allowAttachSelf.


<test>
<featureIds>
<featureId>113813</featureId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an OpenJ9 issue number rather than a internal Jazz #.

Properties props = vm.getSystemProperties();
props.list(System.out);
} catch (AttachNotSupportedException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the test be printing this unconditionally or should it be using an existing logger framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SelfAttacher is run as a child process whose stdout and stderr are captured by the TargetManager which can log it, though I don't bother doing so in this test.

String myId = VmIdGetter.getVmId();
System.err.println("myId="+myId);
boolean found = false;
for (int i = 0; i <10 && !found; ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no better way to get a VIrtualMachine id? Something without looping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playlist: updated.

SelfAttacher:
This isn't to get the vmID. It's cycling waiting for the attach API to initialize. There is OpenJ9 internal API to do that, but it's not portable.


import org.testng.log4testng.Logger;

/* This is was copied from org.openj9.test.attachAPI.TargetManager in Java8AndUp.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was it copied? Is there a way to avoid duplicating the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original TargetManager is in Java8AndUp, which shares no OpenJ9 test code with Java9AndUp. Maybe @smlambert or @llxia can suggest a better mechanism.

return target;
}

static void listIpcDir() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add javadoc for each of these methods? It looks like this method tries to recursively list all the files and directories under the java.io.tmpdir to the logger.debug() output. Should it only be called if the logger.debug() level is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add javadoc for each of these methods?
Done. Let me know if you want more explanation.

It looks like this method tries to recursively list all the files and directories under the java.io.tmpdir to the logger.debug() output. Should it only be called if the logger.debug() level is enabled?
Actually, it lists the contents of /tmp/.com_ibm_tools_attach, which will be a few files for each Java process. This method is mostly for post-failure analysis.

errOutput += currentLine + "\n";
}
}
while (targetOutReader.ready()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right code. I would expect a loop while readLine() is not returning null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, I don't want readline() to block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this actually stops readline from blocking - the stream is ready as soon as there are characters available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readline() will block until there is a newline, but the target process emits complete lines, so any blocking will be brief. The purpose of the code was to handle the case where stdout would close and stderr was still open but not receiving anything.

} finally {
try {
/* get anything that may have been in the buffers */
while (targetErrReader.ready()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above and in other places using ready().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

* This test must be invoked via testng. Running the main method will return only the status of the attach API.
*
*/
@SuppressWarnings({"nls","boxing"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use SuppressWarnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

@@ -0,0 +1,30 @@
/* Copyright (c) 2015, 2017 IBM Corp. and others
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the difference between src_latest and src_current? I'm not aware of why there are two...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a kludge to handle the API differences between the two JCL versions in the builds.

keithc-ca and others added 4 commits September 22, 2017 16:35
also make sure all streams are closed

Signed-off-by: Keith W. Campbell <[email protected]>
Attempt to work around timeouts cloning this repo in the CI builds
by cloning less material.  This is fine since the build doesn't
commit back to that repo (or other repos for that matter)

Issue eclipse-openj9#116

Signed-off-by: Dan Heidinga <[email protected]>
Prevent a JVM from late attaching to itself unless a system property is set
either to "true" or an empty string, per the reference implementation.  Enforce
this in Java 9 only. Update existing tests to enable this feature by default so
they will continue to run.  Add new Java 9 tests to exercise this feature.

Signed-off-by: Peter Bain <[email protected]>
pshipton and others added 3 commits September 25, 2017 11:40
…kout

Use shallow clone of the openj9-openjdk-jdk9 repo in travis build
While resolving bootstrap method handles, TypeNotPresentException is
currently thrown if a class is not found since we rely upon the
MethodType API.  But, NoClassDefFoundError should be thrown if a class
is not found while resolving bootstrap method handles. This change
translates TypeNotPresentException to NoClassDefFoundError while
resolving bootstrap method handles.

Signed-off-by: Babneet Singh <[email protected]>
Changes for OpenJ9 issue eclipse-openj9#126

Signed-off-by: Peter Bain <[email protected]>
@pdbain-ibm
Copy link
Contributor Author

Pushed the changes, not fully tested yet.

DanHeidinga and others added 10 commits September 25, 2017 13:49
Translate TypeNotPresentException to NoClassDefFoundError
During refactoring of the attach API, certain classes were being replaced due
to legacy build scripts and needed to be replaced.  This is no longer the case.

Signed-off-by: Peter Bain <[email protected]>
update preprocessor builder and nature
remove unnecessary builders and natures

Signed-off-by: Keith W. Campbell <[email protected]>
Remove tooling to restore original attach API code
Replace J9VM and JIT repo references with OpenJ9
Make IdleTuningGcOnIdle optimization is covered/included part of the
option(Xtune:virtualized) which grouped the optimizations relevant for virtualized
environment.

Issue: eclipse-openj9#124
Signed-off-by: Parameswaran Selvam <[email protected]>
@pdbain-ibm pdbain-ibm closed this Sep 27, 2017
@pdbain-ibm
Copy link
Contributor Author

Will open a new pull request for a single commit.

@pdbain-ibm
Copy link
Contributor Author

In re Dan's comment above, no: git wouldn't let me rebase & squash, so I abandoned this pull request and created another.

SueChaplain added a commit to SueChaplain/openj9 that referenced this pull request Nov 14, 2017
Adding the detailed build instructions for creating
an OpenjDK V9 with OpenJ9 binary for Windows.

Created as a completely separate section in the existing
build instructions. No attempt to merge instructions
for platforms yet.

[ci skip]

Work supports issue at
ibmruntimes/openj9-openjdk-jdk9#18

Issue eclipse-openj9#18

Signed-off-by: Sue Chaplain <[email protected]>
AlenBadel pushed a commit to AlenBadel/openj9 that referenced this pull request Nov 22, 2017
Adding the detailed build instructions for creating
an OpenjDK V9 with OpenJ9 binary for Windows.

Created as a completely separate section in the existing
build instructions. No attempt to merge instructions
for platforms yet.

[ci skip]

Work supports issue at
ibmruntimes/openj9-openjdk-jdk9#18

Issue eclipse-openj9#18

Signed-off-by: Sue Chaplain <[email protected]>
amicic pushed a commit to amicic/openj9 that referenced this pull request Jan 16, 2018
JamesKingdon pushed a commit to JamesKingdon/openj9 that referenced this pull request Apr 18, 2019
Adding the detailed build instructions for creating
an OpenjDK V9 with OpenJ9 binary for Windows.

Created as a completely separate section in the existing
build instructions. No attempt to merge instructions
for platforms yet.

[ci skip]

Work supports issue at
ibmruntimes/openj9-openjdk-jdk9#18

Issue eclipse-openj9#18

Signed-off-by: Sue Chaplain <[email protected]>
hzongaro pushed a commit to hzongaro/openj9 that referenced this pull request Mar 31, 2020
…pe-queries

Switch to value type query methods from ClassEnv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.