__tsan_java_finalize bug

Man Cao manc at google.com
Wed May 27 19:03:34 UTC 2020


__tsan_java_finalize() is used in Java finalizer:
https://github.com/openjdk/tsan/blob/7f1f31a18bafd9df728b03c63953f4e3fe20abdb/src/java.base/share/classes/java/lang/ref/Finalizer.java#L90
tsanFinalize() calls __tsan_java_finalize().

finalize() is deprecated since Java 9. Perhaps the Cleaner
<https://docs.oracle.com/javase/9/docs/api/java/lang/ref/Cleaner.html>
mechanism
does not need __tsan_java_finalize()?

-Man


On Sat, May 23, 2020 at 5:57 AM Dmitry Vyukov <dvyukov at google.com> wrote:

> Hi,
>
> FYI there is a bug reported in tsan's AcquireGlobal:
> https://github.com/golang/go/issues/39186
> It's for Go, but I think it equally affects __tsan_java_finalize(). Is
> it used in the current implementation for Java finalizers?
>
> Brief summary: it requires a very special program pattern and a very
> narrow inconsistency window (4 threads participating in a very special
> and tricky interleaving), but if all of that is satisfied it can lead
> to arbitrary unexplainable false positives.
>


More information about the tsan-dev mailing list