Genymobile / Genymobile/scrcpy
segmentation fault + ffmpeg parameter error + memory leaks
- Dominant language
- C
- Stars
- 150k
- Forks
- 13.7k
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 2
Description
**Environment**
- OS: Manjaro
- scrcpy version: git c27ab46e
- installation method: meson setup d -Db_sanitize=address
- device model: Samsung S10e
- Android version: 12
**Describe the bug**
scrcpy window is not opened, core dumped on segmentation fault.
```
$ ./run d
scrcpy 2.4
INFO: ADB device found:
INFO: --> (usb) XXX device SM_G970F
DEBUG: Device serial: XXX
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 161.2 MB/s (96676 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-G970F (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Display: using SurfaceControl API
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 550.54.14
INFO: Trilinear filtering enabled
DEBUG: Using SCRCPY_ICON_PATH: app/data/icon.png
AddressSanitizer:DEADLYSIGNAL
=================================================================
==620474==ERROR: AddressSanitizer: SEGV on unknown address 0x0000bfff8000 (pc 0x56455f163e3e bp 0x7ffcbab78680 sp 0x7ffcbab78570 T0)
==620474==The signal is caused by a READ memory access.
#0 0x56455f163e3e in decode_image ../app/src/icon.c:89
#1 0x56455f164510 in load_from_path ../app/src/icon.c:192
#2 0x56455f164e92 in scrcpy_icon_load ../app/src/icon.c:280
#3 0x56455f18130d in sc_screen_init ../app/src/screen.c:411
#4 0x56455f17dbae in scrcpy ../app/src/scrcpy.c:721
#5 0x56455f1455b7 in main_scrcpy ../app/src/main.c:88
#6 0x56455f1456db in main ../app/src/main.c:107
#7 0x7fbad4c76ccf (/usr/lib/libc.so.6+0x29ccf) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#8 0x7fbad4c76d89 in __libc_start_main (/usr/lib/libc.so.6+0x29d89) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#9 0x56455f145014 in _start (/mnt/d/GitHub/scrcpy/d/app/scrcpy+0x2b014) (BuildId: 626a8249afe58faf1f06254862a3863b1ad86115)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../app/src/icon.c:89 in decode_image
==620474==ABORTING
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[server] DEBUG: Screen streaming stopped
[server] DEBUG: Audio encoder stopped
```
So I tried running without an actual icon:
```
$ SCRCPY_SERVER_PATH=d/server/scrcpy-server SCRCPY_ICON_PATH="dev/null" d/app/scrcpy -V debug
scrcpy 2.4
INFO: ADB device found:
INFO: --> (usb) XXX device SM_G970F
DEBUG: Device serial: XXX
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 156.2 MB/s (96676 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-G970F (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Display: using SurfaceControl API
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 550.54.14
INFO: Trilinear filtering enabled
DEBUG: Using SCRCPY_ICON_PATH: dev/null
ERROR: Could not open icon image: dev/null
WARN: Could not load icon
DEBUG: Demuxer 'video': starting thread
DEBUG: Demuxer 'audio': starting thread
INFO: Texture: 1080x2280
ERROR: [FFmpeg] Value -619858224 for parameter 'in_sample_fmt' out of sample format range [-1 - 11]
ERROR: [FFmpeg] Requested input sample format -1 is invalid
ERROR: Failed to initialize the resampling context
ERROR: Demuxer error
DEBUG: quit...
DEBUG: Receiver stopped
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[server] DEBUG: Audio encoder stopped
DEBUG: Demuxer 'video': end of frames
WARN: Killing the server...
DEBUG: Server disconnected
DEBUG: Server terminated
=================================================================
==716268==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 184 byte(s) in 1 object(s) allocated from:
#0 0x7f8fdc8fc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f8fca0b1d8a (/usr/lib/libdbus-1.so.3+0x23d8a) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
Indirect leak of 1842 byte(s) in 2 object(s) allocated from:
#0 0x7f8fdc8fb6e2 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
#1 0x7f8fca0bfa4f (/usr/lib/libdbus-1.so.3+0x31a4f) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
SUMMARY: AddressSanitizer: 2026 byte(s) leaked in 3 allocation(s).
```
The ffmpeg binary is from package ffmpeg 2:6.1.1-7 from the manjaro extra repository
```
$ command ffmpeg
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13.2.1 (GCC) 20230801
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
```
OTG mode works:
```
$ SCRCPY_SERVER_PATH=d/server/scrcpy-server SCRCPY_ICON_PATH="dev/null" d/app/scrcpy --otg
scrcpy 2.4
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
INFO: USB device found:
INFO: --> XXX (04e8:6860) SAMSUNG SAMSUNG_Android
DEBUG: Starting AOA thread
DEBUG: Using SCRCPY_ICON_PATH: dev/null
ERROR: Could not open icon image: dev/null
WARN: Could not load icon
DEBUG: HID keyboard state synchronized
^CDEBUG: User requested to quit
DEBUG: quit...
=================================================================
==732119==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1684064 byte(s) in 102 object(s) allocated from:
#0 0x7f6658efca31 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f663ade8961 (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8961) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Direct leak of 270291 byte(s) in 59 object(s) allocated from:
#0 0x7f6658efc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f663ade8c1d (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8c1d) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Direct leak of 184 byte(s) in 1 object(s) allocated from:
#0 0x7f6658efc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f6646634d8a (/usr/lib/libdbus-1.so.3+0x23d8a) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
Indirect leak of 304108 byte(s) in 236 object(s) allocated from:
#0 0x7f6658efc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f663ade8c1d (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8c1d) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Indirect leak of 121585 byte(s) in 1012 object(s) allocated from:
#0 0x7f6658efca31 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f663ade8961 (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8961) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Indirect leak of 1842 byte(s) in 2 object(s) allocated from:
#0 0x7f6658efb6e2 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
#1 0x7f6646642a4f (/usr/lib/libdbus-1.so.3+0x31a4f) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
Indirect leak of 336 byte(s) in 1 object(s) allocated from:
#0 0x7f6658efb6e2 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
#1 0x7f663ade8ff3 (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8ff3) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
SUMMARY: AddressSanitizer: 2382410 byte(s) leaked in 1413 allocation(s).
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the AddressSanitizer trace at app/src/icon.c:89 and inspect the icon-loading path. Reproduce the failure with the reported Manjaro, Android 12, and FFmpeg setup, then separately investigate the audio demuxer errors and sanitizer leak reports. Done means the reported crash is resolved and the remaining errors are explained or fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, c
- Domain
- audio-video-rtc, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100