On Tue, 27 Oct 2026 00:38:33 GMT, Yasumasa Suenaga <[email protected]> wrote:
>> This change prevents NullPointerException in the clhsdb dumpcodecache >> command. >> >> `CodeCache.createCodeBlobWrapper()` causes NullPointerException. >> `CodeHeap.findStart()` may return null and `CodeHeap.iterate()` passes it to >> `CodeCache.createCodeBlobWrapper()` as the `cbStart` argument. >> >> https://github.com/openjdk/jdk/blob/bbd629b0ef4d0ac7fbc2b33bb76170fd15060cd3/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/CodeHeap.java#L111 >> >> So this change makes `createCodeBlobWrapper()` return null when `cbStart` is >> null. >> >> ### Testing >> * jtreg:hotspot/jtreg/serviceability/sa/ >> >> $ make test TEST="jtreg:hotspot/jtreg/serviceability/sa/" >> ============================== >> TEST TOTAL PASS FAIL ERROR >> SKIP >> jtreg:test/hotspot/jtreg/serviceability/sa 81 76 0 0 >> 5 >> ============================== >> >> * Manual verification: dumpcodecache does not output NullPointerException. >> >> $ jhsdb clhsdb --pid 654607 >> Attaching to process 654607, please wait... >> hsdb> dumpcodecache >> <snip> >> hsdb> >> >> Note: `hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java` passed, but >> printed NullPointerException before this change. There is no >> NullPointerException in the test output after the change. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > >> CodeHeap.findStart() may return null > > Can be it happened in normal case? > I feel the error / exception should be reported / thrown because `null` from > `findPtr()` means the address is not in CodeCache - it shouldn't be happened > in `dumpcodecache` at least. > > As Chris said, were there test(s) in failure? Is the failure covered in jtreg > test(s)? @YaSuenag > Can be it happened in normal case? > I feel the error / exception should be reported / thrown because null from > findPtr() means the address is not in CodeCache - it shouldn't be happened in > dumpcodecache at least. Yes, it can be reproduced easily. Dumping codecache for the simple sleep program printed NullPointerException. The findStart() returns null when the block is free in CodeHeap while the arugument pointer is within the correct range. https://github.com/openjdk/jdk/blob/bbd629b0ef4d0ac7fbc2b33bb76170fd15060cd3/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/CodeHeap.java#L89-L92 > As Chris said, were there test(s) in failure? Is the failure covered in jtreg > test(s)? All SA tests, except for skipped ones, passed and TestDebugInfoDecode doesn't check NullPointerException in the output. ------------- PR Comment: https://git.openjdk.org/jdk/pull/33568#issuecomment-6432599590
