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

Always call classMatchesCachedVersion in rememberClass #15037

Merged
merged 1 commit into from
May 12, 2022

Conversation

dsouzai
Copy link
Contributor

@dsouzai dsouzai commented May 10, 2022

See #15013 for more details.

It is possible for two J9Classes to have the same J9ROMClass but have
different class chains. However, because a class chain is stored into
the SCC using a key derived from the J9ROMClass, it isn't possible to
store different class chains that have the same first J9ROMClass in the
chain. This can lead to undefined behaviour as invalid AOT code can be
executed.

This PR fixes the issue by changing the code that assumes that if it
can find an existing class chain in the SCC for a given J9Class, that it
is valid for said J9Class. The code now always validates the class
chain.

Closes #15013

@dsouzai
Copy link
Contributor Author

dsouzai commented May 10, 2022

@mstoodle could you please review/merge?

@JamesKingdon fyi

@mpirvu mpirvu self-assigned this May 10, 2022
runtime/compiler/env/J9SharedCache.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

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

LGTM
Initially, I had some doubts about the ClassChainValidationCaching used in classMatchesCachedVersion(), but I think we are ok. I was afraid that we could call classMatchesCachedVersion() with a <j9class, existingClassChain> pair, store CCVResult::success in the cache, then later on call again classMatchesCachedVersion() with <j9class, anotherExistingClassChain> and use the cache to draw the wrong conclusion.
However, I think we are safe because for a ROMClass there could only be one existingClassChain, so the scenario with 'anotherExistingClassChain" cannot happen.

See eclipse-openj9#15013 for more
details.

It is possible for two J9Classes to have the same J9ROMClass but have
different class chains. However, because a class chain is stored into
the SCC using a key derived from the J9ROMClass, it isn't possible to
store different class chains that have the same first J9ROMClass in the
chain. This can lead to undefined behaviour as invalid AOT code can be
executed.

This commit fixes the issue by changing the code that assumes that if it
can find an existing class chain in the SCC for a given J9Class, that it
is valid for said J9Class. The code now always validates the class
chain.

Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
@dsouzai
Copy link
Contributor Author

dsouzai commented May 11, 2022

@mstoodle made requested changes; reworded it slightly to be more consistent with each other.

@mpirvu
Copy link
Contributor

mpirvu commented May 11, 2022

jenkins test sanity all jdk17

Copy link
Contributor

@mstoodle mstoodle left a comment

Choose a reason for hiding this comment

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

Thanks, @dsouzai

@mpirvu mpirvu merged commit d016af9 into eclipse-openj9:master May 12, 2022
@dsouzai dsouzai deleted the classChainFix branch February 3, 2023 16:21
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.

Discussion: Cache Class Chain in the J9Class struct
3 participants