RFR: 8289208: Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS

Maxim Kartashev mkartashev at openjdk.org
Wed Jul 13 11:51:00 UTC 2022


On Wed, 13 Jul 2022 08:58:38 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> 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? 

Yes, I believe it can be deallocated before the reference to it is added to `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();


Of this I am not so sure. When `target` object is deallocated in the middle of `add()`, then `ref.get()` (`Reference.get()`) returns `null`, but the above code doesn't do that. Neither does the `add()` method; `records` are indexed by the `Reference` object, not - by now deallocated - referent of that reference:

java.lang.ref.Reference<Object> ref;
...
records.put(ref, rec);

-------------

PR: https://git.openjdk.org/jdk/pull/9362



More information about the client-libs-dev mailing list