[jep442 / foreign function] Crash when calling ioctl function
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Aug 24 13:53:09 UTC 2023
Hi,
Ioctl is a variadic function - see manpage:
```
int ioctl(int fd, unsigned long request, ...);
```
As such, you need to use a Linker.Option.firstVariadicArg when linking,
to denote how many variadic arguments your function descriptor contains
(I believe in your case you have 4 variadic arguments, so the first
variadic index should be 2?)
Cheers
Maurizio
On 24/08/2023 14:41, Guillaume Nodet wrote:
> Hi everybody
>
> I've been trying to port the JLine library to JEP 442 and earlier
> previews (nice work, I'm eagerly waiting for its GA release) every
> once in a while, but I'm stuck on a call for which I can't find my way
> around.
>
> The call is the ioctl function [1] which has untyped parameters, but
> whatever I've been feeding it crashes the JVM. I've been successfully
> using this method with JNA [2] and a plain small JNI library [3], and
> after having spent countless hours, I must admit I can't find what's
> happening....
>
> Here's a very small reproducer:
> https://github.com/gnodet/jep442-ioctl
>
> Any suggestions?
>
> Cheers,
> Guillaume Nodet
>
> [1] http://man7.org/linux/man-pages/man4/tty_ioctl.4.html
> [2]
> https://github.com/jline/jline3/blob/master/terminal-jna/src/main/java/org/jline/terminal/impl/jna/linux/CLibrary.java#L34
> [3]
> https://github.com/fusesource/jansi/blob/master/src/main/native/jansi.c#L64-L76
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230824/8e4f81bf/attachment-0001.htm>
More information about the panama-dev
mailing list