Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Dalvic Crash when querying views #39

Closed
dwt opened this Issue · 6 comments

2 participants

Martin Häcker Marty Schoch
Martin Häcker

Hi,

I've got dalvic crashes when trying to run our couch app (with javascript views) from TouchDB.

06-29 10:28:02.630: V/TDDatabase(21034): Query catalog/categoryByCategory: SELECT key, value, docid FROM maps, revs, docs WHERE maps.view_id=? AND key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND revs.sequence = maps.sequence AND docs.doc_id = revs.doc_id ORDER BY key LIMIT ? OFFSET ?
06-29 10:28:02.646: D/dalvikvm(21034): GC_CONCURRENT freed 655K, 20% free 13326K/16647K, paused 4ms+2ms
06-29 10:28:02.692: E/dalvikvm(21034): JNI ERROR (app bug): local reference table overflow (max=512)
06-29 10:28:02.692: W/dalvikvm(21034): JNI local reference table (0x10adc40) dump:
06-29 10:28:02.692: W/dalvikvm(21034): Last 10 entries (of 512):
06-29 10:28:02.692: W/dalvikvm(21034): 511: 0x40a55900 java.lang.Class
06-29 10:28:02.692: W/dalvikvm(21034): 510: 0x416f2340 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 509: 0x416f02d0 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 508: 0x416f0210 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 507: 0x416e9310 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 506: 0x416e9278 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 505: 0x416d65e0 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 504: 0x416d59e0 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 503: 0x416d59c0 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.692: W/dalvikvm(21034): 502: 0x416d5910 java.lang.String "bd89e0edcdb79f37... (32 chars)
06-29 10:28:02.700: W/dalvikvm(21034): Summary:
06-29 10:28:02.700: W/dalvikvm(21034): 2 of java.lang.Class (2 unique instances)
06-29 10:28:02.700: W/dalvikvm(21034): 510 of java.lang.String (510 unique instances)
06-29 10:28:02.700: E/dalvikvm(21034): Failed adding to JNI local ref table (has 512 entries)
06-29 10:28:02.700: I/dalvikvm(21034): "TDListenerHandlerThread" prio=5 tid=11 RUNNABLE
06-29 10:28:02.700: I/dalvikvm(21034): | group="main" sCount=0 dsCount=0 obj=0x416ca328 self=0xdeae38
06-29 10:28:02.700: I/dalvikvm(21034): | sysTid=21047 nice=0 sched=0/0 cgrp=default handle=15469520
06-29 10:28:02.700: I/dalvikvm(21034): | schedstat=( 0 0 0 ) utm=113 stm=25 core=0
06-29 10:28:02.700: I/dalvikvm(21034): at libcore.icu.NativeCollation.openCollator(Native Method)
06-29 10:28:02.700: I/dalvikvm(21034): at libcore.icu.RuleBasedCollatorICU.(RuleBasedCollatorICU.java:55)
06-29 10:28:02.700: I/dalvikvm(21034): at java.text.Collator.getInstance(Collator.java:291)
06-29 10:28:02.700: I/dalvikvm(21034): at java.text.Collator.getInstance(Collator.java:281)
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.TDCollateJSON.compareStringsUnicode(TDCollateJSON.java:14)
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.sqlite.SQLiteQuery.nativeFillWindow(Native Method)
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:86)
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164)
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161)
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:201)
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.TDView.queryWithOptions(TDView.java:603)
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.router.TDRouter.queryDesignDoc(TDRouter.java:1342)
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.router.TDRouter.do_POST_DesignDocument(TDRouter.java:1368)
06-29 10:28:02.700: I/dalvikvm(21034): at java.lang.reflect.Method.invokeNative(Native Method)
06-29 10:28:02.700: I/dalvikvm(21034): at java.lang.reflect.Method.invoke(Method.java:511)
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.router.TDRouter.start(TDRouter.java:367)
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.listener.TDHTTPServlet$2.run(TDHTTPServlet.java:143)
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.Handler.handleCallback(Handler.java:605)
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.Handler.dispatchMessage(Handler.java:92)
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.Looper.loop(Looper.java:137)
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.HandlerThread.run(HandlerThread.java:60)
06-29 10:28:02.700: E/dalvikvm(21034): VM aborting
06-29 10:28:02.700: A/libc(21034): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

First hits on google where for this:

http://stackoverflow.com/questions/9372373/referencetable-overflow-max-512-jni
http://stackoverflow.com/questions/11109497/android-jni-error-app-bug-local-reference-table-overflow-max-512

So I would guess it's an integration issue with one of the native libraries.

Marty Schoch
Owner

Thanks for the bug report. I don't think its related to the views being implemented in Javascript, as the exception occurs when querying the view, which happens after we've generated all the data for it.

It appears like possibly we're leaking string references in the view collation process. I'll try to reproduce it on my own but a few things would help (if you can provide them)

  1. The .touchdb file where this problem occurs
  2. Full adb logcat output particularly during index.
  3. Some sense of how many rows are in the view, if they have anything special about them (particularly big or complex keys or values)
  4. Device where the problem is observed
Martin Häcker
  1. sorry, the file contains sensitive data
  2. How do I achieve that? For me Eclipse always scrolls it out of view and I can't seem to get at it later (Sorry again, eclipse newbie)
  3. about 3000 items in the database, that view should contain about 50 to 90 percent of those
  4. Samsung Galaxy Nexus 2
Marty Schoch
Owner
  1. I understand. Unfortunately so far I'm not able to reproduce the issue. I've tested with 10,000 rows in the view, and I've tested fewer rows with complex keys (1,024 element array). Can you give me a sense of what your keys look like?
  2. For this type of thing I run adb logcat from the command line and capture the output to a file. Something like:

adb logcat > touchdb_logs.txt

I see one place where its possible we're not cleaning up local references as early as we should. But I'm reluctant to change it until I can reproduce the problem. Is it possible you have complex keys with many parts of the key that match between subsequent records? That might cause deeper loop execution comparing strings without freeing things up. Any additional info you can provide here about what the map results look like will help.

Marty Schoch
Owner

Update: I've been able to reproduce the issue!

Marty Schoch
Owner

Now we properly release lcoal references to strings after they're no longer needed.

01f13ea

Marty Schoch mschoch closed this
Martin Häcker

Nice!

Yaron Y Goland yaronyg referenced this issue from a commit in thaliproject/couchbase-lite-android
Marty Schoch mschoch properly release local string references
caused crash when loops got deep comparing strings inside json key
fixes couchbaselabs/TouchDB-Android#39
01f13ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.