Title: java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds · Issue #537 · sqlcipher/android-database-sqlcipher · GitHub
Open Graph Title: java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds · Issue #537 · sqlcipher/android-database-sqlcipher
X Title: java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds · Issue #537 · sqlcipher/android-database-sqlcipher
Description: Expected Behavior App doesn't crash Actual Behavior App crashes due to SQLiteCipher on Android API 24-25 Steps to Reproduce App uses Room + SQLCipher. WAL is enabled. The only synthetic case how I can emulate crash is accessing SQLiteCom...
Open Graph Description: Expected Behavior App doesn't crash Actual Behavior App crashes due to SQLiteCipher on Android API 24-25 Steps to Reproduce App uses Room + SQLCipher. WAL is enabled. The only synthetic case how I ...
X Description: Expected Behavior App doesn't crash Actual Behavior App crashes due to SQLiteCipher on Android API 24-25 Steps to Reproduce App uses Room + SQLCipher. WAL is enabled. The only synthetic case ho...
Opengraph URL: https://github.com/sqlcipher/android-database-sqlcipher/issues/537
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":" java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds","articleBody":"### Expected Behavior\r\nApp doesn't crash\r\n### Actual Behavior\r\nApp crashes due to SQLiteCipher on Android API 24-25\r\n\r\n### Steps to Reproduce\r\n\r\nApp uses Room + SQLCipher.\r\nWAL is enabled. \r\n\r\nThe only synthetic case how I can emulate crash is accessing `SQLiteCompiledSql`(Use API 24-25 Android emulator):\r\n1) Launch thread A\r\n2) Launch thread B\r\n3) Block B, In A create `SQLiteCompiledSql` object, set `nStatement` so that `finalize` can run `releaseSqlStatement`, block A, unblock B\r\n4) In B launch start a long transaction, unblock A, do memory extensive work to cause GC\r\n5) Wait\r\n\r\nAndroid test Kotlin code(if required I can convert to Java):\r\n```\r\n @Test\r\n fun emulateCrash() = coroutineRule.runBlocking {\r\n dbRule.useWithProject {\r\n val latch1 = CountDownLatch(1)\r\n val latch2 = CountDownLatch(1)\r\n\r\n launch (Dispatchers.IO) {\r\n SQLiteProxy(db.openHelper.writableDatabase as SQLiteDatabase, \"SELECT 1 FROM Album\").setupStub()\r\n latch2.countDown()\r\n latch1.await()\r\n }\r\n\r\n latch2.await()\r\n db.withTransaction {\r\n latch1.countDown()\r\n while (true) {\r\n // no matter what - just pollute memory to cause GC\r\n val albumEntity = newAlbum(\r\n projectEntity = projectEntity,\r\n companyEntity = companyEntity\r\n )\r\n }\r\n }\r\n }\r\n }\r\n```\r\n\r\n```\r\npackage net.sqlcipher.database;\r\n\r\npublic class SQLiteProxy extends SQLiteCompiledSql {\r\n\r\n public SQLiteProxy(SQLiteDatabase db, String sql) {\r\n super(db, sql);\r\n }\r\n\r\n public void setupStub() {\r\n nStatement = Long.MAX_VALUE;\r\n }\r\n\r\n}\r\n```\r\n\r\nSQLCipher version (can be identified by executing `PRAGMA cipher_version;`):\r\n4.4.2 community\r\n\r\nSQLCipher for Android version:\r\n4.4.2\r\n\r\nRoom version:\r\n2.3.0-beta01\r\n\r\nMy guess would be how Android handles GC and especially `finalize()` on version API 24-25.\r\nSince there is DB lock() call that blocks/await thread this causes watchdog to throw exception.\r\nI've checked generated Room code and I don't see where the cursor can be not closed.\r\nNot sure when the compiled statement is not cached to emulate the scenario.\r\nHowever, it happens in normal code execution with extensive concurrent work and multiple transactions. \r\n\r\nCan `releaseSqlStatement` be removed from `finalize` or handled in a different way?\r\n","author":{"url":"https://github.com/oleksandr-semenov","@type":"Person","name":"oleksandr-semenov"},"datePublished":"2021-02-15T17:31:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":23},"url":"https://github.com/537/android-database-sqlcipher/issues/537"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b4a7a914-4937-a001-a1b7-140e9092f9f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3D4:1DE36E:12F1864:19F423B:6971E0FB |
| html-safe-nonce | c2449fbadc70432526b69cf3ecdd939a5ea44fb653e5a39fec8f640e6a5ce9e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0Q0OjFERTM2RToxMkYxODY0OjE5RjQyM0I6Njk3MUUwRkIiLCJ2aXNpdG9yX2lkIjoiMjMwMzUyNDM0NzExODIxNTQxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 696caea04cee8eb139402a689dada720755ed4346bdda65a4cf4f75c60806ce3 |
| hovercard-subject-tag | issue:808714040 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlcipher/android-database-sqlcipher/537/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9357f4a51bc1fc36f737f5011fcb41a0f840da23b77aa8e4046f72e8ff1c0059/sqlcipher/android-database-sqlcipher/issues/537 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9357f4a51bc1fc36f737f5011fcb41a0f840da23b77aa8e4046f72e8ff1c0059/sqlcipher/android-database-sqlcipher/issues/537 |
| og:image:alt | Expected Behavior App doesn't crash Actual Behavior App crashes due to SQLiteCipher on Android API 24-25 Steps to Reproduce App uses Room + SQLCipher. WAL is enabled. The only synthetic case how I ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | oleksandr-semenov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 683712716975b3393656edf09255a1d488d0e68ab7b9ac97e40ecf40036f696c |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlcipher/android-database-sqlcipher git https://github.com/sqlcipher/android-database-sqlcipher.git |
| octolytics-dimension-user_id | 649049 |
| octolytics-dimension-user_login | sqlcipher |
| octolytics-dimension-repository_id | 1466080 |
| octolytics-dimension-repository_nwo | sqlcipher/android-database-sqlcipher |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1466080 |
| octolytics-dimension-repository_network_root_nwo | sqlcipher/android-database-sqlcipher |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ed99da4e2de688dd1056894c1eccd4c82c6bbbfe |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width