[jdk17] RFR: 8271158: runtime/handshake/HandshakeTimeoutTest.java test doesn't check exit code
Igor Ignatyev
iignatyev at openjdk.java.net
Thu Jul 22 19:54:06 UTC 2021
On Thu, 22 Jul 2021 19:43:46 GMT, Igor Ignatyev <iignatyev at openjdk.org> wrote:
>> test/hotspot/jtreg/runtime/handshake/HandshakeTimeoutTest.java line 63:
>>
>>> 61: output.reportDiagnosticSummary();
>>> 62: // In rare cases the target wakes up and performs the handshake at the same time as we timeout.
>>> 63: // Therefore it's not certain the timeout will find any thread.
>>
>> The comment on L62-63 indicates that this line:
>>
>> L64: output.shouldMatch("has not cleared handshake op|No thread with an unfinished handshake op");
>>
>> will sometimes finish with "No thread with an unfinished handshake op". In that case,
>> won't the test finish with an exit code of zero?
>>
>> If I'm right about that, you've introduced a rare case where the test will
>> fail (because the exit code is 0) when it would have passed before.
>
> given `HandshakeTimeoutTest$Test` will work till it crashes, its exit code can't be 0. which, I *guess*, means we will always have "has not cleared handshake op".
actually, both `No thread with an unfinished handshake op` and `has not cleared handshake op` lead to a call of `fatal()`:
```open/src/hotspot/share/runtime/handshake.cpp:
180 static void handle_timeout(HandshakeOperation* op, JavaThread* target) {
181 JavaThreadIteratorWithHandle jtiwh;
182
183 log_error(handshake)("Handshake timeout: %s(" INTPTR_FORMAT "), pending threads: " INT32_FORMAT,
184 op->name(), p2i(op), op->pending_threads());
185
186 if (target == NULL) {
187 for ( ; JavaThread* thr = jtiwh.next(); ) {
188 if (thr->handshake_state()->operation_pending(op)) {
189 log_error(handshake)("JavaThread " INTPTR_FORMAT " has not cleared handshake op: " INTPTR_FORMAT, p2i(thr), p2i(op));
190 // Remember the last one found for more diagnostics below.
191 target = thr;
192 }
193 }
194 } else {
195 log_error(handshake)("JavaThread " INTPTR_FORMAT " has not cleared handshake op: " INTPTR_FORMAT, p2i(target), p2i(op));
196 }
197
198 if (target != NULL) {
199 if (os::signal_thread(target, SIGILL, "cannot be handshaked")) {
200 // Give target a chance to report the error and terminate the VM.
201 os::naked_sleep(3000);
202 }
203 } else {
204 log_error(handshake)("No thread with an unfinished handshake op(" INTPTR_FORMAT ") found.", p2i(op));
205 }
206 fatal("Handshake timeout");
207 }
-------------
PR: https://git.openjdk.java.net/jdk17/pull/270
More information about the hotspot-runtime-dev
mailing list