On Mon, 16 Nov 2026 11:04:41 GMT, Kevin Walls <[email protected]> wrote:

>> This implements "jcmd on core files" for Linux, and for MiniDumps on Windows 
>> (MacOS is "future work").
>> jcmd "revives" the VM memory and .so/.dll from the core/minidump, and runs 
>> the existing native diagnostic command parser and command implementations.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Kevin Walls has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Linux library list: use NT_FILE list and match for .so, to not count aot 
> cache (which is read only) as a library to avoid mapping from core (also 
> *.jsa).  Show revivalhelper retries only if above an interesting level, as 
> for Linux aarch64 two or three tries is common enough to be noisy if always 
> printing.
>  - test tweak

Hi Kevin,

I started taking a deeper look at this as I think it should be reaching the 
"polishing" phase. To that end I have a number of meta comments:
- I think we should move key bits of the code into a new class and file that 
makes it explicit what it is. If that class is made a friend of others then we 
can avoid localised "revival_init" logic.
- I don't like seeing `is_revived` on the common code paths where they will add 
overhead to every use. Not knowing exactly what is being avoided it is hard to 
suggest possible alternatives in some cases.
- There is inconsistent use of guarantee/assert checks for `is_revived`. I 
don't think we really need to guard this code against unintentional callers - 
especially if it gets relocated.
- There is a major lack of explanatory comments. Again code relocation makes it 
easier to document things and describe the big picture.

On the functional side it appears that there are places where you are trying to 
pretend that the revived VMThread is a JavaThread - which I can't see how it 
can work. You would be reading random memory as JavaThread fields, or using 
random memory as vtable entries. ??

I haven't yet looked into the actual librevival/revivalHelper code yet.

Thanks

src/hotspot/os/posix/mutex_posix.hpp line 99:

> 97:   bool try_lock();
> 98: 
> 99:   void clear_for_revive() {

Can we add comments to these revive functions to explain what they are doing 
and why. Something like:

// During crash revival mutexes could be locked but the code we execute in our 
revival actions expects
// to be able to acquire them. To facilitate that we simply zero the memory and 
reinitialize them. The
// original state is not relevant to the revival process.

src/hotspot/os/posix/threadLocalStorage_posix.cpp line 72:

> 70: }
> 71: 
> 72: uint64_t ThreadLocalStorage::revive(Thread* thread) {

Again please add some comments explaining why this is needed.

src/hotspot/os/windows/os_windows.cpp line 1347:

> 1345:   return 0;
> 1346: }
> 1347: 

Why do these not need real values on Windows?

src/hotspot/os/windows/os_windows.cpp line 4262:

> 4260:   int os_prio = GetThreadPriority(thread->osthread()->thread_handle());
> 4261:   if (os_prio == THREAD_PRIORITY_ERROR_RETURN) {
> 4262:     assert(Thread::is_revived(), "GetThreadPriority failed"); // Always 
> assert, unless revived.

Can't help but think that the revival check should be part of the assert 
mechanism, with a raw form assert that can be used for the revival code itself 
(though such asserts only seem useful during development of the feature).

src/hotspot/os/windows/os_windows.cpp line 5374:

> 5372:   } else {
> 5373:     TerminateProcess(GetCurrentProcess(), num);
> 5374:   }

I don't like adding a check for every thread exit. Can we not have a special 
exit function only used by the revival code?

src/hotspot/os/windows/os_windows.cpp line 6073:

> 6071: 
> 6072: void PlatformMutex::clear_for_revive() {
> 6073:   guarantee(Thread::is_revived(), "Must be in revived VM to revive 
> PlatformMutex");

You don't have this in the posix version

src/hotspot/os/windows/threadLocalStorage_windows.cpp line 66:

> 64: 
> 65: uint64_t ThreadLocalStorage::revive(Thread* thread) {
> 66:   // no-op on Windows but gives access to _thread_key

Please explain this - why do we not have to reinitialize like on Posix?

src/hotspot/share/jfr/support/jfrThreadLocal.cpp line 92:

> 90: #endif
> 91:   {
> 92:   if (!Thread::is_revived()) {

Again this overhead for every thread does not seem good.

src/hotspot/share/runtime/thread.cpp line 604:

> 602: struct revival_data vm_revival_data;
> 603: 
> 604: void* Thread::process_revival() {

Can we move all of this revival meta-data and functionality out of thread and 
into its own class please. I'd rather see something like 
`CrashAnalysis::is_active()` than `Thread::is_revived()` all over the place. 
This makes the code much clearer in intent than a simple name notion like 
"revive".

src/hotspot/share/services/diagnosticFramework.cpp line 156:

> 154:     thread = JavaThread::current();
> 155:   } else {
> 156:     thread = static_cast<JavaThread*>(Thread::current()); // avoid assert

This doesn't make sense. The assert will only fire if the current thread is not 
a JavaThread and if it is not a JavaThread then you can't just cast it to be a 
JavaThread!

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

Changes requested by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/31011#pullrequestreview-6033811210
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675654010
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675671625
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675680067
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675688208
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675706545
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675699809
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675713032
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675722254
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675759726
PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4675795984

Reply via email to