Android操作数据库崩溃
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=1 (# cursors opened by this proc=1)
可能原因:
代码中对insert、query等操作有做同步,但是query完成之后在遍历查询结果时cursor还在使用,没有close,而此处没做同步。这时其它线程又执行了insert操作,导致报此异常。
解决方法:
给整个查询操作都加上同步,即cusor没close前也不许做其它操作,经测试,不再崩了。
崩溃日志
2019-10-29 09:57:22.699 524-628/? E/connsyslogger: Bootup Log: 0 log files! 2019-10-29 09:57:25.097 509-1619/? E/MP3Extractor: Unable to resync. Signalling end of stream. 2019-10-29 09:57:26.500 509-1619/? E/MP3Extractor: Unable to resync. Signalling end of stream. 2019-10-29 09:57:26.506 509-1619/? E/MP3Extractor: Unable to resync. Signalling end of stream. 2019-10-29 09:57:32.699 524-628/? E/connsyslogger: Bootup Log: 0 log files! 2019-10-29 09:57:42.699 524-628/? E/connsyslogger: Bootup Log: 0 log files! 2019-10-29 09:57:45.494 7752-7856/? E/SQLiteLog: (14) cannot open file at line 35807 of [553a923c82] 2019-10-29 09:57:45.494 7752-7856/? E/SQLiteLog: (14) os_unix.c:35807: (24) open(/storage/emulated/0/.demo/demo.db-journal) - 2019-10-29 09:57:45.495 7752-7856/? E/g: unable to open database file (code 14) 2019-10-29 09:57:45.501 7752-7791/? E/SharedPreferencesImpl: Couldn't create directory for SharedPreferences file /data/user/0/com.demo.test/shared_prefs/notify_sync_pref.xml 2019-10-29 09:57:45.513 7752-8062/? E/CursorWindow: Could not allocate CursorWindow '/storage/emulated/0/.demo/demo.db' of size 2097152 due to error -24. 2019-10-29 09:57:45.514 7752-8062/? E/g: Cursor window allocation of 2048 kb failed. # Open Cursors=1 (# cursors opened by this proc=1) 2019-10-29 09:57:45.532 7752-8058/? E/CursorWindow: Could not allocate CursorWindow '/storage/emulated/0/.demo/demo.db' of size 2097152 due to error -24. 2019-10-29 09:57:45.534 7752-8058/? E/AndroidRuntime: FATAL EXCEPTION: Timer-4 Process: com.demo.test, PID: 7752 android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=1 (# cursors opened by this proc=1) at android.database.CursorWindow.<init>(CursorWindow.java:108) at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:140) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:134) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:220) at android.database.AbstractCursor.moveToNext(AbstractCursor.java:275) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) 2019-10-29 09:57:45.536 7752-9049/? E/NativeCrypto: AppData::create pipe(2) failed: Too many open files 2019-10-29 09:57:45.538 7752-9049/? E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Process: com.demo.test, PID: 7752 java.lang.RuntimeException: javax.net.ssl.SSLException: Unable to create application data at com.android.org.conscrypt.ConscryptFileDescriptorSocket.newSsl(ConscryptFileDescriptorSocket.java:161) at com.android.org.conscrypt.ConscryptFileDescriptorSocket.<init>(ConscryptFileDescriptorSocket.java:152) at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:149) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: javax.net.ssl.SSLException: Unable to create application data at com.android.org.conscrypt.NativeCrypto.SSL_new(Native Method) at com.android.org.conscrypt.SslWrapper.newInstance(SslWrapper.java:58) at com.android.org.conscrypt.ConscryptFileDescriptorSocket.newSsl(ConscryptFileDescriptorSocket.java:159) at com.android.org.conscrypt.ConscryptFileDescriptorSocket.<init>(ConscryptFileDescriptorSocket.java:152) at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:149) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) 2019-10-29 09:57:45.549 7752-7856/? E/SQLiteLog: (14) cannot open file at line 35807 of [553a923c82] 2019-10-29 09:57:45.549 7752-7856/? E/SQLiteLog: (14) os_unix.c:35807: (24) open(/storage/emulated/0/.demo/demo.db-journal) - 2019-10-29 09:57:45.549 7752-7856/? E/g: unable to open database file (code 14) 2019-10-29 09:57:45.550 7752-8062/? E/CursorWindow: Could not allocate CursorWindow '/storage/emulated/0/.demo/demo.db' of size 2097152 due to error -24. 2019-10-29 09:57:45.550 7752-8062/? E/g: Cursor window allocation of 2048 kb failed. 2019-10-29 09:57:45.745 391-1578/? E/SurfaceFlinger: Failed to find layer (com.demo.test/com.demo.test.ui.LauncherUI#0) in layer parent (no-parent). 2019-10-29 09:57:46.156 339-339/? E/SELinux: avc: denied { find } for service=persistent_data_block pid=9053 uid=10115 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:persistent_data_block_service:s0 tclass=service_manager permissive=0 2019-10-29 09:57:46.420 9072-9072/? E/VA++: Enter init before all. 2019-10-29 09:57:46.421 9072-9072/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 9072 (dex2oat), pid 9072 (dex2oat) 2019-10-29 09:57:46.455 9075-9075/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: Build fingerprint: 'xiaomi/cactus/cactus:8.1.0/O11019/V10.2.2.0.OCBCNXM:user/release-keys' 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: Revision: '0' 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: ABI: 'arm' 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: pid: 9072, tid: 9072, name: dex2oat >>> /system/bin/dex2oat <<< 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: Cause: null pointer dereference 2019-10-29 09:57:46.456 9075-9075/? A/DEBUG: r0 a5d98ee0 r1 00000000 r2 00000000 r3 a5d8351c 2019-10-29 09:57:46.457 9075-9075/? A/DEBUG: r4 0000002f r5 0000003c r6 a6d723b8 r7 be903d00 2019-10-29 09:57:46.457 9075-9075/? A/DEBUG: r8 a5d98ec0 r9 0000001d sl a5dad000 fp a5d98ea0 2019-10-29 09:57:46.457 9075-9075/? A/DEBUG: ip a6096d5c sp be903cb0 lr a606d435 pc a6d01d36 cpsr 60010030 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: backtrace: 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #00 pc 0003cd36 /data/app/com.demo.test-Na9co-xJbmsEf7wA2fNt1Q==/lib/arm/libva++.so (add_replace_item(char const*, char const*)+145) 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #01 pc 000387a7 /data/app/com.demo.test-Na9co-xJbmsEf7wA2fNt1Q==/lib/arm/libva++.so (IOUniformer::init_env_before_all()+530) 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #02 pc 000135dd /system/bin/linker (__dl__ZL13call_functionPKcPFviPPcS2_ES0_+68) 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #03 pc 000134b5 /system/bin/linker (__dl__ZN6soinfo17call_constructorsEv+336) 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #04 pc 000133d7 /system/bin/linker (__dl__ZN6soinfo17call_constructorsEv+114) 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #05 pc 00010077 /system/bin/linker (__dl___linker_init+2406) 2019-10-29 09:57:46.461 9075-9075/? A/DEBUG: #06 pc 00014f6c /system/bin/linker (_start+4) 2019-10-29 09:57:46.505 9076-9076/? E/AEE_AED: Skipped - do not care third party apk 2019-10-29 09:57:46.506 9075-9075/? E/crash_dump32: cannot open libmiuindbg.so: No such file or directory 2019-10-29 09:57:46.973 9077-9077/? E/VA++: Enter init before all. 2019-10-29 09:57:46.973 9077-9077/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 9077 (dex2oat), pid 9077 (dex2oat) 2019-10-29 09:57:47.005 9080-9080/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 2019-10-29 09:57:47.006 9080-9080/? A/DEBUG: Build fingerprint: 'xiaomi/cactus/cactus:8.1.0/O11019/V10.2.2.0.OCBCNXM:user/release-keys' 2019-10-29 09:57:47.006 9080-9080/? A/DEBUG: Revision: '0' 2019-10-29 09:57:47.006 9080-9080/? A/DEBUG: ABI: 'arm' 2019-10-29 09:57:47.006 9080-9080/? A/DEBUG: pid: 9077, tid: 9077, name: dex2oat >>> /system/bin/dex2oat <<< 2019-10-29 09:57:47.006 9080-9080/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4 2019-10-29 09:57:47.006 9080-9080/? A/DEBUG: Cause: null pointer dereference 2019-10-29 09:57:47.007 9080-9080/? A/DEBUG: r0 ad198ee0 r1 00000000 r2 00000000 r3 ad18351c 2019-10-29 09:57:47.007 9080-9080/? A/DEBUG: r4 0000002f r5 0000003c r6 ad52e3b8 r7 beea2d00 2019-10-29 09:57:47.007 9080-9080/? A/DEBUG: r8 ad198ec0 r9 0000001d sl ad1ad000 fp ad198ea0 2019-10-29 09:57:47.007 9080-9080/? A/DEBUG: ip ad7e7d5c sp beea2cb0 lr ad7be435 pc ad4bdd36 cpsr 60010030 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: backtrace: 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #00 pc 0003cd36 /data/app/com.demo.test-Na9co-xJbmsEf7wA2fNt1Q==/lib/arm/libva++.so (add_replace_item(char const*, char const*)+145) 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #01 pc 000387a7 /data/app/com.demo.test-Na9co-xJbmsEf7wA2fNt1Q==/lib/arm/libva++.so (IOUniformer::init_env_before_all()+530) 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #02 pc 000135dd /system/bin/linker (__dl__ZL13call_functionPKcPFviPPcS2_ES0_+68) 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #03 pc 000134b5 /system/bin/linker (__dl__ZN6soinfo17call_constructorsEv+336) 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #04 pc 000133d7 /system/bin/linker (__dl__ZN6soinfo17call_constructorsEv+114) 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #05 pc 00010077 /system/bin/linker (__dl___linker_init+2406) 2019-10-29 09:57:47.011 9080-9080/? A/DEBUG: #06 pc 00014f6c /system/bin/linker (_start+4) 2019-10-29 09:57:47.055 9081-9081/? E/AEE_AED: Skipped - do not care third party apk 2019-10-29 09:57:47.056 9080-9080/? E/crash_dump32: cannot open libmiuindbg.so: No such file or directory 2019-10-29 09:57:47.657 969-2119/? E/TouchFilter: setTouchFilter LOG Enable prameter: 0
发表评论