Closed Bug 1233048 Opened 10 years ago Closed 10 years ago

crash in java.lang.NullPointerException: Attempt to invoke interface method ''int android.database.Cursor.getCount()'' on a null object reference at org.mozilla.gecko.preferences.AndroidImport.run(AndroidImport.java)

Categories

(Firefox for Android Graveyard :: General, defect)

defect
Not set
critical

Tracking

(firefox43 affected, firefox44 verified, firefox45 verified, firefox46 verified, b2g-v2.5 fixed, fennec43+)

RESOLVED FIXED
Firefox 46
Tracking Status
firefox43 --- affected
firefox44 --- verified
firefox45 --- verified
firefox46 --- verified
b2g-v2.5 --- fixed
fennec 43+ ---

People

(Reporter: u549602, Assigned: swaroop.rao)

References

Details

(Keywords: crash)

Crash Data

Attachments

(1 file)

This bug was filed from the Socorro interface and is report bp-b6f9a4e8-c727-47e6-b5d3-3195f2151216. ============================================================= Device: Samsung Galaxy Note 5 (Android 5.1.1) Build: All builds Steps to reproduce: 1. Remove default browser from android settings or disable it 2. Go to settings- Advance- import options and select both or any option 3. Tap "Import" Result: Firefox crashes
Blocks: 1188271
Does this happen in first run too? This would be a bad first impression.
tracking-fennec: --- → ?
Hi Sebastian, Yes, this crash also occurs when trying to import at first run.
One clause has a check for a null cursor: if (Build.MANUFACTURER.equals(SAMSUNG_MANUFACTURER) && cursor != null && cursor.getCount() == 0) { cursor = mCr.query(SAMSUNG_BOOKMARKS_URI, null, null, null, null); } and one doesn't: if (Build.MANUFACTURER.equals(SAMSUNG_MANUFACTURER) && cursor.getCount() == 0) { cursor = mCr.query(SAMSUNG_HISTORY_URI, null, null, null, null); } This code could do with a little bit of cleanup, too.
Can I take this up?
(In reply to swaroop.rao from comment #4) > Can I take this up? Yeah, sure. Attach a bug and it's all yours! :) However as this is a crash.. time is a concern here and someone else might pick it up if it's not moving along. Have a look at "Bugs ahoy!" or visit us on IRC (irc.mozilla.org #mobile) if you are looking for a bug that is less critical: http://www.joshmatthews.net/bugsahoy/?mobileandroid=1
I've got a patch ready but I was unsure about the "little bit of cleanup" part mentioned by rnewman. Is there anything else I should be doing apart from adding the null check?
Flags: needinfo?(s.kaspari)
(In reply to Sebastian Kaspari (:sebastian) from comment #5) > Yeah, sure. Attach a bug and it's all yours! :) Oops. This should say "Attach a patch".. :) (In reply to swaroop.rao from comment #6) > I've got a patch ready but I was unsure about the "little bit of cleanup" > part mentioned by rnewman. Is there anything else I should be doing apart > from adding the null check? Avoiding the crash is good enough. While I do not know what rnewman had in mind, here are some things I noticed while reading the class: * Good: To avoid errors like this we could move the query part from mergeBookmarks() and mergeHistory() to a query() method that first tries to query BOOKMARKS_URI and then SAMSUNG_BOOKMARKS_URI if needed - and then returns the cursor * Maybe: I think we should query Samsung's bookmarks provider even if the previous query returned a null cursor. So I think it should be: SAMSUNG && (cursor == null || cursor.getCount() == 0) * Minor: mContext is set but never used * Minor: Instead of cursor.moveToFirst and while(!cursor.isAfterLast()) we could just use while(cursor.moveToNext()) * Minor: We could return early if the cursor is null after both queries: if (cursor == null) { return } But again: The crash is important here. It would be nice to clean it up a bit while we edit the file but we can always file a follow-up bug if needed.
Flags: needinfo?(s.kaspari)
OK, I've made the null check change and also implemented the 'Good' and 'Maybe' changes suggested above. I have created a patch and currently testing it on try.
Attached patch 1233048.patchSplinter Review
Attaching the patch containing the changes described in earlier comment. However, I don't have a Samsung phone and I could not reproduce this defect on my Nexus 6 (either before or after the fix). Try log is at https://treeherder.mozilla.org/#/jobs?repo=try&revision=42ef36717998.
Attachment #8700873 - Flags: review?(s.kaspari)
Assignee: nobody → swaroop.rao
Status: NEW → ASSIGNED
Comment on attachment 8700873 [details] [diff] [review] 1233048.patch Review of attachment 8700873 [details] [diff] [review]: ----------------------------------------------------------------- Patch is looking good. But I'd like to get liuche's opinion on the changes (especially the logic change).
Attachment #8700873 - Flags: review?(s.kaspari)
Attachment #8700873 - Flags: review?(liuche)
Attachment #8700873 - Flags: feedback+
Comment on attachment 8700873 [details] [diff] [review] 1233048.patch Review of attachment 8700873 [details] [diff] [review]: ----------------------------------------------------------------- This also looks good to me! And the logic change also makes sense, we should be trying if the cursor is null or empty.
Attachment #8700873 - Flags: review?(liuche) → review+
So, is there anything else needed from me?
Flags: needinfo?(s.kaspari)
(In reply to swaroop.rao from comment #12) > So, is there anything else needed from me? No. We can add "checkin-needed" to land this. :)
Flags: needinfo?(s.kaspari)
Keywords: checkin-needed
Let's try to uplift this, since we're promoting this during first run.
tracking-fennec: ? → 43+
NI to remember requesting uplift.
Flags: needinfo?(s.kaspari)
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 46
Verified as fixed on the latest Nightly build (46.0a1 / 2015-12-27) on Nexus tab 7 with Android 5.1.1. Thank you
Comment on attachment 8700873 [details] [diff] [review] 1233048.patch Approval Request Comment [Feature/regressing bug #]: Import bookmarks/history feature. Promoted from first-run experience and preferences. [User impact if declined]: On Samsung devices using the import feature can crash the app in certain situations. [Describe test coverage new/current, TreeHerder]: Only manual testing. [Risks and why]: Low - Added missing null check. [String/UUID change made/needed]: -
Flags: needinfo?(s.kaspari)
Attachment #8700873 - Flags: approval-mozilla-beta?
Attachment #8700873 - Flags: approval-mozilla-aurora?
Comment on attachment 8700873 [details] [diff] [review] 1233048.patch Crash fix that was verified, beta44+, aurora45+
Attachment #8700873 - Flags: approval-mozilla-beta?
Attachment #8700873 - Flags: approval-mozilla-beta+
Attachment #8700873 - Flags: approval-mozilla-aurora?
Attachment #8700873 - Flags: approval-mozilla-aurora+
This isn't applying cleanly to beta, mostly because Bug 1107811 wasn't uplifted to beta. Can we get a rebased patch to work around that?
Flags: needinfo?(swaroop.rao)
Flags: needinfo?(margaret.leibovic)
I changed the paths in the patch and it applied cleanly to beta: https://hg.mozilla.org/releases/mozilla-beta/rev/28d49ead7a22
Flags: needinfo?(swaroop.rao)
Flags: needinfo?(margaret.leibovic)
Verified as fixed on latest Aurora build (45.0a2 07-01-2016), using a Nexus 4 with Android 5.1.1
Verified as fixed on the latest Beta build (44.0b7), using a Nexus 4 with Android 5.1.1
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

Creator:
Created:
Updated:
Size: