RFR: 8299665: /proc/self/stat parsing in libmanagement broken by execname with spaces
Kevin Walls
kevinw at openjdk.org
Wed May 24 20:39:54 UTC 2023
On Wed, 24 May 2023 20:03:47 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:
> How do you test the issue is fixed now? Is there any test case which fails without your fix and passes with it?
Hi - I tested manually, renaming the java executable to something with a space, then query the OperatingSystem MBean, and see something like: CommittedVirtualMemorySize = (java.lang.Long) 36202319872 (which is the same/similar to another run
when not renamed). The problem is seeing a completely wrong value, like: CommittedVirtualMemorySize = (java.lang.Long) 0
These are lines like:
$ cat /proc/9496/stat
9496 (java) S 625 9495 607 34823 9635 1077936192 12024 0 0 0 156 22 0 0 20 0 28 0 2172294643 36260237312 30463 18446744073709551615 93928094162944 93928094166632 140724289571696 0 0 0 4 0 16800975 0 0 0 -1 11 0 0 0 0 0 93928094174456 93928094175248 93928124657664 140724289577708 140724289577894 140724289577894 140724289581032 0
That's a different run, where 36260237312 was the value we wanted. If "java" becomes "this is java" (with 2 spaces), then we read field 21, not field 23 from the line of data and show zero.
It's quite a niche thing to do so I didn't add a test that copied the java binary under test to a new name with a space in it...
The code that does the strrchr to scan from the last ) and then parses the remainder has been with us for some time. 8-)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14107#issuecomment-1561893976
More information about the serviceability-dev
mailing list