bcdev / jpy

A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
Apache License 2.0
187 stars 37 forks source link

SIGSEGV starting python #166

Open Jbiloki opened 5 years ago

Jbiloki commented 5 years ago

I am implementing this class in Java to instantiate a python object:

public class MyClass{
    private PyModule myObject;
    public void MyClass(){
        try{
            // Prepare required system properties like 'jpy.jpyLib' and others
            Properties properties = new Properties();
            InputStream inputStream = getClass().getResourceAsStream("jpyconfig.properties");
            properties.load(inputStream);
            properties.forEach((k, v) -> System.setProperty((String) k, (String) v));
            PyLib.startPython();
            PyModule myObject = PyModule.importModule("os");
        } catch(Exception e){
            System.out.println(e);
        }
    }

    public List<String> classify(List<String> taggedQuery){
        System.out.println(taggedQuery);
        PyLib.startPython();
        System.out.println(PyLib.isPythonRunning());
        System.out.println(this.myObject.call("path"));
        return taggedQuery;
    }
}

But this returns an error code of:

[info] # [info] # A fatal error has been detected by the Java Runtime Environment: [info] # [info] # SIGSEGV (0xb) at pc=0x0000000133aa9187, pid=81334, tid=69383 [info] # [info] # JRE version: OpenJDK Runtime Environment (11.0.2+9) (build 11.0.2+9) [info] # Java VM: OpenJDK 64-Bit Server VM (11.0.2+9, mixed mode, tiered, compressed oops, g1 gc, bsd-amd64) [info] # Problematic frame: [info] # C [Python+0x2b187] _PyFrame_New_NoTrack+0x1a [info] # [info] # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again [info] # [info] # An error report file with more information is saved as: [info] # /Users/biloki/nlp-general/hs_err_pid81334.log [info] [thread 68871 also had an error] [info] # [info] # If you would like to submit a bug report, please visit: [info] # http://bugreport.java.com/bugreport/crash.jsp [info] # The crash happened outside the Java Virtual Machine in native code. [info] # See problematic frame for where to report the bug. [info] #