Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use standard loading mechanism for jl.Object in Analyzer #4890

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

Merged
merged 4 commits into from
Aug 5, 2023

Conversation

gzm0
Copy link
Contributor

@gzm0 gzm0 commented Aug 5, 2023

Discovered as a simplification while working on #1626.

This also exposes a latent bug in the class loading sequence: the
Analyzer is built with the assumption that pending tasks never drop to
zero until the whole analysis is completed.

However, our loading sequence violated this assumption: since the
constructor of LoadingClass scheduled info loading immediately, it was
possible for info loading to complete before linking is requested on
the class. If this condition happens on the initial calling
thread (which itself is not tracked as a "task"), the pending task
count would drop to zero.

@@ -216,8 +215,6 @@ object Analysis {

def logError(error: Error, logger: Logger, level: Level): Unit = {
val headMsg = error match {
case MissingJavaLangObjectClass(_) =>
"Fatal error: java.lang.Object is missing"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sjrd, if you feel we need to keep this error, we have two alternatives:

  • Emit it in addition when the lookup of ObjectClass returns a nonExistentClass
  • Special case ClassInfo#link to emit a different error if className == ObjectClass (there is precedent for ClassInfo to behave differently if it is jlO, so it's not that bad).

Copy link
Member

Choose a reason for hiding this comment

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

The special error was only there because I thought it would crash the rest of the Analyzer if Object was missing. If it doesn't crash, it's fine.

Perhaps add a test where jl.Object is missing but there actually is another class? Currently the only test we have has no class at all.

@gzm0 gzm0 force-pushed the object-less-special branch from 7fbac61 to 5ae12d4 Compare August 5, 2023 09:44
@gzm0 gzm0 changed the title Use standard loading mechanisms for jl.Object in Analyzer Use standard loading mechanism for jl.Object in Analyzer Aug 5, 2023
@gzm0 gzm0 requested a review from sjrd August 5, 2023 09:44
@gzm0 gzm0 force-pushed the object-less-special branch from 5ae12d4 to 4fe66ec Compare August 5, 2023 10:10
@gzm0
Copy link
Contributor Author

gzm0 commented Aug 5, 2023

FWIW: Maybe we should split this into two commits. LMK if you'd like me to do this.

@gzm0 gzm0 force-pushed the object-less-special branch from 4fe66ec to c58c82b Compare August 5, 2023 12:32
@gzm0
Copy link
Contributor Author

gzm0 commented Aug 5, 2023

I have:

  • split-off the changes that fix queueing
  • added another commit that always validates superClass / interfaces (even for jl.Object). That is in fact necessary to avoid bad failure behavior in case the loaded data for jl.Object is bad (e.g. if it has a super class).

gzm0 added 4 commits August 5, 2023 15:25
The Analyzer is built with the assumption that the number of pending
tasks never drops to zero until the whole analysis is completed.

However, our loading sequence violated this assumption: since the
constructor of LoadingClass scheduled info loading immediately, it was
possible for info loading to complete before linking is requested on
the class. If this condition happens on the initial calling
thread (which itself is not tracked as a "task"), the pending task
count would drop to zero.
Discovered as a simplification while working on scala-js#1626.
@gzm0 gzm0 force-pushed the object-less-special branch from c58c82b to 42cd08d Compare August 5, 2023 13:27
@gzm0
Copy link
Contributor Author

gzm0 commented Aug 5, 2023

  • I have added an additional commit with a less trivial test.
  • I ran linker2_12/test on all intermediate commits.

@gzm0 gzm0 requested a review from sjrd August 5, 2023 13:40
@sjrd sjrd merged commit c4f1114 into scala-js:main Aug 5, 2023
@gzm0 gzm0 deleted the object-less-special branch August 6, 2023 08:25
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

Successfully merging this pull request may close these issues.

2 participants