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)
public interface LibC extends Library {
LibC libC = Native.load("c", LibC.class);
int TIOCGWINSZ = 0x40087468; // this is definitely correct, I've checked it with C
int ioctl(int fd, int request, winsize winsize);
}
public static int getWindowSize() {
val ttysize = new winsize();
val returnCode = libC.ioctl(0, TIOCGWINSZ, ttysize);
if (returnCode != 0) {
throw new RuntimeException("There was a problem calling ioctl(): " + returnCode);
}
return ttysize.ws_col;
}
for (int i = 0; i < 100; i++) {
System.out.println(getWindowSize());
}
running this code results in either:
- ioctl() returning -1
- SIGSEGV
- Illegal instruction: 4
- Heap corruption detected
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: