xhsyy / omnidroid

Automatically exported from code.google.com/p/omnidroid
Apache License 2.0
1 stars 0 forks source link

IllegalStateException raised from the SQLite module. #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run in the debug mode
2. Setup some rules
3. When the action triggered, look at the log.

IllegalStateException caused android system kill the SQLite process
especially when an action process tried to use some I/O stream.

This must be caused by some dbHelper was leaving their db cursor open.

Not a high priority, since nothing shows up on screen, but it would be nice
to solve this.

Original issue reported on code.google.com by EHo...@gmail.com on 14 Dec 2009 at 4:34

GoogleCodeExporter commented 9 years ago

Original comment by anshu.ah...@gmail.com on 27 May 2010 at 2:55

GoogleCodeExporter commented 9 years ago
Start to take a look at this issue.

Original comment by renc...@gmail.com on 16 Jun 2010 at 3:55

GoogleCodeExporter commented 9 years ago
Code review at:
http://codereview.appspot.com/1717045

Caused by:
Exception is caused by database cursor objects being left open even when not in 
use. Excerpt from the logs:
06-16 16:36:27.458: INFO/dalvikvm(234): Uncaught exception thrown by finalizer 
(will be discarded):
06-16 16:36:27.458: INFO/dalvikvm(234): Ljava/lang/IllegalStateException;: 
Finalizing cursor android.database.sqlite.SQLiteCursor@43818050 on 
RegisteredApps that has not been deactivated or closed
06-16 16:36:27.458: INFO/dalvikvm(234):     at 
android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
06-16 16:36:27.458: INFO/dalvikvm(234):     at 
dalvik.system.NativeStart.run(Native Method)

Another similar problem is found where the database object itself is left open 
even when not in use. Excerpt from the logs:

06-16 16:14:21.893: ERROR/Database(233): Leak found
06-16 16:14:21.893: ERROR/Database(233): java.lang.IllegalStateException: 
/data/data/edu.nyu.cs.omnidroid.app/databases/omnidroid SQLiteDatabase created 
and never closed
06-16 16:14:21.893: ERROR/Database(233):     at 
android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1581)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:
659)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:
652)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:482)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.ja
va:98)
06-16 16:14:21.893: ERROR/Database(233):     at 
edu.nyu.cs.omnidroid.app.model.CoreRuleDbHelper.<init>(CoreRuleDbHelper.java:65)
06-16 16:14:21.893: ERROR/Database(233):     at 
edu.nyu.cs.omnidroid.app.controller.HandlerService.onStart(HandlerService.java:5
8)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2776)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.app.ActivityThread.access$3400(ActivityThread.java:116)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1855)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.os.Looper.loop(Looper.java:123)
06-16 16:14:21.893: ERROR/Database(233):     at 
android.app.ActivityThread.main(ActivityThread.java:4203)
06-16 16:14:21.893: ERROR/Database(233):     at 
java.lang.reflect.Method.invokeNative(Native Method)
06-16 16:14:21.893: ERROR/Database(233):     at 
java.lang.reflect.Method.invoke(Method.java:521)
06-16 16:14:21.893: ERROR/Database(233):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-16 16:14:21.893: ERROR/Database(233):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-16 16:14:21.893: ERROR/Database(233):     at 
dalvik.system.NativeStart.main(Native Method)

Summary of changes:
Made sure that database cursor objects are closed when they are not needed 
after acquiring them. Same thing also applies to database objects.

Test Cases (must check the logs that no exception occurs while performing 
these):
1. Go all types of screens while creating a new rule - root event, add action, 
add filter.
2. With Omnidroid active, go to home and open another application. Go back to 
home and re-open Omnidroid.
3. Open Omnidroid and proceed to any screen as deep as possible. Keep on 
pressing back until you reach the home screen and reopen Omnidroid again.

Original comment by renc...@gmail.com on 18 Jun 2010 at 2:29

GoogleCodeExporter commented 9 years ago
Forgot to add one more test case:
4. Trigger a saved rule.

Original comment by renc...@gmail.com on 19 Jun 2010 at 2:06

GoogleCodeExporter commented 9 years ago
Checked-in on r757.

Original comment by renc...@gmail.com on 19 Jun 2010 at 3:09