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

Improve backend error handling #11136

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Improve backend error handling #11136

merged 1 commit into from
Sep 20, 2024

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented Sep 19, 2024

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

- Fix debug logging for #11088--attempt to create an exception that is its own
  cause fails.
- In case the parser is used after closing, throw an `IllegalStateException`
  instead of UB.
@kazcw kazcw self-assigned this Sep 19, 2024
@kazcw kazcw added the CI: No changelog needed Do not require a changelog entry for this PR. label Sep 19, 2024
@kazcw
Copy link
Contributor Author

kazcw commented Sep 19, 2024

* Fix debug logging for [NPE when accessing FileFormatSPI #11088](https://github.com/enso-org/enso/issues/11088) case--attempt to create an exception that is its own cause fails.

I think this change is necessary, but it doesn't seem to be sufficient: I'm still seeing the original exception, instead of the message attached when rethrowing.

[WARN] [2024-09-19T16:16:49.683] [enso.org.enso.interpreter.service.ExecutionService] Execution of function main failed (Cannot invoke "Object.getClass()" because "arg2Value" is null).
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "arg2Value" is null
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageContextFactory$ToHostValueNodeGen$Inlined.execute(PolyglotLanguageContextFactory.java:84)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$SharedInvokeNode.doDefault(PolyglotValueDispatch.java:4781)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$SharedInvokeNodeGen$Inlined.executeShared(PolyglotValueDispatchFactory.java:10501)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$InvokeNode.doDefault(PolyglotValueDispatch.java:4821)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$InvokeNodeGen.executeImpl(PolyglotValueDispatchFactory.java:10729)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)
	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:669)
	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:602)
	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:586)
	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedRuntimeSupport.callProfiled(OptimizedRuntimeSupport.java:266)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.invoke(PolyglotValueDispatch.java:2662)
	at org.graalvm.polyglot/org.graalvm.polyglot.Value.invokeMember(Value.java:1023)
	at org.enso.base.polyglot.EnsoMeta.getType(EnsoMeta.java:16)

@@ -18,7 +18,7 @@ public static Value getType(String moduleName, String typeName) {
var ex =
new NullPointerException(
"Cannot get type for " + moduleName + " type: " + typeName + " at " + module);
ex.initCause(ex);
ex.initCause(e);
Copy link
Member

Choose a reason for hiding this comment

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

Oh, thanks for the catch.

byte[] inputBytes = input.toString().getBytes(StandardCharsets.UTF_8);
ByteBuffer inputBuf = ByteBuffer.allocateDirect(inputBytes.length);
inputBuf.put(inputBytes);
return parseTreeLazy(state, inputBuf);
}

public Tree parse(CharSequence input) {
var state = getState();
Copy link
Member

Choose a reason for hiding this comment

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

Ok, this kind of robustness check cannot hurt.

@kazcw kazcw added the CI: Ready to merge This PR is eligible for automatic merge label Sep 20, 2024
@mergify mergify bot merged commit e587d56 into develop Sep 20, 2024
37 of 38 checks passed
@mergify mergify bot deleted the wip/kw/compiler-exceptions branch September 20, 2024 13:23
jdunkerley pushed a commit that referenced this pull request Sep 26, 2024
- Fix debug logging for #11088 case--attempt to create an exception that is its own cause fails.
- In case the parser is used after closing, throw an `IllegalStateException` instead of UB. (This case is not known to occur and doesn't seem to be behind the #11121, but we should handle it more safely if it does.)

(cherry picked from commit e587d56)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants