JDK-8197812 : (ref) Data race in Finalizer
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-02-13
  • Updated: 2018-03-28
  • Resolved: 2018-02-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b02Fixed
Related Reports
Relates :  
Description
Google's experimental java-tsan tool reports the race below.
Examining the source, we see that most but not all accesses to next links are protected by "lock".  The one occurrence of synchronized (this) appears bogus (was synthronized (lock) intended?)

WARNING: ThreadSanitizer: data race (pid=5727)
  Read of size 8 at 0x7f889aec15f0 by thread T18 (mutexes: write M948147946252932544):
    #0 java.lang.ref.Finalizer.runFinalizer(Lsun/misc/JavaLangAccess;)V (Finalizer.java:163)  
    #1 java.lang.ref.Finalizer.access$100(Ljava/lang/ref/Finalizer;Lsun/misc/JavaLangAccess;)V (Finalizer.java:37)  
    #2 java.lang.ref.Finalizer$FinalizerThread.run()V (Finalizer.java:313)  
    #3 (Generated Stub)  

  Previous write of size 8 at 0x7f889aec15f0 by thread T40 (mutexes: write M665265594339316864, write M666110019269449240, write M666391494246159920, write M194920908232491176, write M665265594653827776, write M666110019583960152, write M666391494560670832, write M619948123401274448, write M622762873168381280, write M920844873141023256, write M922815197978005512, write M829365506068091856):
    #0 java.lang.ref.Finalizer.register(Ljava/lang/Object;)V (Finalizer.java:146)  
    #1 (Generated Stub)  
    #2 java.util.zip.ZipFile$ZipFileInflaterInputStream.<init>(Ljava/util/zip/ZipFile;Ljava/util/zip/ZipFile$ZipFileInputStream;Ljava/util/zip/Inflater;I)V (ZipFile.java:398)  
    #3 java.util.jar.JarFile.getInputStream(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream; (JarFile.java:449)  
    #4 sun.misc.URLClassPath$JarLoader$2.getInputStream()Ljava/io/InputStream; 
Comments
The add and remove methods are actually clearer when inlined.
14-02-2018

http://cr.openjdk.java.net/~martin/webrevs/jdk/Finalizer-data-race/
13-02-2018