Skip to content

Always call classMatchesCachedVersion in rememberClass - #15037

Merged
mpirvu merged 1 commit into
eclipse-openj9:masterfrom
dsouzai:classChainFix
May 12, 2022
Merged

mpirvu merged 1 commit into
eclipse-openj9:masterfrom
dsouzai:classChainFix

Conversation

@dsouzai

@dsouzai dsouzai commented May 10, 2022 •

Copy link
Copy Markdown
Contributor

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

dsouzai commented May 10, 2022

Copy link
Copy Markdown
Contributor Author

@mstoodle could you please review/merge?

@JamesKingdon fyi

@mpirvu mpirvu self-assigned this May 10, 2022
Comment thread runtime/compiler/env/J9SharedCache.cpp Resolved

@mpirvu mpirvu left a comment

Copy link
Copy Markdown
Contributor

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

dsouzai commented May 11, 2022

Copy link
Copy Markdown
Contributor Author

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

@mpirvu

mpirvu commented May 11, 2022

Copy link
Copy Markdown
Contributor

jenkins test sanity all jdk17

@mstoodle mstoodle left a comment

Copy link
Copy Markdown
Contributor

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