RFR: JDK-8299790: os::print_hex_dump is racy [v4]
Thomas Stuefe
stuefe at openjdk.org
Mon Aug 7 10:33:27 UTC 2023
> Tiny fix for a tiny problem.
>
> `os::print_hex_dump` uses `os::is_readable_pointer` to check the to-be-printed memory for readability; `os::is_readable_pointer` uses `SafeFetch` to probe the memory for access, which is good, but then, by the time we actually print that information, we reread the memory location again. It may be unreadable now (either because the region had been unmapped or protected by a concurrent thread), and we would crash the VM.
>
> The patch rewrites the function to not use `os::is_readable_pointer`, but to use `SafeFetch` to read from memory directly and then use the result of that read for printing. That requires a bit of bit fiddling, since we only can read word-wise, but the hex-dump could be in units between bytes and qwords.
>
> Tests: manual and GHA-driven gtests on all platforms. The gtests test this function exhaustively.
Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
- Merge branch 'master' into JDK-8299790-os-print-hex-dump-should-use-SafeFetch
- remove superfluous include
- feedback Aleksey; small code reshuffle
- remove debug output from gtest
- JDK-8299790-os-print-hex-dump-should-use-SafeFetch
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/14895/files
- new: https://git.openjdk.org/jdk/pull/14895/files/cafd075d..ed0c8774
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=14895&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=14895&range=02-03
Stats: 48384 lines in 1035 files changed: 26858 ins; 16138 del; 5388 mod
Patch: https://git.openjdk.org/jdk/pull/14895.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14895/head:pull/14895
PR: https://git.openjdk.org/jdk/pull/14895
More information about the hotspot-runtime-dev
mailing list