On 02/14/2018 11:49 AM, Peter Levart wrote:
Hi Martin,

On 02/14/2018 10:58 AM, Peter Levart wrote:

I take back this claim. Of course the the following race is possible:

- Thread1: calls runAllFinalizers and takes a Finalizer from 'unprocessed' list. - Thread2: takee the same Finalizer instance from ReferenceQueue and calls runFinalizer() - Thread1: calls runFinalizer() with the same instance for the 2nd time now.

... but this could be "fixed" if the taking of next Finalizer from 'unfinalized' list and removing it from the same list was a single atomic operation. What do you say of the following further simplification:

http://cr.openjdk.java.net/~plevart/jdk-dev/8197812_Data_race_in_Finalizer/webrev.01/

Even that has a flaw. Running the next unfinalized Finalizer from runAllFinalizers() does not prevent the same Finalizer to be returned from the ReferenceQueue. So the check must remain in place.

Sorry for this long monologue. I truly rest now.

Regards, Peter

Reply via email to