RFR: 8253429: Error reporting should report correct state of terminated/aborted threads

Zhengyu Gu zgu at openjdk.java.net
Fri Sep 25 15:06:03 UTC 2020


On Fri, 25 Sep 2020 14:20:30 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> For some non-JavaThread, their object instances can outlast threads' lifespan. For example, we still can query/report
>> thread's state after thread terminated.
>> But the query/report currently returns wrong state. E.g. a terminated thread appears to be alive and seemly has valid
>> thread stack, etc.
>> This patch sets non-JavaThread's state to ZOMBIE just before it terminates, so that we can distinguish terminated
>> thread from live thread.
>> Also, thread should not report its SMR info, if it has terminated or it never started (thread->osthread() == NULL).
>> 
>> Note: Java thread does not have such issue, its thread object is deleted before thread terminates.
>
> src/hotspot/share/runtime/thread.cpp line 919:
> 
>> 917:     osthread()->print_on(st);
>> 918:
>> 919:     if (osthread()->get_state() != ZOMBIE) {
> 
> I'm not sure print_on(), as opposed to print_on_error() can ever be called with a ZOMBIE thread. I didn't expect any
> change in this method.

For thread, e.g. G1ConcurrentMarkThread, there is nothing to prevent calling _cm_thread->print_on(tty) after it
terminated, although, I can not find a case right now.

You prefer an assertion instead?

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

PR: https://git.openjdk.java.net/jdk/pull/341


More information about the hotspot-runtime-dev mailing list