microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
8.29k stars 1.7k forks source link

Memory leak in HandleProxyFactory.kt DroidGuard class cache ClassLoader not Unloaded java.lang.UnsatisfiedLinkError Library already loaded in another classloader #2153

Open ydaniels opened 8 months ago

ydaniels commented 8 months ago

Describe the bug HandleProxyFactory keeps a cache of DroidGuardClass in classMap fun loadClass https://github.com/microg/GmsCore/blob/048a6e59f1cd9192eb614fb73db3304c058574cb/play-services-droidguard/core/src/main/kotlin/org/microg/gms/droidguard/core/HandleProxyFactory.kt#L214.

but DroidGuardHandleImpl.kt creates a new copy of the class everytime PlayIntegrity or Safetynet is checked so the previous DroidGuardClass cache never gets unloaded and you get error java.lang.UnsatisfiedLinkError Library already loaded in another classloader when you try to check PlayIntegrity or Safetynet multiple times

To Reproduce 1.) Install SPIC - Play Integrity Checker 2.) Check Integrity It works fine for the first time 3) Check Integrity Multiple time. It fails and crash occur internally on adb with error java.lang.UnsatisfiedLinkError Library already loaded in another classloader

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

System Android Version: 11 Custom ROM: LineageOS 18

Additional context This was tested with official playstore

huwenkai26 commented 7 months ago

image