Open Bug 1872735 Opened 2 years ago Updated 1 year ago

java.util.ConcurrentModificationException when typing in the URL bar

Categories

(Firefox for Android :: Toolbar, defect)

Firefox 121
All
Android
defect

Tracking

()

Tracking Status
firefox122 --- wontfix
firefox123 --- wontfix
firefox124 --- wontfix
firefox136 --- affected
firefox137 --- affected
firefox138 --- affected

People

(Reporter: josh.hight, Unassigned)

References

Details

(Keywords: crash)

Crash Data

Attachments

(1 file, 1 obsolete file)

Steps to reproduce:

  1. Launch Firefox
  2. Type search terms in the URL bar
  3. If no crash, repeat step 2

Actual results:

Firefox will eventually crash. Stacktrace, grabbed from logcat:

EditToolbar: Error while processing autocomplete input
java.util.ConcurrentModificationException
at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1209)
at java.util.TreeMap$KeyIterator.next(TreeMap.java:1263)
at mozilla.components.feature.toolbar.ToolbarAutocompleteFeature$2.invokeSuspend(ToolbarAutocompleteFeature.kt:87)
at mozilla.components.feature.toolbar.ToolbarAutocompleteFeature$2.invoke(ToolbarAutocompleteFeature.kt:20)
at mozilla.components.browser.toolbar.AsyncFilterListener$invoke$1.invokeSuspend(BrowserToolbar.kt:46)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:9)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:112)
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)

Expected results:

No crash

Component: General → Toolbar

The severity field is not set for this bug.
:skhan, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(skhan)

I've found this crash in some of our automation tests logs as well, and can sometimes reproduce it locally (not manually though). Here are a few examples of this crash:
deleteCollectionTest
verifyOpenAllInPrivateTabsTest

goes back to at least Fx122: urlBarQuickActionsTest

STR as seen in the test recordings are exactly what the reporter described:

  • On the first run, click the search toolbar, type in a URL.
  • Some of the UI tests are set up to retry in case of flakiness, so it could crash only the second time it edits the URL bar. On the second retry, the URL bar should already contain the first URL, so it will replace that.

device used: Pixel 2, Android 11, virtual device.

Severity: -- → S2
Status: UNCONFIRMED → NEW
Ever confirmed: true
Crash Signature: [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java) ]
Keywords: crash
Crash Signature: [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java) ] → [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java) ] [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java) ]

Possible duplicate? Bug 1864557

Flags: needinfo?(skhan)

(In reply to [:skhan] from comment #5)

Possible duplicate? Bug 1864557

Yes, this seems to be a duplicate.

Since the crash volume is low (less than 15 per week), the severity is downgraded to S3. Feel free to change it back if you think the bug is still critical.

For more information, please visit BugBot documentation.

Severity: S2 → S3

I chased this error for a bit thinking I'd caused it with some other work before realizing it was already in fenix/android-components. I traced it further.

It's getting triggers by the fan out of autocomplete providers at

https://searchfox.org/mozilla-central/source/mobile/android/android-components/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeature.kt#37

with

                val result = autocompleteProviders
                    .firstNotNullOfOrNull { it.getAutocompleteSuggestion(query) }

After some testing I was able to pin it to one provider, PlacesHistoryStorage and its getAutocompleteSuggestion method at

https://searchfox.org/mozilla-central/source/mobile/android/android-components/components/browser/storage-sync/src/main/java/mozilla/components/browser/storage/sync/PlacesHistoryStorage.kt#168

    val url = handlePlacesExceptions("getAutoCompleteSuggestions", default = null) {
            autocompleteReader.interrupt()
            autocompleteReader.matchUrl(query)
    } ?: return null

It appears that autocompleteReader.interrupt() always in my testing generates a ConcurrentModificationException but also autocompleteReader.matchUrl(query) sometimes can generate it as well.

PlacesHistoryStorag's autocompleteReader is from PlacesReaderConnection which belongs to a separate package, appservice:places, so that's where my tracing ended.

Hope this helps

The bug is linked to a topcrash signature, which matches the following criterion:

  • Top 10 AArch64 and ARM crashes on nightly

:royang, could you consider increasing the severity of this top-crash bug?

For more information, please visit BugBot documentation.

Flags: needinfo?(royang)
Keywords: topcrash

I was able to reproduce this with Focus recently as well: https://crash-stats.mozilla.org/signature/?product=Focus&signature=java.util.ConcurrentModificationException%3A%20at%20java.util.LinkedHashMap%24LinkedHashIterator.nextNode%28LinkedHashMap.java%29

The spike increase doesn't look good from the crash signature graph above.

Comment 8 looks pretty useful, thanks for that Dan!

Severity: S3 → S2
See Also: → 1950991

:boek Bug 1950991 released in 136.0.1, but the crash volume is still significantly higher than 135.
Are any further investigations happening? If yes, is there a bug tracking it?
If not, could we track a bug for investigation?

Tracking here in the interim unless Comment 11 points to another bug to track.

Comment on attachment 9472212 [details]
Bug 1872735 - Make a copy of the observers list to avoid a race condition that triggers a CME

Revision D241706 was moved to bug 1954228. Setting attachment 9472212 [details] to obsolete.

Attachment #9472212 - Attachment is obsolete: true
Flags: needinfo?(jboek)
See Also: → 1954228

Tracking with Bug 1954228

Crash Signature: [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java) ] [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java) ] → [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java) ] [@ java.util.ConcurrentModificationException: at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java) ] [@ jav…

Based on the topcrash criteria, the crash signatures linked to this bug are not in the topcrash signatures anymore.

For more information, please visit BugBot documentation.

Keywords: topcrash
Flags: needinfo?(royang)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: