-
Notifications
You must be signed in to change notification settings - Fork 183
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 error in 3.12 during exception handling #1180
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1180 +/- ##
==========================================
- Coverage 87.45% 87.44% -0.01%
==========================================
Files 113 113
Lines 10236 10238 +2
Branches 4057 4059 +2
==========================================
+ Hits 8952 8953 +1
+ Misses 692 691 -1
- Partials 592 594 +2 ☔ View full report in Codecov by Sentry. |
I tried this commit with package org.acme;
public class MyThrowable extends RuntimeException {
public MyThrowable(String message) {
super(message);
}
public MyThrowable(String message, Throwable cause) {
super(message, cause);
}
@Override
public Throwable fillInStackTrace() {
return this;
}
} package org.acme;
public class MyClass {
public static void throwWithCause() throws Throwable {
throw new MyThrowable("error");
}
} <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>issue-reproducer</artifactId>
<name>Issue Reproducer</name>
<version>1.0.0-SNAPSHOT</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> def test_throwing():
import jpype
import jpype.imports
jpype.startJVM(classpath=[
'target/issue-reproducer-1.0.0-SNAPSHOT.jar',
])
from org.acme import MyClass
MyClass.throwWithCause() and a |
Found and corrected the second error point. Mind giving it another try on #1178? |
Can confirm this fixes the issue with |
Was the source compiled with debugging information? I think that the stacktrace is taking line numbers from the debug symbols. If it was generated using ASM then I believe you have to add the debug section after the procedure body. I have made dynamic procedures in the past, but I can’t say that I have tried making the debugging symbols.
|
It generated with ASM, but the generated ASM does not have debug symbols. I did test adding the debug symbols via ASM (via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
While trying to examine user reported issue #1178, I found that exception handling was getting caught on an unhandled exception. The root source of the issue it that if we don't set a traceback then it produced NULL to the PyExeception_SetTraceback. The exception was meaningless and (mostly) harmless, but due to other changes in Python it was not cleared by the PyErr_SetString method and thus remained set through to a PyObject_IsInstance call which then through a SystemError.
To fix this error I added an "if" statement to avoid setting the traceback if there is nothing meaningful to set. We should technically be checking every single return value from Python CAPI calls, rather than blindly plowing forward. But that would be a huge modification.
The underlying Python code that triggered the exception is odd....
If tb is NULL then it is an invalid input, but the message "may not be deleted" doesn't really tell the user anything about what has gone wrong.
It is unclear if this is the same problem the user was reporting as I wasn't able to replicate the exact issue reported. Though given it was down the same code path I suspect it will be addressed.