On Sat, 16 Oct 2021 15:58:21 GMT, Daniel D. Daugherty <dcu...@openjdk.org> wrote:
>> The `NULL` target thread being passed in is actually handled by the baseline >> code: >> >> >> ThreadsListHandle tlh; >> if (tlh.includes(target)) { >> >> >> `tlh.includes(target)` returns `false` when `target` is `NULL/nullptr`. >> I just made the already handled situation more explicit. >> >>> Why would the caller not check if the target is dead? >> >> Hmmm... It's hard for me to answer that question since I didn't write >> the original code. The test code that calls `WB_HandshakeWalkStack()` >> or `WB_AsyncHandshakeWalkStack()` can call those functions with >> a `thread_handle` that translates into a `thread_oop` that returns a >> `NULL` `JavaThread*`. >> >> See the comment that I added to `WB_AsyncHandshakeWalkStack()` above. > > Update: I've added comments to WB_HandshakeReadMonitors() and > WB_HandshakeWalkStack() to clarify their expectations. Update again: I took a closer look at `WB_AsyncHandshakeWalkStack()`, `WB_HandshakeReadMonitors()` and `WB_HandshakeWalkStack()` and I realized that those functions were not properly converting a `jobject` into a protected JavaThread*. I've updated them to call the proper conversion function and I've changed this code to `guarantee()` that the target is not `nullptr`. ------------- PR: https://git.openjdk.java.net/jdk/pull/4677