On Thu, 12 Jan 2023 12:08:51 GMT, Daniel Jeliński <djelin...@openjdk.org> wrote:

> Please review this fix for DwarfParser cleaner.
> 
> The original code registered the cleaner using a lambda that captured a 
> reference to the parser object; as a result, the object was never GCed, and 
> the cleaner never ran.
> 
> In this version I moved the lambda creation to a static method, so that it 
> can't capture a reference to the parser.
> 
> Additionally, the new code uses a static cleaner; the cleaner object creation 
> and cleanup are heavy operations (every cleaner comes with its own thread), 
> and it's preferable to use a single shared cleaner where possible.
> 
> I verified manually that the native `destroyDwarfContext` method is called 
> after this fix. No new automated test. Existing tier1-2 tests continue to 
> pass.

This seems like a pretty serious flaw with using Lambdas and Cleaners that 
probably should be brought up with the libs and language teams. I see other 
occurrences of this issue in these files (I may have missed some):

src/java.base/share/classes/com/sun/crypto/provider/*Key.java (4 files)
src/java.base/windows/classes/java/lang/ProcessImpl.java
src/java.desktop/share/classes/javax/swing/border/TitledBorder.java
src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java

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

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

Reply via email to