On Tue, 4 Jun 2024 19:06:19 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:
>> The kill sends async exception that is thrown somewhere during >> log.display(...) method. >> The log shows that it is thrown while PrintStream locking moving it into an >> inconsistent state. >> So the fix is to use some method that could be safely interrupted by async >> exception. > > test/hotspot/jtreg/vmTestbase/nsk/jdb/kill/kill001/kill001a.java line 153: > >> 151: } >> 152: } >> 153: > > Have you tried an empty method? I don't think it's a matter of how much time > you spend in the method, but just whether or not a JVM async exception > polling point is reached. I suspect the method call or return will be a > polling point, but I'm unsure what happens if the method call is elided by > the JIT because it does nothing. The empty method is removed. So test failing with '-Xcomp /C2' and exception happens after try block. The log shows: reply[2]: main[1] Sending command: cont reply[0]: > reply[1]: Exception occurred: java.lang.NullPointerException (to be caught at: nsk.jdb.kill.kill001.MyThread.run(), line=165 bci=107)"thread=MyThread-1", nsk.jdb.kill.kill001.MyThread.run(), line=164 bci=100 reply[2]: 164 methodForException(); reply[3]: reply[4]: MyThread-1[1] Sending command: cont reply[0]: > reply[1]: Exception occurred: nsk.jdb.kill.kill001.MyException (uncaught) reply[2]: Exception occurred: nsk.jdb.kill.kill001.MyException (uncaught)"thread=MyThread-4", nsk.jdb.kill.kill001.MyThread.run(), line=178 bci=187 reply[3]: 178 kill001a.log.display(ThreadFinished); reply[4]: reply[5]: MyThread-4[1] Sending command: cont reply[0]: > reply[1]: Exception occurred: com.sun.jdi.IncompatibleThreadStateException (uncaught) reply[2]: Exception occurred: com.sun.jdi.IncompatibleThreadStateException (uncaught)"thread=MyThread-3", nsk.share.Log.display(), line=327 bci=9 reply[3]: 327 doPrint(message.toString()); reply[4]: reply[5]: MyThread-3[1] Sending command: cont reply[0]: > Thread MyThread-1 caught expected async exception: java.lang.NullPointerException: kill001a's Exception reply[1]: Thread finished: MyThread-1 reply[2]: reply[3]: Exception occurred: java.lang.ThreadDeath (uncaught) reply[4]: Exception occurred: java.lang.ThreadDeath (uncaught)"thread=MyThread-0", nsk.share.Log.doPrint(), line=495 bci=1 reply[5]: 495 PrintStream stream = findOutStream(); reply[6]: reply[7]: MyThread-0[1] Sending command: cont reply[0]: > reply[1]: Exception occurred: java.lang.SecurityException (uncaught) reply[2]: Exception occurred: java.lang.SecurityException (uncaught)"thread=MyThread-2", nsk.share.Log.doPrint(), line=495 bci=1 reply[3]: 495 PrintStream stream = findOutStream(); ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19547#discussion_r1626603001