RFR: 8327114: Attach in Linux may have wrong behaviour when pid == ns_pid (Kubernetes debug container) [v5]

Sebastian Lövdahl duke at openjdk.org
Tue Jul 2 11:07:56 UTC 2024


On Mon, 1 Jul 2024 07:19:48 GMT, Sebastian Lövdahl <duke at openjdk.org> wrote:

>> 8327114: Attach in Linux may have wrong behaviour when pid == ns_pid (Kubernetes debug container)
>
> Sebastian Lövdahl has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adapt code style

Thanks for the confirmation Larry. I added a small comment about it.


diff --git src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
index 91ffea2ab87..0e76152c1e3 100644
--- src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
+++ src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
@@ -297,7 +297,7 @@ private String findTargetProcessTmpDirectory(long pid, long ns_pid) throws Attac
                 }
             }
 
-            // let's attempt to obtain the pid NS, best efforts to avoid crossing pid ns boundaries (as with a container)
+            // let's attempt to obtain the pid ns, best efforts to avoid crossing pid ns boundaries (as with a container)
             Optional<Path> curPidNS = Optional.empty();
 
             try {
@@ -311,7 +311,7 @@ private String findTargetProcessTmpDirectory(long pid, long ns_pid) throws Attac
                 // the process still exists, but we don't have privileges to read its procfs
             }
 
-            // recurse "up" the process hierarchy, if appropriate
+            // recurse "up" the process hierarchy if appropriate. PID 1 cannot have a parent in the same namespace
             final var havePidNSes = prevPidNS.isPresent() && curPidNS.isPresent();
             final var ppid = ph.get().parent();

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19055#issuecomment-2202761731


More information about the serviceability-dev mailing list