fingerprintjs / fingerprintjs-android

Swiss army knife for identifying and fingerprinting Android devices. MIT license, no restrictions on usage in production.
https://fingerprint.com/github/
MIT License
586 stars 86 forks source link

Resource Leak #118

Open SirionRazzer opened 5 days ago

SirionRazzer commented 5 days ago

Hello, the Scanner object here is not properly closed causing resource leaks. Can you please fix it? Thank you, Tomas

https://github.com/fingerprintjs/fingerprintjs-android/blob/a33e213daa8534a2d2d1e85636f6aba635e75dc1/fingerprint/src/main/java/com/fingerprintjs/android/fingerprint/info_providers/CpuInfoProvider.kt#L62C25-L62C44

The acquired stacktrace from devices:

`D  StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
                                                                                                        at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:2007)
                                                                                                        at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
                                                                                                        at java.io.FileInputStream.finalize(FileInputStream.java:662)
                                                                                                        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:370)
                                                                                                        at java.lang.Daemons$FinalizerDaemon.processReference(Daemons.java:350)
                                                                                                        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:322)
                                                                                                        at java.lang.Daemons$Daemon.run(Daemons.java:131)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.lang.Throwable: Explicit termination method 'close' not called
                                                                                                        at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
                                                                                                        at dalvik.system.CloseGuard.open(CloseGuard.java:257)
                                                                                                        at java.io.FileInputStream.<init>(FileInputStream.java:195)
                                                                                                        at java.util.Scanner.<init>(Scanner.java:645)
                                                                                                        at com.fingerprintjs.android.fingerprint.info_providers.CpuInfoProviderImpl.getCpuInfo(CpuInfoProvider.kt:63)
                                                                                                        at `com.fingerprintjs.android.fingerprint.info_providers.CpuInfoProviderImpl.access$getCpuInfo(CpuInfoProvider.kt:33)``
Valve commented 4 days ago

Hi @SirionRazzer,

Thanks for letting us know about this issue. Our engineering team will look into this and get back to you.