On Mon, 11 Jul 2022 10:01:18 GMT, Maxim Kartashev <mkartas...@openjdk.org> wrote:
> will be executed on the disposer thread simultaneously with the array > relocation of `deferredRecords`. So some of the `get()` calls will return > `null` as they read from initialized, but yet-to-be-relocated chunks, and > some will read what essentially is garbage. Don't we have a similar issue in the usage of `records `and `queue`? Is it possible that the `target` object in the `add `method will be deallocated before `ref `will be added to the `records`? In that case, the next code in `run` method will fail: Reference<?> obj = queue.remove(); obj.clear(); DisposerRecord rec = records.remove(obj); rec.dispose(); Do we need Reference.reachabilityFence at the end of the `add` or some kind of synchronization? Note that pollRemove tries to solve that: DisposerRecord rec = records.remove(obj); if (rec == null) { // shouldn't happen, but just in case. continue; } But for sure synchronization should solve that in some better way. ------------- PR: https://git.openjdk.org/jdk/pull/9362