Open zipswich opened 2 years ago
The issue doesn't match the logcat. Is it ACCERR o MAPERR? Because i solved ACCERR on my setup, but I don't know if that applies to your situation.
@riccardoPegaso Thank you for catching that. I have corrected it. It is SEGV_MAPERR.
@riccardoPegaso I have just realized that there are two types of crashes. The other one is related to SEGV_ACCERR. Could you tell me how you addressed the problem?
2022-02-25 13:13:44.736 684-2231/? W/SurfaceFlinger: Attempting to set client state on removed layer: com.serenegiant.usbcameratest8/com.serenegiant.usbcameratest8.MainActivity#1
2022-02-25 13:13:44.736 684-2231/? W/SurfaceFlinger: Attempting to destroy on removed layer: com.serenegiant.usbcameratest8/com.serenegiant.usbcameratest8.MainActivity#1
2022-02-25 13:13:44.753 684-2231/? W/SurfaceFlinger: Attempting to set client state on removed layer: Dim Layer for - Task=985#0
2022-02-25 13:13:44.753 684-2231/? W/SurfaceFlinger: Attempting to destroy on removed layer: Dim Layer for - Task=985#0
2022-02-25 13:13:44.795 15591-15653/com.serenegiant.usbcameratest8 W/libUVCCamera: [15653*UVCPreview.cpp:125:get_frame]:allocate new frame
2022-02-25 13:13:44.796 15591-15652/com.serenegiant.usbcameratest8 W/libUVCCamera: [15652*UVCPreview.cpp:125:get_frame]:allocate new frame
2022-02-25 13:13:44.805 950-950/? I/wmt_apkhideicon_service: wmt copy_wmt_ApkHideIcon
2022-02-25 13:13:44.841 15591-15652/com.serenegiant.usbcameratest8 A/libc: Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7cbf333334 in tid 15652 (CameraThread), pid 15591 (.usbcameratest8)
2022-02-25 13:13:44.851 684-684/? I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2022-02-25 13:13:44.852 684-684/? I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2022-02-25 13:13:44.898 15591-15653/com.serenegiant.usbcameratest8 W/libUVCCamera: [15653*UVCPreview.cpp:125:get_frame]:allocate new frame
2022-02-25 13:13:44.946 15659-15659/? I/crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
2022-02-25 13:13:44.947 1112-1112/? I//system/bin/tombstoned: received crash request for pid 15652
2022-02-25 13:13:44.948 15659-15659/? I/crash_dump64: performing dump of process 15591 (target tid = 15652)
2022-02-25 13:13:44.963 15659-15659/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: Build fingerprint: 'Android/sdm660_64/sdm660_64:9/PKQ1.190319.001/sw09090959:user/release-keys'
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: Revision: '0'
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: ABI: 'arm64'
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: pid: 15591, tid: 15652, name: CameraThread >>> com.serenegiant.usbcameratest8 <<<
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7cbf333334
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x0 0000000000001230 x1 0000007c82b95290 x2 0000000000000001 x3 0000007c84dc6f10
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x4 0000000000000001 x5 0000007c82b959c8 x6 0000007c82b95280 x7 0000007cbf333334
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x8 0000007c82baa4b0 x9 0000007c8513b430 x10 0000007c8513c830 x11 0000007c84fc2804
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x12 0000000000000008 x13 0000000000000180 x14 0000007c82bbb282 x15 0000000000001220
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x16 0000000000000000 x17 0000007c8513da4e x18 0000007c82bbbb97 x19 0000007c82b95994
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x20 0000007c84dc70f0 x21 0000007c84dc6ec4 x22 0000007c82b951e8 x23 0000000000000001
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x24 0000007c82b95940 x25 0000007c82b94bc0 x26 0000007c82b951b0 x27 0000007c82b95180
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: x28 0000000000000003 x29 0000007c84dc6e60
2022-02-25 13:13:44.964 15659-15659/? A/DEBUG: sp 0000007c84dc6e00 lr 0000007c84fab1cc pc 0000007c84fc4244
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: backtrace:
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #00 pc 0000000000044244 /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x3000)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #01 pc 000000000002b1c8 /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x3000)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #02 pc 0000000000023810 /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x3000)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #03 pc 000000000001afcc /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x3000) (jpeg_read_scanlines+152)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #04 pc 0000000000011324 /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x6b000) (uvc_mjpeg2rgbx+736)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #05 pc 0000000000013c40 /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x2e9000) (UVCPreview::do_preview(uvc_stream_ctrl*)+324)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #06 pc 0000000000013450 /data/app/com.serenegiant.usbcameratest8-tt80PRN4jHJ4X-nMuwuteg==/base.apk (offset 0x2e9000) (UVCPreview::preview_thread_func(void*)+48)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #07 pc 0000000000092090 /system/lib64/libc.so (__pthread_start(void*)+36)
2022-02-25 13:13:44.966 15659-15659/? A/DEBUG: #08 pc 000000000002393c /system/lib64/libc.so (__start_thread+68)
2022-02-25 13:13:45.104 15591-15653/com.serenegiant.usbcameratest8 W/libUVCCamera: [15653*UVCPreview.cpp:125:get_frame]:allocate new frame
2022-02-25 13:13:45.262 1112-1112/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_04
2022-02-25 13:13:45.268 1293-15662/? W/ActivityManager: Force finishing activity com.serenegiant.usbcameratest8/.MainActivity
2022-02-25 13:13:45.273 1293-15662/? D/ActivityTrigger: ActivityTrigger activityPauseTrigger
I don't know if it the same issue. There might a problem when targeting SDK > 28 due to an issue present from Android 10 and forward due to XOM. (this was NOT my issue)
My issue was that the height of the frame wasn't multiple of 8, so the copyFrame function overflows.
static void copyFrame(const uint8_t *src, uint8_t *dest, const int width, int height, const int stride_src, const int stride_dest) { const int h8 = height % 8; for (int i = 0; i < h8; i++) { memcpy(dest, src, width); dest += stride_dest; src += stride_src; } for (int i = 0; i < (height - h8); i += 8) { memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; memcpy(dest, src, width); dest += stride_dest; src += stride_src; } }
Adding -h8
on the second for fixes the issue
@riccardoPegaso That is an excellent tip. I used your code as following:
static void copyFrame(const uint8_t *src, uint8_t *dest, const int width, int height, const int stride_src, const int stride_dest) {
const int h8 = height % 8;
for (int i = 0; i < h8; i++) {
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
}
for (int i = 0; i < (height - h8); i += 8) {
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
memcpy(dest, src, width);
dest += stride_dest; src += stride_src;
}
}
My current crash is caused clear_pool():
void AbstractBufferedPipeline::clear_pool() {
ENTER();
Mutex::Autolock lock(pool_mutex);
for (auto iter = frame_pool.begin(); iter != frame_pool.end(); iter++) {
total_frame_num--;
uvc_free_frame(*iter);
}
frame_pool.clear();
EXIT();
}
uvc_free_frame(*iter) throws the following:
Abort message: 'Invalid address 0x7c8240de40 passed to free: value not allocated'
Preview frequently causes a crash:
2022-02-22 18:18:26.025 23242-23405/com.serenegiant.usbcameratest8 A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7c0531e848 in tid 23405 (CameraThread), pid 23242 (.usbcameratest8)
I wonder if anyone could shed some light on this crash.
Complete logcat: