This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Calling ioctl with varargs on Linux/FreeBSD AMD64 from Java


Hi,


I'm the author of PureJavaComm (PJC), see

https://github.com/nyholku/purejavacomm

which is a drop in Pure Java replacement for Sun's
abandoned JavaComm and its Free RXTX replacement,
or in short, a library to access serial port from Java.

PJC builds on JNA to access the POSIX API.

It is pretty simple and uses the bare minimum of the
underlaying OS API:

namely open/close/read/write/select/ioctl/fctl

It works great on Mac OS X,Linux/Free BSD IA32, Solaris
and Windows.

But it crashes on Linux/FreeBSD AMD64.

For the past two months I've been trying to track this
down but not successfully.

It is 100% repeatable: I have a test case that opens
a serial port that uses a single (Java) thread and uses
select() to read/write data through a loopback cable
as fast as the hardware handshake allows -- sooner
or later it segfaults and it brings the JVM down with it.
But it typically transfers tens of thousands of messages
that are 250 characters, before it crashes.

Sometimes an Invalid Access exception is reported
in Java code, specifically inside the JNA call that
is trying to call the ioctl() function.

The access to the OS using JNA is simple, works on
the other platforms and has been triple double
checked to make sure the method signatures on Java/JNA
side match those of the C-headers.


I've been discussing this in the JNA list and Timothy
Wall, JNA author, suggested that this might be a
problem how the variable args (for ioctl()) are handled
by the libffi on AMD64.

Now I'm looking for suggestions, guesses, what ever
to get me further.... I'm short of things to try and
investigate.

Is there some way I can, for example, compare how a
C compiler and JNA/libffi call ioctl()?

br Kusti













Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]