Closed Bug 737445 Opened 12 years ago Closed 12 years ago

java.lang.ClassCastException: java.lang.String at org.mozilla.gecko.FormAssistPopup$AutoCompleteListAdapter.populateSuggestionsList(FormAssistPopup.java)

Categories

(Firefox for Android Graveyard :: General, defect)

13 Branch
ARM
Android
defect
Not set
critical

Tracking

(firefox13 fixed, firefox14 fixed)

RESOLVED FIXED
Firefox 14
Tracking Status
firefox13 --- fixed
firefox14 --- fixed

People

(Reporter: scoobidiver, Assigned: Margaret)

Details

(Keywords: crash, Whiteboard: [native-crash])

Crash Data

Attachments

(1 file)

There are two crashes from the same user in 13.0a2/20120315: bp-c54ff8bc-9f80-4a18-9e40-709172120319, bp-b39b8752-72e7-4064-9a71-669782120319.

java.lang.ClassCastException: java.lang.String
	at org.mozilla.gecko.FormAssistPopup$AutoCompleteListAdapter.populateSuggestionsList(FormAssistPopup.java:286)
	at org.mozilla.gecko.FormAssistPopup.showAutoCompleteSuggestions(FormAssistPopup.java:158)
	at org.mozilla.gecko.FormAssistPopup.access$100(FormAssistPopup.java:64)
	at org.mozilla.gecko.FormAssistPopup$2.run(FormAssistPopup.java:132)
	at android.os.Handler.handleCallback(Handler.java:587)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:130)
	at android.app.ActivityThread.main(ActivityThread.java:3687)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:507)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
	at dalvik.system.NativeStart.main(Native Method)

More reports at:
https://crash-stats.mozilla.com/report/list?signature=java.lang.ClassCastException%3A+java.lang.String+at+org.mozilla.gecko.FormAssistPopup%24AutoCompleteListAdapter.populateSuggestionsList%28FormAssistPopup.java%29
Seems like an easy fix in populateSuggestionsList();
Assignee: nobody → margaret.leibovic
(In reply to Aaron Train [:aaronmt] from comment #1)
> Seems like an easy fix in populateSuggestionsList();

What do you think that fix is?

(In reply to Scoobidiver from comment #0)
> java.lang.ClassCastException: java.lang.String

Is this the whole error at this line? I would think it would be something like "java.lang.ClassCastException: java.lang.String cannot be cast to org.json.JSONObject" since that's the cast we're doing here. 

If that's the case, that means that suggestions.get(i) is giving us a String that can't be cast to a JSONObject. Suggestions *should* be an array of { label: x, value: y} JSON objects:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#3009

I guess the thing to look into would be to make sure we're always sending the right data to java. Since only one user is seeing this crash, maybe some bad data got into the suggestions data and busted the string. I wonder what would happen if you tried putting JSON-like data in datalist suggestions. I would hope that our JSON stringify/parse code would handle this correctly.
(In reply to Margaret Leibovic [:margaret] from comment #2)
> (In reply to Aaron Train [:aaronmt] from comment #1)
> > Seems like an easy fix in populateSuggestionsList();
> 
> What do you think that fix is?

Oh, I guess we could change line 286 to:

JSONObject suggestion = suggestions.getJSONObject(i);

But then that would just be throwing a JSONException instead of a ClassCastException. This would get rid of the crash, but it might be worth investigating why this problem is happening in the first place.
(In reply to Margaret Leibovic [:margaret] from comment #2)
> (In reply to Scoobidiver from comment #0)
> > java.lang.ClassCastException: java.lang.String 
> Is this the whole error at this line?
Yes. See the Java Stack Trace field in the two crash reports.
Attached patch patchSplinter Review
This will prevent a ClassCastException. I'd still like to try to reproduce this problem, but I don't have the time right now. Maybe we can file a follow-up in case someone has time to try to create some bad suggestion strings?

Even though we could still encounter a JSONException, the only thing that would happen is that the suggestion wouldn't get added to the list, and that isn't the end of the world, especially if there was some weird issue causing the suggestion to be formatted incorrectly.
Attachment #607649 - Flags: review?(mark.finkle)
Comment on attachment 607649 [details] [diff] [review]
patch

So this bug would eventually re-appear as a "no autocomplete suggestions appear" bug? We at least have code to handle the exception and stop the crash, which is important.
Attachment #607649 - Flags: review?(mark.finkle) → review+
(In reply to Mark Finkle (:mfinkle) from comment #6)

> So this bug would eventually re-appear as a "no autocomplete suggestions
> appear" bug?

Yeah, that would be the symptom if this problem re-appears. And in that case we would have the actual website/profile to debug this problem.

https://hg.mozilla.org/integration/mozilla-inbound/rev/e0c8bf206124
https://hg.mozilla.org/mozilla-central/rev/e0c8bf206124
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 14
Comment on attachment 607649 [details] [diff] [review]
patch

[Approval Request Comment]
Mobile only. Crash fix.
Attachment #607649 - Flags: approval-mozilla-aurora?
Comment on attachment 607649 [details] [diff] [review]
patch

[Triage Comment]
Mobile only, approved for Aurora 13.
Attachment #607649 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: