Closed Bug 935414 Opened 7 years ago Closed 7 years ago

crash in android.database.sqlite.SQLiteException: at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)

Categories

(Firefox for Android :: General, defect)

All
Android
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Firefox 28

People

(Reporter: cos_flaviu, Assigned: Margaret)

Details

(Keywords: crash)

Crash Data

Attachments

(1 file)

This bug was filed from the Socorro interface and is 
report bp-ad0672b6-39b6-4d70-9c42-15f2f2131106.
=============================================================

Steps to reproduce:
1. Open http://en.wikipedia.org/wiki/Mozilla;
2. Select a large paragraph and copy it to the clipboard e.g.: the history paragraph;
3. Paste the copied text in the url bar;

Expected result:
The text is successfully inserted in the url bar and the default search engine will search for that text.

Actual result:
The application crashes.

Stack trace:

android.database.sqlite.SQLiteException: parser stack overflow: , while compiling: SELECT _id, url, title, MAX(display) AS display, bookmark_id, history_id FROM combined WHERE ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((url LIKE ? OR title LIKE ?)) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) AND ((url LIKE ? OR title LIKE ?))) GROUP BY url ORDER BY (CASE WHEN bookmark_id > -1 THEN 100 ELSE 0 END) + visits * MAX(1, 100 * 225 / ((date - 1383729482311) / 86400000*(date - 1383729482311) / 86400000 + 225))  DESC LIMIT 100
	at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
	at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
	at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
	at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:127)
	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
	at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:53)
	at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
	at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1564)
	at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:354)
	at org.mozilla.gecko.db.BrowserProvider.query(BrowserProvider.java:2691)
	at android.content.ContentProvider$Transport.query(ContentProvider.java:178)
	at android.content.ContentResolver.query(ContentResolver.java:311)
	at org.mozilla.gecko.db.LocalBrowserDB.filterAllSites(LocalBrowserDB.java:173)
	at org.mozilla.gecko.db.LocalBrowserDB.filterAllSites(LocalBrowserDB.java:141)
	at org.mozilla.gecko.db.LocalBrowserDB.filter(LocalBrowserDB.java:221)
	at org.mozilla.gecko.db.BrowserDB.filter(BrowserDB.java:134)
	at org.mozilla.gecko.home.SearchLoader$SearchCursorLoader.loadCursor(SearchLoader.java:70)
	at org.mozilla.gecko.home.SimpleCursorLoader.loadInBackground(SimpleCursorLoader.java:49)
	at org.mozilla.gecko.home.SearchLoader$SearchCursorLoader.loadInBackground(SearchLoader.java:56)
	at org.mozilla.gecko.home.SimpleCursorLoader.loadInBackground(SimpleCursorLoader.java:31)
	at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:240)
	at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
	at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
	at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
	at java.util.concurrent.FutureTask.run(FutureTask.java:137)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
	at java.lang.Thread.run(Thread.java:856)
I thought we found and fixed this type of crash already. The crash report is from Fx28.
Flags: needinfo?(lucasr.at.mozilla)
(In reply to Mark Finkle (:mfinkle) from comment #1)
> I thought we found and fixed this type of crash already. The crash report is
> from Fx28.

That's in a different part of our code. This code has been there for a long time. Margaret, IIRC, you implemented the code that splits the query into multiple words a long time ago, right?
Flags: needinfo?(lucasr.at.mozilla) → needinfo?(margaret.leibovic)
I think the type of crash we fixed was related to the favicons (I think Lucas fixed that one).

Yes, this is caused by the code I wrote that splits the query, which was added a very long time ago:
http://hg.mozilla.org/mozilla-central/rev/823ab3b9d814

This crash seems like a bit of a pathological case, but I suppose we could change this for loop to only include the first few terms in the WHERE clause:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/db/LocalBrowserDB.java#150
Flags: needinfo?(margaret.leibovic)
Assignee: nobody → margaret.leibovic
(In reply to :Margaret Leibovic from comment #4)

> This crash seems like a bit of a pathological case, but I suppose we could
> change this for loop to only include the first few terms in the WHERE clause:
> http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/db/
> LocalBrowserDB.java#150

Agreed that this is a bit of an edge case. The easy fix, as you suggest is to limit the number of search terms.

How about 25? I totally picked that number at random.
Attached patch patchSplinter Review
Before seeing mfinkle's last comment, I chose 10. I have a hard time believe anything would actually match even 10 constraint words, since the logic here is to find history/bookmark urls/titles that have all of these constraint words somewhere in them.
Attachment #828454 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 828454 [details] [diff] [review]
patch

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

Makes sense.

::: mobile/android/base/db/LocalBrowserDB.java
@@ +145,5 @@
>              int limit, CharSequence urlFilter, String selection, String[] selectionArgs) {
>          // The combined history/bookmarks selection queries for sites with a url or title containing
>          // the constraint string(s), treating space-separated words as separate constraints
>          if (!TextUtils.isEmpty(constraint)) {
>            String[] constraintWords = constraint.toString().split(" ");

nit: empty line here.

@@ +147,5 @@
>          // the constraint string(s), treating space-separated words as separate constraints
>          if (!TextUtils.isEmpty(constraint)) {
>            String[] constraintWords = constraint.toString().split(" ");
> +          // Only create a filter query with a maximum of 10 constraint words
> +          String constraintCount = Math.min(constraintWords.length, 10);

I guess you meant int here?
Attachment #828454 - Flags: review?(lucasr.at.mozilla) → review+
Comment on attachment 828454 [details] [diff] [review]
patch

>+          // Only create a filter query with a maximum of 10 constraint words
>+          String constraintCount = Math.min(constraintWords.length, 10);
>+          for (int i = 0; i < constraintCount; i++) {

Would making a named constant for the "10" be nice?
(In reply to Lucas Rocha (:lucasr) from comment #7)

> @@ +147,5 @@
> >          // the constraint string(s), treating space-separated words as separate constraints
> >          if (!TextUtils.isEmpty(constraint)) {
> >            String[] constraintWords = constraint.toString().split(" ");
> > +          // Only create a filter query with a maximum of 10 constraint words
> > +          String constraintCount = Math.min(constraintWords.length, 10);
> 
> I guess you meant int here?

Oops yeah, that's why I don't normally write patches at night :)

(In reply to Mark Finkle (:mfinkle) from comment #8)
> Comment on attachment 828454 [details] [diff] [review]
> patch
> 
> >+          // Only create a filter query with a maximum of 10 constraint words
> >+          String constraintCount = Math.min(constraintWords.length, 10);
> >+          for (int i = 0; i < constraintCount; i++) {
> 
> Would making a named constant for the "10" be nice?

I feel like if it's only used here, it's fine to just use the number inline like this. Removes one step of seeing what the code is actually doing.
https://hg.mozilla.org/mozilla-central/rev/9ad1c37880b7
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 28
You need to log in before you can comment on or make changes to this bug.