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

[CLOSED] Investigate hashcode() and finalzie() non-determinism #4

Closed
3 tasks
aionbot opened this issue Dec 4, 2018 · 3 comments
Closed
3 tasks

[CLOSED] Investigate hashcode() and finalzie() non-determinism #4

aionbot opened this issue Dec 4, 2018 · 3 comments

Comments

@aionbot
Copy link

aionbot commented Dec 4, 2018

Issue created by yulongaion (on Friday May 04, 2018 at 18:31 GMT)

Approaches:

  • code injection
  • agent
  • method override
@aionbot
Copy link
Author

aionbot commented Dec 4, 2018

Comment by jeff-aion (on Friday May 04, 2018 at 20:32 GMT)

After initially looking like we couldn't use the Java JVMTI agent to replace a native method in java/lang/Object, through retransformClass (was having a problem with StackOverflowError), it turned out that this was just a special-case I needed to account for, from the ASM library.
It seems like the ASM library won't call visitCode on a native method, even if you strip the native modifier from it. This was leaving a non-native, yet code-less, method in the bytecode. Presumably, this retransformation bypasses verification, so the only problem was when attempting to run this empty method resulted in the StackOverflowError (probably because the empty method defined no stack requirement).
In this case, directly calling the visitCode method on the new node resulted, in the case where we removed the native modifier, seemed to result in a correctly-functioning VM and method.
In my experiments, it appears as though this will work for both Object.hashCode() and String.intern().

@aionbot
Copy link
Author

aionbot commented Dec 4, 2018

Comment by JunhanHu-aion (on Tuesday May 22, 2018 at 21:39 GMT)

https://stackoverflow.com/questions/2237720/what-is-an-objects-hash-code-if-hashcode-is-not-overridden/32454673#32454673
-XX:hashCode=n is a great option for testing.

@aionbot
Copy link
Author

aionbot commented Dec 4, 2018

Comment by jeff-aion (on Friday May 25, 2018 at 13:33 GMT)

I think that the last change required, in order to close this issue, is that we should reject any user-provided class which attempts to override finalize since we know that it won't work in our renaming scheme.

jeff-aion added a commit that referenced this issue Dec 5, 2018
-this exists as a container of our various ASM idioms and a place to hang unit test demonstrations of its usage
-the design is evolving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant