On Thu, 29 May 2025 18:10:55 GMT, Leonid Mesnik <lmes...@openjdk.org> wrote:
>> Based on the log output, the test failure seems to be the result of two >> threads trying to set and access variables that are not volatile, so I've >> made them volatile. Since I can't reproduce the failure, I can't confirm >> that it is now fixed, but the lack of volatile is clearly a bug so should be >> done anyway. Tested by running the test locally to make sure nothing breaks. > > test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionEvent/_itself_/exevent008.java > line 83: > >> 81: private ReferenceType rType, rTypeEx; >> 82: private String cmd; >> 83: private volatile int counter1 = 0, counter2 = 0; > > The volatile is not enough for increment. It might be not affect test if you > check 0/non-0 only but still not a good way. > Better to use AtomicInteger or set/read variable only. Since there is only one writer thread, volatile should be sufficient. The only requirement is to make writes visible to the reader thread. volatile accomplishes that. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25236#discussion_r2114719187