Hello
I further pursued the approach
- Rebased the Linux implementation [1], implemented the permission check
using JSR 203 and the Unix domain sockets using JEP 380.
- Applied the same changes to the AIX implementation [2].
- Switched Linux to an FFM based kill implementation [3], completely
getting rid of JNI.
- Updated the macOS implementation [4], implemented the permission
check using JSR 203 and the Unix domain sockets using JEP 380.
- Switched macOS to an FFM based kill and sysctl implementation [5],
completely getting rid of JNI.
I ran the serviceability test suite on Linux and macOS and it passes. I
manually verified that I can attach to JVMs using local builds.
I could not test on AIX.
[1]
https://github.com/marschall/jdk/commit/3a7796daadad7c9d2d85e9e4623f170baecc0e41
[2]
https://github.com/marschall/jdk/commit/962729e0bfb6b7d86af303f25c6670d407d1d2d9
[3]
https://github.com/marschall/jdk/commit/7b5f1bf6f55458a7f69f50b8fdf4986e22202559
[4]
https://github.com/marschall/jdk/commit/93372a124eca6078fde5597c2498b381a4ef5dfa
[5]
https://github.com/marschall/jdk/commit/c5faf9655bbb85cc3ed9b2a7ef15b08ab83d1d8b
Cheers
Philippe
On 20.04.22 22:13, Philippe Marschall wrote:
Hello
I hope this is the right mailing list. I recently had a look at the
Linux attach provider implementation and could not help but noticing
that a large part, if not all of it, could be replaced with Java.
Besides getting rid of the C code this should allow us to unify the AIX,
Linux and macOS implementations under a single Unix implementation.
The permission check can be implemented using JSR 203 [1] to access uid,
gid and file mode and using jdk.internal.misc.VM to get the euid and egid.
Reading and writing to Unix domain sockets can be done through JEP 380 [2].
Sending SIGQUIT to a process could in theory done through JEP 102 [3]
however sending SIGQUIT to self is currently blocked. This is required
for the self attach mechanism. There a very small C function is still
needed for now, this is hopefully portable.
I did a small prototype [4]. The tier1 suite runs and I can attach to a
local JVM.
The overhead will likely be a bit higher as we go through more JDK
abstractions.
[1] https://jcp.org/en/jsr/detail?id=203
[2] https://openjdk.java.net/jeps/380
[3] https://openjdk.java.net/jeps/102
[4]
https://github.com/marschall/jdk/
commit/207dac7e4d1bd65450bbd2c9e14d33fc34b7cebc
Cheers
Philippe