You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Undefined behaviour when calling ioctl() multiple times #1632
"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. */structwinsize {
unsigned shortws_row; /* rows, in characters */unsigned shortws_col; /* columns, in characters */unsigned shortws_xpixel; /* horizontal size, pixels */unsigned shortws_ypixel; /* vertical size, pixels */
};
intioctl(int, unsigned long, ...);
I've also tried changing "request" type to long and defining constant as long TIOCGWINSZ = 0x40087468L;, but it's still the same.
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 int TIOCGWINSZ = 0x40087468;. I think widening should happen automatically in Java but I'm not sure if this could be a problem? Can you try declaring it as a long?
Also you say you've validated the value in C, but according to this page the value is 0x5413. That seems to indicate it comes from an ffi library. I'm not very familiar with this, but is it possible you need to use a different constant with ffi that you do with native?
@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.
Activity
matthiasblaesing commentedon Oct 18, 2024
Please specify:
valkeyword)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.
Gieted commentedon Oct 18, 2024
"val" comes from Lombok, you can replace it with "var" and it will work.
I've also tried changing "request" type to long and defining constant as
long TIOCGWINSZ = 0x40087468L;, but it's still the same.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.
Gieted commentedon Oct 18, 2024
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?
dbwiddis commentedon Oct 18, 2024
Second argument is a long but you've defined
int TIOCGWINSZ = 0x40087468;. I think widening should happen automatically in Java but I'm not sure if this could be a problem? Can you try declaring it as a long?Also you say you've validated the value in C, but according to this page the value is 0x5413. That seems to indicate it comes from an ffi library. I'm not very familiar with this, but is it possible you need to use a different constant with ffi that you do with native?Gieted commentedon Oct 18, 2024
@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.