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

Fix Symbol$CompletionFailure crash when building CFG #6397

Merged
merged 26 commits into from
Jan 19, 2024

Conversation

msridhar
Copy link
Contributor

@msridhar msridhar commented Jan 14, 2024

Fixes #6396

It turns out the crash occurred inside the javax.lang.model.util.Elements#getAllMembers method, which was called to find the implementation of close() to invoke for a resource in a try-with-resources block. I don't know the exact cause, but it looks like that method tries to resolve all members in all superclasses of the argument, which is leading to a crash with this specific third-party jar file. I suspect the root cause of the crash is somewhere else. (Maybe in the Scala compiler? The jar seems to include Scala-generated classes.) But, as a workaround, it seems that if we search for the method more directly, only looking for members with the name "close", the crash is avoided. I'm not 100% thrilled with this fix, but it's the best I can come up with at this point to avoid this crash.

@msridhar msridhar changed the title [WIP] Fix Symbol$CompletionFailure crash when building CFG Fix Symbol$CompletionFailure crash when building CFG Jan 14, 2024
@msridhar msridhar marked this pull request as ready for review January 14, 2024 00:23
@msridhar msridhar requested a review from mernst January 14, 2024 00:23
mernst
mernst previously approved these changes Jan 14, 2024
Copy link
Member

@mernst mernst left a comment

Choose a reason for hiding this comment

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

Thanks!

@msridhar msridhar enabled auto-merge (squash) January 14, 2024 23:25
@mernst
Copy link
Member

mernst commented Jan 15, 2024

@msridhar Something in this pull request significantly degrades run-time performance. I've run CI 3 times and wasn't able to complete within the timeout any of those times. Could you look into improving that? Maybe use the original code, but catch the exception and if the exception is caught, use your new code.

@msridhar
Copy link
Contributor Author

@mernst I'm puzzled by the CI failure. It seems the only job failing is junit_jdk17, but junit_jdk11 and junit_jdk21 are both fine. And, I can run ./gradlew :checker:test on JDK 17 on my machine and I see no degradation in performance. Can I somehow increase logging on CI for the junit_jdk17 job to get a better idea of what could be happening, maybe by adding --info to the Gradle command? I can try poking at it by using the old code and catching the exception if it fails, but even if that works somehow (I am skeptical it will), I'd like to understand the root cause.

@mernst
Copy link
Member

mernst commented Jan 15, 2024

@msridhar I didn't see anything obviously non-performant in your code. Feel free to add any logging you want to this pull request; we can remove or comment it out before merging. I just triggered a new build (as opposed to re-running the failed build).

@mernst
Copy link
Member

mernst commented Jan 15, 2024

I'm seeing the failure on the master branch of my fork (https://github.com/mernst/checker-framework/commits/master/). I'm running some other tests now.

@msridhar msridhar disabled auto-merge January 15, 2024 22:54
@msridhar msridhar enabled auto-merge (squash) January 16, 2024 17:19
@msridhar msridhar disabled auto-merge January 17, 2024 06:44
// calling that method crashes with a Symbol$CompletionFailure exception. See
// https://github.com/typetools/checker-framework/issues/6396. The code below directly searches
// all supertypes for the method and avoids the crash.
Name closeName = names.fromString("close");
Copy link
Member

Choose a reason for hiding this comment

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

I think this call is potentially costly, which is why the Checker Framework doesn't use Names very often. So you could try making it a field.

@msridhar msridhar enabled auto-merge (squash) January 19, 2024 17:16
@msridhar
Copy link
Contributor Author

@mernst @smillst could I get a re-review on this one? No significant changes since the last approval

@msridhar msridhar merged commit e28b27c into typetools:master Jan 19, 2024
29 checks passed
@msridhar msridhar deleted the cfg-symbol-completion-failure branch January 19, 2024 17:21
wmdietl pushed a commit to eisop/checker-framework that referenced this pull request Jan 30, 2025
Co-authored-by: Michael Ernst <mernst@cs.washington.edu>
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.

Symbol$CompletionFailure crash when building CFG
3 participants