Need some help in analyzing a mixed traceback #276
-
Using github.com/ebitengine/purego v0.7.1. The purpose of the attached Go code is to execute the JVM library libzip.so deflater from one byte array to another. This is a proof of concept. Good news:
So far, so good. I was able to load 3 required libraries and execute a few functions.
However, when I attempt to execute one function (the actual deflater), I see this:
I am not asking you to debug the attached program (main.go). I am looking for advice as to how one would diagnose what is going wrong in main.go or what am I supposed to gleam from the stack trace. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
For whatever it is worth, I had desk-checked. Also, here are the variable values going into the
|
Beta Was this translation helpful? Give feedback.
-
First thanks for using purego. The stack trace is almost always going to be useless in these situations since the issue is most likely caused by a disagreement of where the library expects an argument and where purego puts it. This usually happens because the function you are calling was defined incorrectly in the RegisterFunc function. I would try the following to solve this issue:
Also I'm not sure I understand why you are using the jvm to call into libzip when you can just download the C libzip.so from there website: https://libzip.org/ and run it directly without a jvm |
Beta Was this translation helpful? Give feedback.
I wrote a C-language equivalent and blew up in that too, the same JVM library function call, namely
Java_java_util_zip_Deflater_deflateBytesBytes
. All the simpler function calls work just fine in C and Go with purego.What's different? I am trying to deflate (compress, in normal English) a byte array. It turns out that byte arrays need help from some functions that are accessed via a vector stored in the primary JVM area that is represented with a pointer. The C calls look like this example:
(*env)->SetByteArrayRegion(env, inputArray, 0, sizeof(input), (jbyte*)input);
. There are several functions of the same form that are required to set up the input and extract the output for array-orien…