Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FinalizableReferenceQueue might keep ClassLoaders around #3086

Open
netdpb opened this issue Mar 26, 2018 · 4 comments
Open

FinalizableReferenceQueue might keep ClassLoaders around #3086

netdpb opened this issue Mar 26, 2018 · 4 comments
Labels

Comments

@netdpb
Copy link
Member

netdpb commented Mar 26, 2018

Based on #92, in 2012 we made sure that using FinalizableReferenceQueue didn't stop ClassLoaders from being destroyed once they were no longer used.

Testing this behavior in JDK 9 revealed some strange failures. FinalizableReferenceQueueClassLoaderUnloadingTest has three tests:

  1. testUnloadableWithoutSecurityManager
  2. testUnloadableWithSecurityManager
  3. testUnloadableInStaticFieldIfClosed

(3) fails in JDK 9, but the others pass. During testing, we tried ignoring (3) in JDK 9. Then, (2) fails in JDK 9 but (1) passes. If we ignore (2) and (3) in JDK 9, then (1) fails.

Tracking down stray references to ClassLoaders for this behavior is difficult, and this heisenbug-like behavior will make it even more difficult.

Since Guava v10, MapMaker no longer uses FinalizableReferenceQueue, and we believe it to be infrequently used in general. Because of that, we're going to ignore all of these tests in JDK 9 and treat this as a known, but low-priority, bug.

Please comment here if you are impacted by this bug.

Please also feel free to work on tracking down the underlying issue. If you fix it, we would welcome a PR.

@YuryYaroshevich
Copy link

After running mvn clean package inside of guava-tests dir I didn't see failed tests from FinalizableReferenceQueueClassLoaderUnloadingTest but instead I saw a bunch of failing tests from MoreFilesFileTraverserTest.
My machine setup:

administrators-MacBook-Pro-3:guava yyar$ java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

@jrtom
Copy link
Member

jrtom commented Apr 3, 2018

@YuryYaroshevich please clarify (a) what version of Guava you're using and (b) what test failures you're seeing; this might be a completely separate issue.

@YuryYaroshevich
Copy link

@jrtom ,
I forked guava repo and then I did:

  1. cd guava-tests
  2. mvn clean test
    and I got these results:
Tests in error: 
  testFileTraverser_multipleDirectoryLayers_breadthFirstStartsWithTopLayer(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017334-0: unable to guarantee security of recursive delete
  testFileTraverser_singleDirectory(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017360-0: unable to guarantee security of recursive delete
  testFileTraverser_emptyDirectory(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017361-0: unable to guarantee security of recursive delete
  testFileTraverser_multipleFilesAndDirectories(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017362-0: unable to guarantee security of recursive delete
  testFileTraverser_nonExistingFile(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017364-0: unable to guarantee security of recursive delete
  testFileTraverser_file(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017366-0: unable to guarantee security of recursive delete
  testFileTraverser_singleFile(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017366-1: unable to guarantee security of recursive delete
  testFileTraverser_multipleDirectoryLayers_traversalReturnsAll(com.google.common.io.MoreFilesFileTraverserTest): /var/folders/5_/f590cn0n36s2sml54ffv3xc4n9rn41/T/1522830017368-0: unable to guarantee security of recursive delete

Tests run: 849670, Failures: 0, Errors: 8, Skipped: 0

@cpovirk
Copy link
Member

cpovirk commented Apr 4, 2018

#3100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants