-
Notifications
You must be signed in to change notification settings - Fork 713
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
TR_J9VM::getClassFromSignature: class loader of the result does not always match the class loader of the method #10397
Comments
I propose to modify the |
If you look at this method's signature
There's a constant pool there. What that means is that you're asking the question "Get me the J9Class that has a particular signature, that is visible to the J9Class that is associated with the
What do you mean by "the method" here; could you give a more concrete example of how |
When I talk about the method, I'm talking about the other 2 versions of The point is that right now jitserver assumes that |
Yeah there's definitely no guarantee that |
FWIW, it is always safe to cache using
Given the following situtation:
I don't think it's possible for |
The chain of calls is
So in the end we are asking the VM to give us a class based on name and
Excepting the special case above I would like to see and understand some examples where: I agree that our current caching scheme does not take into account the visibility aspect that Irwin mentioned, i.e., having cached the result of a query {j9method1, name} as {classLoader, name}, for another query involving {j9method2, name} we may find something in our cache, but the true result should have been NULL. |
We could try that and measure the increase in the number of messages. |
I am ok with this, but with the following amendment: if the loaders do not match, store an entry in the JITServer j9class cache indicating the classloader that needs to be used when accessing the {classloader,name} hashtable. |
I've actually realized something: So we could cache the classes where class loaders match and cache the classes where they don't match but the actual class loader is a system class loader. Then at retrieval we would just need to check 2 cases: one with class loader of the referencing class, and one with the system class loader. |
IIRC we treat class redefinition as class unloading, meaning that we delete from caches the classes that have been redefined. Classes from system class loaders cannot be unloaded, but they can be redefined. |
Right. But if I understand your above solution correctly, the referencing class would cache the class loader of the class retrieved by signature. Wouldn't it be possible that the same class references multiple classes by signature and thus we would need a map? Or am I misunderstanding the idea. |
Yes, we would need a linked list which would be used only for class unload or redefinition situations. |
I modified #10408 to only deliver the fix to incorrect signatures, but not to mismatching class unloaders since the former is a more serious bug but has a simple fix. |
When caching the result of `TR_J9ServerVM::getClassFromSignature` we incorrectly assume that the class loader of the referencing constant pool is the same as class loader of the resulting class. The problem is that when we delete unloaded classes from the cache, we use the actual class loader as key, instead of referencing one which will result in entries for unloaded classes not being deleted properly. This commit fixes it by keeping track of which class loaders reference a class in `ClassInfo`. When processing unloaded classes, we find correct entries for deletion by retrieving class loaders from `ClassInfo`. Closes: eclipse-openj9#10397 Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
When caching the result of `TR_J9ServerVM::getClassFromSignature` we incorrectly assume that the class loader of the referencing constant pool is the same as class loader of the resulting class. The problem is that when we delete unloaded classes from the cache, we use the actual class loader as key, instead of referencing one which will result in entries for unloaded classes not being deleted properly. This commit fixes it by keeping track of which class loaders reference a class in `ClassInfo`. When processing unloaded classes, we find correct entries for deletion by retrieving class loaders from `ClassInfo`. Closes: eclipse-openj9#10397 Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
In jitserver, we cache the result of
TR_J9VM::getClassFromSignature
call by{classLoader, signature}
key where the class loader is obtained from the method passed as an argument.However, I determined that in some cases, these 2 class loaders do not match. Sometimes, the class loader of the result is a system class loader, unlike the loader of the class owning the method.
This code explains some cases when the class loader might be different:
https://github.com/eclipse/openj9/blob/6a4bb2436cc5c15ad99da4f46e2881d9aaedd7b1/runtime/compiler/env/VMJ9.cpp#L6871-L6881
However, I see that sometimes the class loaders do not match, even if the above code is never executed. The reasons for that are not clear to me, but the conclusion is that we should not be using class loader of the method as a key when they do not match.
If the class loader is wrong, this will lead to segfaults if the class is unloaded. This problem is causing #10215 .
The text was updated successfully, but these errors were encountered: