-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Undefined behaviour when calling ioctl() multiple times #1632
Comments
Please specify:
I'm missing the reasoning/proof, that this is a bug in JNA. I have yet to see segfaults not caused by issues in the bindings. |
"val" comes from Lombok, you can replace it with "var" and it will work. /*
* Window/terminal size structure. This information is stored by the kernel
* in order to provide a consistent interface, but is not used by the kernel.
*/
struct winsize {
unsigned short ws_row; /* rows, in characters */
unsigned short ws_col; /* columns, in characters */
unsigned short ws_xpixel; /* horizontal size, pixels */
unsigned short ws_ypixel; /* vertical size, pixels */
};
int ioctl(int, unsigned long, ...); @Structure.FieldOrder(value = {"ws_row", "ws_col", "ws_xpixel", "ws_ypixel"})
class winsize extends Structure {
public short ws_row;
public short ws_col;
public short ws_xpixel;
public short ws_ypixel;
} I've also tried changing "request" type to long and defining constant as My reasoning for it being an issue is JNA related, is that for non-crash case, GetLastError() returns [14] Bad address, which to my understanding cannot happen because of a typo in bindings. |
Sorry for a confusion earlier, I've just discovered that I wasn't using Temurin JDK, but GraalVM. In fact the issue doesn't seem to occur when using Temurin. Are there any known issues related to JNA not being compatible with GraalVM? |
Second argument is a long but you've defined
|
@dbwiddis LibC Constants can have different values for each platform, the best way to get correct value is to write a simple C program that prints it. As I said in my last comment the issue seems to be with GraalVM (regular JIT, not the AOT compiled version). I'm not sure how JNA works after the hood, but it might be that GraalVM has more agrresive GC that frees the allocated memory before JNA call finishes. |
JNA version: 5.15.0
JVM: GraalVM CE 17.0.9+9.1 (build 17.0.9+9-jvmci-23.0-b22)
OS: macOS 14.7
CPU: Apple M1 (64-bit)
running this code results in either:
The text was updated successfully, but these errors were encountered: