On Fri, 30 Aug 2024 00:07:50 GMT, Alex Menkov <amen...@openjdk.org> wrote:
> The fix improves Attch API protocol and implements updated protocol on > windows; shared code is ready to implement updated protocol support on other > platforms. > More detailed explanations on the 1st comment. > > Testing: tier1,tier2,tier3,tier4,hs-tier5-svc > manually tested backward compatibility (old tools can attach to current > VMs, current tools can attach to older VMs) on Windows with jdk21u and jdk8u. Currently Attach API has the following restrictions: 1. attach operation must have exactly 3 arguments; The value cannot be changed due backward compatibility - tools from previous release should be able to attach to current java processes, current tool should be able to work with older java processes; 2. each argument is resticted by 1024 symbols; this may be not enough as some arguments contain file paths. DCmd framework supports any number of command arguments, but encodes all arguments as a single attach operation arguement, so total length of all arguments are restricted by 1024 symbols. Attach API changes: - version of the protocol is bumped to 2; attach operation request v2 contains length of the request, so request can contain any number of argument of arbitrary length (for security reason request length is restricted by 256K); - for backward compatibility both client and server sides support both v1 and v2; if v2 is not supported by tool or target JVM, v1 is used for communication; new attach operation is implemented: "getVersion"; old VMs report "Operation not recognized", new VMs report supported version; - for testing purposes "jdk.attach.compat" system property is introduced to disable v2 protocol; Windows implementation: Windows implementation is different from other platforms (other platforms use unix sockets for communications). On Windows client enqueues operation by copying request parameters and executing remote thread in the target VM process which calls special exported function. Operation results are returned by using pipe (1-directional), created by the client; - to enqueue operation v2 new exported function has been added; only pipe name is passed to the target VM for v2 requests; - all operation parameters are passed through pipe, operation results are returned through the same pipe (it becomes 2-directional). ------------- PR Comment: https://git.openjdk.org/jdk/pull/20782#issuecomment-2319508258