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

Fatal Exception: java.util.ConcurrentModificationException: #1260

Open
5 tasks done
JhinSir opened this issue Aug 30, 2024 · 1 comment
Open
5 tasks done

Fatal Exception: java.util.ConcurrentModificationException: #1260

JhinSir opened this issue Aug 30, 2024 · 1 comment

Comments

@JhinSir
Copy link

JhinSir commented Aug 30, 2024

Checklist before submitting a bug report

Java version

JDK11

Android version

Android13,14,12,10,11

Android SDK version

16.2.0

Installation platform & version

Gradle

Package

Core & AppEvents

Goals

The program is normal

Expected results

No crash

Actual results

Program startup crashes
Fatal Exception: java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:760) at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:782) at com.facebook.internal.FetchedAppGateKeepersManager.getGateKeepersForApplication(FetchedAppGateKeepersManager.kt:165) at com.facebook.internal.FetchedAppGateKeepersManager.getGateKeeperForKey(FetchedAppGateKeepersManager.kt:177) at com.facebook.internal.FeatureManager.getGKStatus(FeatureManager.kt:107) at com.facebook.internal.FeatureManager.isEnabled(FeatureManager.kt:54) at com.facebook.internal.FeatureManager.isEnabled(FeatureManager.kt:54) at com.facebook.internal.Utility.setAppEventAttributionParameters(Utility.kt:578) at com.facebook.applinks.AppLinkData.fetchDeferredAppLinkFromServer(AppLinkData.java:143) at com.facebook.applinks.AppLinkData.access$000(AppLinkData.java:36) at com.facebook.applinks.AppLinkData$1.run(AppLinkData.java:131) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012)

Steps to reproduce

Unable to reproduce

Code samples & details

After integrating the SDK, calling the AppLinkData.fetchDeferredAppLinkData method in the Application's oncreate method, 5K+ crashes were observed on firbase. However, the crash cannot be reproduced locally.
The following is my debugging process:
1. Because I called AppLinkData.fetchDeferredAppLinkData in the Kotlin coroutine, I am not sure whether there is an asynchronous concurrency problem in a multi-threaded environment
2. The FetchedAppGateKeepersManager class in the source code, the following code:
      val output: MutableMap<String, Boolean> = HashMap()
      val jsonObject: JSONObject = fetchedAppGateKeepers[applicationId] ?: JSONObject()
      val jsonIterator = jsonObject.keys()
      while (jsonIterator.hasNext()) {
        val key = jsonIterator.next()
        output[key] = jsonObject.optBoolean(key)
      }
Printing the log, I found that even when multiple threads accessed and modified at the same time, it did not affect the iteration here. So I am wondering what other possible points may cause this error?
3.Is it possible that cacheList is empty under certain circumstances? Is it possible that the SDK initialization and the AppLinkData.fetchDeferredAppLinkData method are executed simultaneously under certain extreme conditions when the App is started?
@JhinSir
Copy link
Author

JhinSir commented Aug 30, 2024

Can you explain to me what conditions may trigger this error when the getGateKeepersForApplication method is running? From my current debugging log observation, there is no problem even when accessing and modifying the fetchedAppGateKeepers variable in a multi-threaded environment

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

No branches or pull requests

1 participant