google / volley

https://google.github.io/volley
Apache License 2.0
3.38k stars 754 forks source link

RequestQueue with threadPoolSize > 1 can can crash whole application #211

Closed Piers-Walter closed 6 years ago

Piers-Walter commented 6 years ago

I am having an issue with Volley which is causing my app to crash inconsistently. It seems that when I add multiple requests to the queue, and the threadPoolSize is greater than 1 the app can crash with the following error:

07-26 16:46:58.732 30178-30207/com.***.sd.*** A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x18 in tid 30207 (Thread-7), pid 30178 (.sd.***)

The crash never happens if the RequestQueue that I send these to has a threadPoolSize of 1, so I can only assume there is something with multithreading going on that is breaking inside Volley.

The crash is intermittent happening about 50% of the time which isn't very helpful when it comes to diagnosing it.

The RequestQueue is a static variable attached to my Application class being initialised in the following way:

mRequestQueue = Volley.newRequestQueue(getApplicationContext());

but it also happens if the queue is initialised like this:

mRequestQueue = new RequestQueue(new DiskBasedCache(getCacheDir(),16*1024*1024), new BasicNetwork(new HurlStack()),4);
mRequestQueue.start();

My requests are added to the queue in the following way:

stringRequest.setRetryPolicy(new DefaultRetryPolicy(2000,0,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
stringRequest.setShouldCache(false);
MyApp.mRequestQueue.add(stringRequest);

with stringRequest being a standard POST StringRequest with custom Authorization and Content-Type headers

The crash happens on multiple devices and with the app being built on multiple computers with Android Studio. I am using Volley 1.1.1. Any ideas as to what might be causing this?

The full tombstone for my app is as follows:


07-26 16:46:58.784 30315-30315/? W/crash_dump64: type=1400 audit(0.0:663): avc: denied { search } for name="com.***.sd.***" dev="dm-2" ino=466035 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
07-26 16:46:58.815 30315-30315/? I/crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
07-26 16:46:58.815 3842-3842/? I//system/bin/tombstoned: received crash request for pid 30178
07-26 16:46:58.816 30315-30315/? I/crash_dump64: performing dump of process 30178 (target tid = 30207)
07-26 16:46:58.817 30315-30315/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-26 16:46:58.818 30315-30315/? A/DEBUG: Build fingerprint: 'google/angler/angler:8.1.0/OPM6.171019.030.E1/4805388:user/release-keys'
    Revision: '0'
    ABI: 'arm64'
    pid: 30178, tid: 30207, name: Thread-7  >>> com.***.sd.*** <<<
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x18
    Cause: null pointer dereference
        x0   00000079a3a11480  x1   0000000000000000  x2   40c52fd2e401a117  x3   00000000ffffffff
        x4   0000000000000074  x5   c6a4a7935bd1e995  x6   c6a4a7935bd1e995  x7   92cd625b4ad188af
        x8   dba50055a49a0268  x9   dba50055a49a0268  x10  0000000000000006  x11  00000000ffffffff
        x12  00000079a6194400  x13  ffffffffa4a8f3c1  x14  00250ef300000000  x15  003b9aca00000000
        x16  0000007a3ec6eca8  x17  0000007a3ec0b4b8  x18  0000000000000020  x19  0000000000000051
        x20  00000079b12438e0  x21  00000079b1245780  x22  0000000000000018  x23  0000000000000000
        x24  00000079a3a11480  x25  00000079a299ac40  x26  00000079a2993000  x27  000000000002848b
        x28  00000079a612f760  x29  00000079a5be4890  x30  00000079a272d600
        sp   00000079a5be47e0  pc   00000079a272d60c  pstate 0000000060000000
07-26 16:46:58.814 30315-30315/? W/crash_dump64: type=1400 audit(0.0:664): avc: denied { search } for name="com.***.sd.***" dev="dm-2" ino=466035 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
07-26 16:46:58.875 30315-30315/? A/DEBUG: backtrace:
        #00 pc 000000000005160c  /data/data/com.***.sd.***/libperfa_arm64.so
        #01 pc 00000000000163fc  /system/lib64/libopenjdkjvmti.so (openjdkjvmti::JvmtiAllocationListener::ObjectAllocated(art::Thread*, art::ObjPtr<art::mirror::Object>*, unsigned long)+320)
        #02 pc 0000000000152a90  /system/lib64/libart.so (_ZN3art2gc4Heap24AllocObjectWithAllocatorILb1ELb1ENS_6mirror16SetLengthVisitorEEEPNS3_6ObjectEPNS_6ThreadENS_6ObjPtrINS3_5ClassEEEmNS0_13AllocatorTypeERKT1_+1744)
        #03 pc 0000000000536e6c  /system/lib64/libart.so (MterpNewArray+480)
        #04 pc 000000000053a394  /system/lib64/libart.so (ExecuteMterpImpl+4628)
        #05 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
        #06 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #07 pc 0000000000295a70  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+668)
        #08 pc 0000000000533f50  /system/lib64/libart.so (MterpInvokeStatic+264)
        #09 pc 000000000053ca94  /system/lib64/libart.so (ExecuteMterpImpl+14612)
        #10 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
        #11 pc 0000000000525450  /system/lib64/libart.so (artQuickToInterpreterBridge+1052)
        #12 pc 0000000000553d0c  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
        #13 pc 000000000054ab88  /system/lib64/libart.so (art_quick_invoke_stub+584)
        #14 pc 00000000000dc594  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+204)
        #15 pc 000000000046edc8  /system/lib64/libart.so (art::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::ArgArray*, art::JValue*, char const*)+100)
        #16 pc 000000000047025c  /system/lib64/libart.so (art::InvokeVirtualOrInterfaceWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+432)
        #17 pc 0000000000353754  /system/lib64/libart.so (art::JNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+616)
        #18 pc 0000000000110a8c  /system/lib64/libart.so (art::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+2424)
        #19 pc 00000000000fee04  /system/lib64/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+84)
07-26 16:46:58.876 30315-30315/? A/DEBUG:     #20 pc 0000000000030964  /system/lib64/libjavacrypto.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+120)
        #21 pc 000000000003122c  /system/lib64/libjavacrypto.so (cert_verify_callback(x509_store_ctx_st*, void*)+192)
        #22 pc 0000000000029fa4  /system/lib64/libssl.so (ssl_crypto_x509_session_verify_cert_chain(ssl_session_st*, ssl_st*)+232)
        #23 pc 00000000000145d0  /system/lib64/libssl.so (ssl3_connect+5756)
        #24 pc 000000000002218c  /system/lib64/libssl.so (SSL_do_handshake+116)
        #25 pc 0000000000026610  /system/lib64/libjavacrypto.so (NativeCrypto_SSL_do_handshake(_JNIEnv*, _jclass*, long, _jobject*, _jobject*, int)+268)
        #26 pc 000000000003c468  /system/framework/arm64/boot-conscrypt.oat (offset 0x1e000) (com.android.org.conscrypt.NativeCrypto.SSL_do_handshake+216)
        #27 pc 000000000054ae4c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
        #28 pc 00000000000dc5d0  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+264)
        #29 pc 000000000029b49c  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
        #30 pc 0000000000295a90  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+700)
        #31 pc 0000000000533f50  /system/lib64/libart.so (MterpInvokeStatic+264)
        #32 pc 000000000053ca94  /system/lib64/libart.so (ExecuteMterpImpl+14612)
        #33 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
07-26 16:46:58.877 30315-30315/? A/DEBUG:     #34 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #35 pc 0000000000295a70  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+668)
        #36 pc 0000000000532ad8  /system/lib64/libart.so (MterpInvokeVirtual+652)
        #37 pc 000000000053c914  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #38 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
        #39 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #40 pc 0000000000295a70  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+668)
        #41 pc 0000000000532ad8  /system/lib64/libart.so (MterpInvokeVirtual+652)
        #42 pc 000000000053c914  /system/lib64/libart.so (ExecuteMterpImpl+14228)
        #43 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
        #44 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #45 pc 0000000000295a70  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+668)
        #46 pc 0000000000533d68  /system/lib64/libart.so (MterpInvokeDirect+356)
        #47 pc 000000000053ca14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
        #48 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
07-26 16:46:58.878 30315-30315/? A/DEBUG:     #49 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #50 pc 0000000000295a70  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+668)
        #51 pc 0000000000533d68  /system/lib64/libart.so (MterpInvokeDirect+356)
        #52 pc 000000000053ca14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
        #53 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
        #54 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #55 pc 00000000002969b4  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb1ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+604)
        #56 pc 0000000000534244  /system/lib64/libart.so (MterpInvokeVirtualRange+604)
        #57 pc 000000000053cc14  /system/lib64/libart.so (ExecuteMterpImpl+14996)
        #58 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
        #59 pc 000000000027b7cc  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+216)
        #60 pc 0000000000295a70  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+668)
        #61 pc 0000000000533d68  /system/lib64/libart.so (MterpInvokeDirect+356)
        #62 pc 000000000053ca14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
        #63 pc 0000000000275c00  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
07-26 16:46:59.101 3754-3812/? E/QC-QMI: linux_qmi_qmux_io_wake_lock: Err in writing wakelock=qmuxd_port_wl_0, error [1:Operation not permitted]
    linux_qmi_qmux_io_wake_unlock: Err in writing wakelock=qmuxd_port_wl_0, error [1:Operation not permitted]
07-26 16:46:59.101 3763-4429/? D/audio_hw_primary: disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback speaker
07-26 16:46:59.110 3763-4429/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
07-26 16:47:00.544 3842-3842/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_04```
jpd236 commented 6 years ago

I think this is an Android Studio bug - note the top line of the backtrace:

#00 pc 000000000005160c /data/data/com.***.sd.***/libperfa_arm64.so

libperfa_arm64.so is related to Android Studio's profiler, and I found https://issuetracker.google.com/110924477 which seems likely to be related.

I would try reproducing using a Gradle build instead of building with Android Studio, and/or trying an older version of Android Studio. If you still hit issues, please feel free to reopen (though I'm not sure how you would given that libperfa wouldn't be in the back stack in that case).

Piers-Walter commented 6 years ago

Thanks for that, I'll keep an eye on that google issue and hope it gets resolved in the near future