-
Notifications
You must be signed in to change notification settings - Fork 738
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
IllegalAccessError regression in internal testing introduced by #11708 #12285
Comments
@DanHeidinga Is there a reason we need the The spec states that:
and
see https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-5.html#jvms-5.4.3.5 When resolving a method, we never perform access checks on the param/ret types themselves, we only check that the method is visible to the caller. This means our current MH behaviour differs from our bytecode behaviour |
Is the IAE thrown by Hotspot as well? It would be good to confirm that the original test is "correct". The change was introduced here: be44482 as part of #2675 to make us compatible with the RI. As to Tobi's question, the access check is equivalent to the class loader constraint checks that happen when looking up a java method - see for example the code in lookupmethod.c that handles clconstriant calls |
Here is a small example that demonstrates the difference between hotspot and j9. Given the following:
and
With hotspot the result is:
with J9 its:
|
So you see that the even though hotspot doesnt allow access to In our case, the only place we differ is in 4) because we perform access checks on all method ret/params. We do not do this in 3). |
I think there are two potential problems. A) should 1) be failing at all? The reason we fail it is because if its an array, we look at the member access flags for the element type which will have B) There is clearly a difference between bytecode behaviour and MH behaviour with both J9 and hotspot, but maybe in case its fine. See alternate example below:
With hotspot:
with j9
So 2) passes but 3) and 4) fail. |
I think the correct behaviour in the first example is that 1, 2, 3 & 4 should pass, this implies that the hotspot behaviour is wrong (Note that in the second example there is consistency between 1, 3 & 4). But if the hotspot behaviour is correct then J9 shouldn't treat 3) and 4) differently. In the second example, I may just be misunderstanding the spec. My understanding is that 2, 3 & 4 should behave the same according to the "as bytecode behaviour" rules. |
@tajila are you comparing equivalent JDK11 releases in these tests? Or some other release? |
J9
hotspot
|
Ill try a more recent hotspot |
The behaviour is the same with
|
@tajila what does a JDK16 hotspot do with the |
If we assume the RI is correct, then I'd look at why we're failing example 1, case 4. My guess would be that our checks are using the wrong access bits - ie: protected rather than public for the array component class. |
JDK16 does the same as jdk11
We are failing it because of the way we've implemented
For arrays The thing is if we change the behaviour here, it is also going to change the behaviour of |
@tajila @DanHeidinga
c2/Caller.java
result:
RI's behavior does match the requirement for arg check, I reviewed the VM specification and found:
I believe the reason that example 1, 3/4 are inconsistent is because RI have 2 different version of the access check (one in Java with is used by the MH APIs: ie example 1, and an native impl that is used during vm resolution: ie example 4) where as OpenJ9 shares the same access check API between Java and native code. Given the spec/bytecode, my understanding is that the native access check impl from RI correctly matches the spec and is what we should be following. as to example 1 the Java API doc:
since TEST[] can be accessed in the test method (array access is based on component type access), I think this is a bug on RI's behavior? |
Based on the javap output, this is similar to RI's impl and should have same result |
I've created #12331 which changes the current |
@fengxue-IS that leaves us inconsistent with the RI for the |
We should also put together a straightfoward bug report and work with the RI to have |
(6 Apr 21) OpenJ9 community call update: An OpenJDK bug report will be opened soon. We will need to match the RI for the 0.26 release in case the bug report does not get addressed in our favor before the release. To match the RI, the behaviour needs to be split between the |
OpenJDK bug report: https://bugs.openjdk.java.net/browse/JDK-8266269 |
Update: https://bugs.openjdk.java.net/browse/JDK-8266269 have been resolved in OpenJDK for Java 17+. @DanHeidinga should we revert #12371 and continue with the fix in #12331? |
Yes, but as far as I can tell JDK-8266269 is only merged into JDK17+ so we should wait to merge to change our behaviour until we're sure that the 0.27 branches won't be refreshed from master. fyi @pshipton for awareness to ensure we don't refresh the release branch once this is addressed |
Also, Java 17+ will use OJDK MH by default so JDK-8266269 should be picked up by 17+ builds automatically, do we need to backport JDK-8266269 to the 8 & 11 extensions repo in the future when we decide to switch to OJDK MH on 8/11? |
Is there an extensions change, or just #12371? We won't be refreshing the 0.27 branch from master in the openj9 repo. We may pull other releases (IBM) from master before OJDK MH is backported to jdk8. |
JDK-8266269 is a OJDK MH change that is only available for Java 17+ in the extensions repo I guess the questions are:
|
My vote is to keep it as-is for the 0.27 release, and match the RI for 8, 11, 16. Perhaps JDK-8266269 will be backported for the OpenJDK release in Oct. We can decide if we want to make any updates for this release. I'd prefer not to put anything in the extensions we don't want in 0.27, as usually I do refresh the 0.27 extensions branches with the latest, as long as that is feasible/possible. |
I agree with Peter, assuming there aren't any tests in 8/11 that will fail due to this.
We should propose the OJDK backport now if we want it for Oct. |
I don't see this being backported anytime soon, we should move this to 0.29? |
JDK-8266269 is available for JDK17+. OJDK MH has been enabled at |
There is an IllegalAccessError regression in internal testing, caused by #11708
Internal reference 145127.
The text was updated successfully, but these errors were encountered: