Closed Bug 718904 Opened 8 years ago Closed 8 years ago

java.lang.ClassCastException: java.lang.String at org.mozilla.gecko.AwesomeBar.onCreateContextMenu(AwesomeBar.java:421)

Categories

(Firefox for Android :: General, defect, P3, critical)

12 Branch
ARM
Android
defect

Tracking

()

VERIFIED FIXED
Firefox 13
Tracking Status
firefox11 --- fixed
firefox12 --- fixed
firefox13 --- verified

People

(Reporter: nhirata, Assigned: wesj)

References

Details

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

Crash Data

Attachments

(2 files)

From Soccoro Reports: 
https://crash-stats.mozilla.com/report/index/ead225f7-821f-4074-83c7-b26c32120115
https://crash-stats.mozilla.com/report/index/128464cf-edb0-4bfd-b758-a64042120115

Java Crash in app notes:
java.lang.ClassCastException: java.lang.String
	at org.mozilla.gecko.AwesomeBar.onCreateContextMenu(AwesomeBar.java:421)
	at android.view.View.createContextMenu(View.java:4363)
	at com.android.internal.view.menu.ContextMenuBuilder.show(ContextMenuBuilder.java:81)
	at com.android.internal.policy.impl.PhoneWindow$DecorView.showContextMenuForChild(PhoneWindow.java:1983)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:466)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:466)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:466)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:466)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:466)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:466)

Note: Occurs on Motorola Triumph
No idea if we can reproduce this crash, but based on the build (2012-01-15 12.0a1)it should be this line:
http://hg.mozilla.org/mozilla-central/annotate/c98283f80ae7/mobile/android/base/AwesomeBar.java#l421

Cursor cursor = (Cursor)selectedItem;

The error would indicate that we are trying to cast selectedItem to a Cursor, but selectedItem is a String. How could that happen?
Assignee: nobody → wjohnston
Blocks: 719373
(In reply to Mark Finkle (:mfinkle) from comment #1)
> No idea if we can reproduce this crash, but based on the build (2012-01-15
> 12.0a1)it should be this line:
> http://hg.mozilla.org/mozilla-central/annotate/c98283f80ae7/mobile/android/
> base/AwesomeBar.java#l421
> 
> Cursor cursor = (Cursor)selectedItem;
> 
> The error would indicate that we are trying to cast selectedItem to a
> Cursor, but selectedItem is a String. How could that happen?

Weird. Both Bookmark and Top Sites ListViews are cursor-based. The only explanation I can think of is that this bug is triggered by tapping-and-holding on top of a History section header ("Today", "Yesterday", "7 days ago", etc) which is a string element.
This is very brittle code.  See bug 704467 for another workaround I added to protect against a similar situation.
Priority: -- → P3
Attached patch PatchSplinter Review
This fixes A bug with tapping on the header rows in the history pane. It does not touch the code that apparently crashed here. Nor does it happen on bing maps like the comments in the crash report suggest.
Attachment #591253 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 591253 [details] [diff] [review]
Patch

Review of attachment 591253 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/AwesomeBar.java
@@ +408,5 @@
>              ExpandableListView exList = (ExpandableListView)list;
>              int childPosition = exList.getPackedPositionChild(info.packedPosition);
>              int groupPosition = exList.getPackedPositionGroup(info.packedPosition);
> +
> +            // check if long tap is on a header row

nit: "Check"
Attachment #591253 - Flags: review?(lucasr.at.mozilla) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/d9120155ac87

Landed on inbound. NOTE again this does NOT fix this particular bug, I was just apparently to lazy to file a follow up for it.
Comment on attachment 591253 [details] [diff] [review]
Patch

[Approval Request Comment]
Regression caused by (bug #): bug 711905
User impact if declined: potential crashes when long tapping on headers (Today, Yesterday, etc).
Testing completed (on m-c, etc.): Landed on central Jan 25
Risk to taking this patch (and alternatives if risky): Little risk.
Attachment #591253 - Flags: approval-mozilla-aurora?
Comment on attachment 591253 [details] [diff] [review]
Patch

[Triage Comment]
Mobile only - approved for Aurora.
Attachment #591253 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
https://hg.mozilla.org/mozilla-central/rev/d9120155ac87
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 12
It's not fixed in Fx 11:
https://crash-stats.mozilla.com/report/list?query_search=signature&query_type=contains&reason_type=contains&range_value=4&range_unit=weeks&hang_type=any&process_type=any&signature=java.lang.ClassCastException%3A%20java.lang.String%20at%20org.mozilla.gecko.AwesomeBar.onCreateContextMenu%28AwesomeBar.java%29
Status: RESOLVED → REOPENED
Crash Signature: [@ TouchBadMemory ] → [@ TouchBadMemory ] [@ java.lang.ClassCastException: java.lang.String at org.mozilla.gecko.AwesomeBar.onCreateContextMenu(AwesomeBar.java)]
Resolution: FIXED → ---
Attached patch PatchSplinter Review
I'm still not sure what causes this. I think we're best to catch it and hope that we can find a way to reproduce.
Attachment #595190 - Flags: review?(mark.finkle)
Comment on attachment 595190 [details] [diff] [review]
Patch

we should remove the logging at some point. not right away.
Attachment #595190 - Flags: review?(mark.finkle) → review+
Comment on attachment 595190 [details] [diff] [review]
Patch

Low risk. Mobile only. Prevents a crash.
Attachment #595190 - Flags: approval-mozilla-beta?
Attachment #595190 - Flags: approval-mozilla-aurora?
Target Milestone: Firefox 12 → Firefox 13
https://hg.mozilla.org/mozilla-central/rev/82628a241e74
Status: REOPENED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → FIXED
Attachment #595190 - Flags: approval-mozilla-beta?
Attachment #595190 - Flags: approval-mozilla-beta+
Attachment #595190 - Flags: approval-mozilla-aurora?
Attachment #595190 - Flags: approval-mozilla-aurora+
Duplicate of this bug: 724652
Crash occurs on build : 20120209042012 on Model: 'SAMSUNG-SGH-I997'
Not sure, maybe needs to clear data on the phone?  Waiting to see if there's another crash that reoccurs.

From Socorro:
https://crash-stats.mozilla.com/report/index/d3a96fb8-3281-4947-b880-0ed192120209

java.lang.ClassCastException: java.lang.String
	at org.mozilla.gecko.AwesomeBar.onCreateContextMenu(AwesomeBar.java:420)
	at android.view.View.createContextMenu(View.java:4420)
	at com.android.internal.view.menu.ContextMenuBuilder.show(ContextMenuBuilder.java:81)
	at com.android.internal.policy.impl.PhoneWindow$DecorView.showContextMenuForChild(PhoneWindow.java:1933)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:460)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:460)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:460)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:460)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:460)
	at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:460)
	at android.widget.AbsListView.performLongPress(AbsListView.java:2032)
	at android.widget.AbsListView.access$600(AbsListView.java:99)
	at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:1985)
	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 org.mozilla.gecko.GeckoApp$32.run(GeckoApp.java:1777)
	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)
This crash doesn't occur on the latest Nightly build. Closing bug as:

Verified fixed on:

Firefox 13.0a1 (2012-03-01)
20120301031135
http://hg.mozilla.org/mozilla-central/rev/1c3b291d0830

--
Device: Samsung Galaxy S2
OS: Android 2.3.4
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.