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

Disallow thread enable/disable JVMTI_EVENT_SAMPLED_OBJECT_ALLOC #6042

Merged
merged 1 commit into from
Jun 11, 2019

Conversation

JasonFengJ9
Copy link
Member

Disallow thread enable/disable JVMTI_EVENT_SAMPLED_OBJECT_ALLOC

JVMTI_EVENT_SAMPLED_OBJECT_ALLOC is enabled or disabled globally to match RI behaviour.
Throws JVMTI_ERROR_ILLEGAL_ARGUMENT if there is an attempt to thread enable/disable.

Note: this is to address a JTReg Test Failure - serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorEventsForTwoThreadsTest.java:

Exception in thread "main" java.lang.RuntimeException: Sampling event is thread enabled, that is unexpected.
	at MyPackage.HeapMonitorEventsForTwoThreadsTest.main(HeapMonitorEventsForTwoThreadsTest.java:46)

With this PR, the test has following output:

## Set event notifications error: 103

which is same as RI.

Additional note: this test (and the name HeapMonitorEventsForTwoThreadsTest.java) is misleading, the failure messages are identical for first and second thread [1]. It might give an impression that the SetEventNotificationMode() failed at second thread but indeed failed at first thread and the second thread serves no purpose from my perspective.

RI only allows JVMTI_EVENT_SAMPLED_OBJECT_ALLOC to be enabled or disabled globally though JVMTI specification doesn't include Sampled Object Allocation in the list of events that cannot be controlled at the thread level.

OpenJ9 matches RI behaviours.

[1] https://github.com/ibmruntimes/openj9-openjdk-jdk11/blob/2a60f1f273a2c29b411ec9c4d9263d8ff5434529/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.c#L762-L773
[2] https://docs.oracle.com/en/java/javase/12/docs/specs/jvmti.html#SetEventNotificationMode

Reviewer: @DanHeidinga
FYI: @gacholio

Signed-off-by: Jason Feng fengj@ca.ibm.com

Copy link
Contributor

@gacholio gacholio left a comment

Choose a reason for hiding this comment

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

More formatting than content, which I strongly dislike.

@gacholio
Copy link
Contributor

gacholio commented Jun 6, 2019

Should we update the new JVMTI test to test this case instead of relying on jtreg?

@JasonFengJ9
Copy link
Member Author

Modified the test to check the thread enable case, also relax 1 for the disable case to allow a sampling event which might escape before disable().
In addition, reverted code format changes, only fixed un-initialized values.

@gacholio please have another look.

@gacholio
Copy link
Contributor

jenkins test sanity plinux jdk11

@gacholio
Copy link
Contributor

Test fails:

12:55:54  Output from test:
12:55:54   [OUT] *** Testing [1/1]:	testDefaultInterval
12:55:54   [OUT] Allocated a byte array with size 524288
12:55:54   [OUT] com.ibm.jvmti.tests.samplingObjectAllocation.soae001.enable(thread) failed as expected with: -1
12:55:54   [OUT] *** Test took 10 milliseconds
12:55:54   [OUT] FAILED
12:55:54   [OUT] 
12:55:54   [ERR] exception thrown: 
12:55:54   [ERR] type: 2	Error: 103  JVMTI_ERROR_ILLEGAL_ARGUMENT
12:55:54   [ERR] 		Failed to enable JVMTI_EVENT_SAMPLED_OBJECT_ALLOC event
12:55:54   [ERR] 		Location: com/ibm/jvmti/tests/samplingObjectAllocation/soae001.c -> [Java_com_ibm_jvmti_tests_samplingObjectAllocation_soae001_enable():96]
12:55:54   [ERR] 
12:55:54   [ERR] com.ibm.jvmti.tests.util.AgentHardException: 
12:55:54   [ERR] type: 2	Error: 103  JVMTI_ERROR_ILLEGAL_ARGUMENT
12:55:54   [ERR] 		Failed to enable JVMTI_EVENT_SAMPLED_OBJECT_ALLOC event
12:55:54   [ERR] 		Location: com/ibm/jvmti/tests/samplingObjectAllocation/soae001.c -> [Java_com_ibm_jvmti_tests_samplingObjectAllocation_soae001_enable():96]
12:55:54   [ERR] 
12:55:54   [ERR] 	at com.ibm.jvmti.tests.util.ErrorControl.checkErrors(ErrorControl.java:71)
12:55:54   [ERR] 	at com.ibm.jvmti.tests.util.TestSuite.run(TestSuite.java:87)
12:55:54   [ERR] 	at com.ibm.jvmti.tests.util.TestRunner.main(TestRunner.java:60)

@JasonFengJ9
Copy link
Member Author

@gacholio the test should be good now, please launch another PR build to verify.

@gacholio
Copy link
Contributor

jenkins test sanity zlinux jdk11

@JasonFengJ9
Copy link
Member Author

Failed again, looking at it.

JVMTI_EVENT_SAMPLED_OBJECT_ALLOC is enabled or disabled globally to
match RI behavior;
Throws JVMTI_ERROR_ILLEGAL_ARGUMENT if there is an attempt to thread
enable/disable;
Modified the test to check the thread enable case;
Minor code format refactoring.

Signed-off-by: Jason Feng <fengj@ca.ibm.com>
@JasonFengJ9
Copy link
Member Author

The test failed even though the harness printed OK:

Test result: FAILED
Output from test:
 [OUT] *** Testing [1/1]:	testDefaultInterval
 [OUT] Allocated a byte array with size 524288
 [OUT] com.ibm.jvmti.tests.samplingObjectAllocation.soae001.enable(thread) failed as expected with: -1
 [OUT] *** Test took 6 milliseconds
 [OUT] OK

This is due to the

[ERR] com.ibm.jvmti.tests.util.AgentHardException: 
 [ERR] type: 2	Error: 103  JVMTI_ERROR_ILLEGAL_ARGUMENT
 [ERR] 		Failed to enable JVMTI_EVENT_SAMPLED_OBJECT_ALLOC event
 [ERR] 		Location: com/ibm/jvmti/tests/samplingObjectAllocation/soae001.c -> [Java_com_ibm_jvmti_tests_samplingObjectAllocation_soae001_enable():96]

Changed SetEventNotificationMode() error to softError, verified that make _cmdLineTester_jvmtitests_soae_3 passes.

@gacholio please launch another PR build, thanks.

@gacholio gacholio merged commit 22792ec into eclipse-openj9:master Jun 11, 2019
@JasonFengJ9 JasonFengJ9 deleted the notthread branch June 11, 2019 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants