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

Doyle, James, K jdoyle at iso-ne.com
Wed May 1 21:03:48 UTC 2024


Hi Sebastian,

> I think I can confirm that there is a regression.

Thanks for reproducing the regression, your test makes sense to me, and I think it is similar to the scenario we have with Kubernetes debug containers (separate filesystems, but same PID namespace).

I noticed some of the other recent Pull Request comments on https://github.com/openjdk/jdk/pull/17628:

> should it not be comparing pid namespace ids and not pids?

and wanted to give a little feedback.  I think more refined approaches to figuring out whether the target JVM is in the same PID namespace make sense and could be an improvement, but it's still different from figuring out whether the target JVM has the same filesystem (specifically, I guess, the filesystem containing /tmp or java.io.tmpdir).  That seems like the crucial thing for deciding what socket file path to read, and whether /tmp is sufficient or /proc/<pid>/root/tmp is needed.  I can think of a couple different approaches to the filesystem issue:

1. There is some Linux kernel information that can be obtained about the jcmd process and the target JVM process to figure out unequivocally what their root filesystems are from the host's point of view, and whether they're the same.  (I don't know what this might be, though!)
2. jcmd treats it as a heuristic and attempts each way during the socket file read - first /proc/<pid>/root/tmp and then /tmp.
3. jcmd has some option or environment variable where the user can tell it the socket file path.

Do you agree that these are the types of choices available?

Thanks,
Jim



More information about the serviceability-dev mailing list