Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Dalvic Crash when querying views #39

dwt opened this Issue · 6 comments

2 participants



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 Method)
06-29 10:28:02.700: I/dalvikvm(21034): at
06-29 10:28:02.700: I/dalvikvm(21034): at java.text.Collator.getInstance(
06-29 10:28:02.700: I/dalvikvm(21034): at java.text.Collator.getInstance(
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.TDCollateJSON.compareStringsUnicode(
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(
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.sqlite.SQLiteCursor.fillWindow(
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.sqlite.SQLiteCursor.getCount(
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.AbstractCursor.moveToPosition(
06-29 10:28:02.700: I/dalvikvm(21034): at android.database.AbstractCursor.moveToFirst(
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.TDView.queryWithOptions(
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.router.TDRouter.queryDesignDoc(
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.router.TDRouter.do_POST_DesignDocument(
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(
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.router.TDRouter.start(
06-29 10:28:02.700: I/dalvikvm(21034): at com.couchbase.touchdb.listener.TDHTTPServlet$
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.Handler.handleCallback(
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.Handler.dispatchMessage(
06-29 10:28:02.700: I/dalvikvm(21034): at android.os.Looper.loop(
06-29 10:28:02.700: I/dalvikvm(21034): at
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:

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


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
  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
  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.


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


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


@mschoch mschoch closed this


@yaronyg yaronyg referenced this issue from a commit in thaliproject/couchbase-lite-android
@mschoch mschoch properly release local string references
caused crash when loops got deep comparing strings inside json key
fixes couchbaselabs/TouchDB-Android#39
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.