scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Segmentation fault

Open Monirzadeh opened this issue 1 year ago • 10 comments

Hi i try to run this on RPi3B+ install that from aarch64 official repository but when i try run scrcpy get Segmentation fault (core dumped) anybody know what is the problem or way to gather more information?

Monirzadeh avatar Aug 27 '24 15:08 Monirzadeh

Try to build manually with ASAN enabled, then run: https://github.com/Genymobile/scrcpy/issues/3843#issuecomment-1477711086

rom1v avatar Aug 27 '24 16:08 rom1v

i done that the way you say and get this when run get this

 ./run d
scrcpy 2.6.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  deviceid                        device  devicename
DEBUG: Device serial: deviceid
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped.
Aborted 
DEBUG: Interrupting socket
DEBUG: Server disconnected
DEBUG: Server terminated
ERROR: Server connection failed

=================================================================
==1761==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 768 byte(s) in 1 object(s) allocated from:
    #0 0xffffa995f0d8 in realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
    #1 0xffffa70352a0  (/usr/lib/libSDL2-2.0.so.0+0xa52a0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #2 0xffffa7077450  (/usr/lib/libSDL2-2.0.so.0+0xe7450) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #3 0xffffa70c00e0  (/usr/lib/libSDL2-2.0.so.0+0x1300e0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #4 0xffffa16268c0  (/usr/lib/libffi.so.8+0x68c0) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #5 0xffffa1625f70  (/usr/lib/libffi.so.8+0x5f70) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #6 0xffff9c93ad50  (/usr/lib/libasan.so.8.0.0+0xa48d50)
    #7 0xffff9c936390  (/usr/lib/libasan.so.8.0.0+0xa44390)
    #8 0xffff9c937a08  (/usr/lib/libasan.so.8.0.0+0xa45a08)
    #9 0xffff9c938a08  (/usr/lib/libasan.so.8.0.0+0xa46a08)
    #10 0xffffa70c1914  (/usr/lib/libSDL2-2.0.so.0+0x131914) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #11 0xffffa707e4f0  (/usr/lib/libSDL2-2.0.so.0+0xee4f0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #12 0xffffa6fc1174  (/usr/lib/libSDL2-2.0.so.0+0x31174) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #13 0xaaaaafd0e16c in scrcpy ../app/src/scrcpy.c:458
    #14 0xaaaaafccc198 in main_scrcpy ../app/src/main.c:88
    #15 0xaaaaafccc2e0 in main ../app/src/main.c:107
    #16 0xffffa6d68290  (/usr/lib/libc.so.6+0x28290) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #17 0xffffa6d68374 in __libc_start_main (/usr/lib/libc.so.6+0x28374) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #18 0xaaaaafccba2c in _start (/home/alarm/scrcpy/d/app/scrcpy+0x2ba2c) (BuildId: 63f45f231e69bca511fe6399beb10ef1c6eb8a7e)

Direct leak of 96 byte(s) in 1 object(s) allocated from:
    #0 0xffffa995fec4 in calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0xffff9c935c00  (/usr/lib/libasan.so.8.0.0+0xa43c00)
    #2 0xffff9c9380cc  (/usr/lib/libasan.so.8.0.0+0xa460cc)
    #3 0xffff9c93877c  (/usr/lib/libasan.so.8.0.0+0xa4677c)
    #4 0xffffa70b9008  (/usr/lib/libSDL2-2.0.so.0+0x129008) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #5 0xffffa16268c0  (/usr/lib/libffi.so.8+0x68c0) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #6 0xffffa1625f70  (/usr/lib/libffi.so.8+0x5f70) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #7 0xffff9c93ad50  (/usr/lib/libasan.so.8.0.0+0xa48d50)
    #8 0xffff9c936390  (/usr/lib/libasan.so.8.0.0+0xa44390)
    #9 0xffff9c937a08  (/usr/lib/libasan.so.8.0.0+0xa45a08)
    #10 0xffff9c938a08  (/usr/lib/libasan.so.8.0.0+0xa46a08)
    #11 0xffffa70c18fc  (/usr/lib/libSDL2-2.0.so.0+0x1318fc) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #12 0xffffa707e4f0  (/usr/lib/libSDL2-2.0.so.0+0xee4f0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #13 0xffffa6fc1174  (/usr/lib/libSDL2-2.0.so.0+0x31174) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #14 0xaaaaafd0e16c in scrcpy ../app/src/scrcpy.c:458
    #15 0xaaaaafccc198 in main_scrcpy ../app/src/main.c:88
    #16 0xaaaaafccc2e0 in main ../app/src/main.c:107
    #17 0xffffa6d68290  (/usr/lib/libc.so.6+0x28290) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #18 0xffffa6d68374 in __libc_start_main (/usr/lib/libc.so.6+0x28374) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #19 0xaaaaafccba2c in _start (/home/alarm/scrcpy/d/app/scrcpy+0x2ba2c) (BuildId: 63f45f231e69bca511fe6399beb10ef1c6eb8a7e)

SUMMARY: AddressSanitizer: 864 byte(s) leaked in 2 allocation(s).
[alarm@alarm scrcpy]$ ./run d
scrcpy 2.6.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  deviceid                        device  devicename
DEBUG: Device serial: deviceid
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped.
Aborted 
DEBUG: Interrupting socket
DEBUG: Server disconnected
DEBUG: Server terminated
ERROR: Server connection failed

=================================================================
==2153==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 768 byte(s) in 1 object(s) allocated from:
    #0 0xffff96eff0d8 in realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
    #1 0xffff945d52a0  (/usr/lib/libSDL2-2.0.so.0+0xa52a0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #2 0xffff94617450  (/usr/lib/libSDL2-2.0.so.0+0xe7450) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #3 0xffff946600e0  (/usr/lib/libSDL2-2.0.so.0+0x1300e0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #4 0xffff8ebc68c0  (/usr/lib/libffi.so.8+0x68c0) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #5 0xffff8ebc5f70  (/usr/lib/libffi.so.8+0x5f70) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #6 0xffff89dbad50  (/home/alarm/scrcpy/d/app/scrcpy+0x15ad50)
    #7 0xffff89db6390  (/home/alarm/scrcpy/d/app/scrcpy+0x156390)
    #8 0xffff89db7a08  (/home/alarm/scrcpy/d/app/scrcpy+0x157a08)
    #9 0xffff89db8a08  (/home/alarm/scrcpy/d/app/scrcpy+0x158a08)
    #10 0xffff94661914  (/usr/lib/libSDL2-2.0.so.0+0x131914) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #11 0xffff9461e4f0  (/usr/lib/libSDL2-2.0.so.0+0xee4f0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #12 0xffff94561174  (/usr/lib/libSDL2-2.0.so.0+0x31174) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #13 0xaaaae889e16c in scrcpy ../app/src/scrcpy.c:458
    #14 0xaaaae885c198 in main_scrcpy ../app/src/main.c:88
    #15 0xaaaae885c2e0 in main ../app/src/main.c:107
    #16 0xffff94308290  (/usr/lib/libc.so.6+0x28290) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #17 0xffff94308374 in __libc_start_main (/usr/lib/libc.so.6+0x28374) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #18 0xaaaae885ba2c in _start (/home/alarm/scrcpy/d/app/scrcpy+0x2ba2c) (BuildId: 63f45f231e69bca511fe6399beb10ef1c6eb8a7e)

Direct leak of 96 byte(s) in 1 object(s) allocated from:
    #0 0xffff96effec4 in calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0xffff89db5c00  (/home/alarm/scrcpy/d/app/scrcpy+0x155c00)
    #2 0xffff89db80cc  (/home/alarm/scrcpy/d/app/scrcpy+0x1580cc)
    #3 0xffff89db877c  (/home/alarm/scrcpy/d/app/scrcpy+0x15877c)
    #4 0xffff94659008  (/usr/lib/libSDL2-2.0.so.0+0x129008) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #5 0xffff8ebc68c0  (/usr/lib/libffi.so.8+0x68c0) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #6 0xffff8ebc5f70  (/usr/lib/libffi.so.8+0x5f70) (BuildId: 6514cfa6562037b60546ebb66ae16a30d3b2ade9)
    #7 0xffff89dbad50  (/home/alarm/scrcpy/d/app/scrcpy+0x15ad50)
    #8 0xffff89db6390  (/home/alarm/scrcpy/d/app/scrcpy+0x156390)
    #9 0xffff89db7a08  (/home/alarm/scrcpy/d/app/scrcpy+0x157a08)
    #10 0xffff89db8a08  (/home/alarm/scrcpy/d/app/scrcpy+0x158a08)
    #11 0xffff946618fc  (/usr/lib/libSDL2-2.0.so.0+0x1318fc) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #12 0xffff9461e4f0  (/usr/lib/libSDL2-2.0.so.0+0xee4f0) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #13 0xffff94561174  (/usr/lib/libSDL2-2.0.so.0+0x31174) (BuildId: 1d1dc831945cc801a6b5d8c06e94012af3abcf48)
    #14 0xaaaae889e16c in scrcpy ../app/src/scrcpy.c:458
    #15 0xaaaae885c198 in main_scrcpy ../app/src/main.c:88
    #16 0xaaaae885c2e0 in main ../app/src/main.c:107
    #17 0xffff94308290  (/usr/lib/libc.so.6+0x28290) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #18 0xffff94308374 in __libc_start_main (/usr/lib/libc.so.6+0x28374) (BuildId: a284d5e76f240b0feab8ae24ae91fe38c3cbb7b3)
    #19 0xaaaae885ba2c in _start (/home/alarm/scrcpy/d/app/scrcpy+0x2ba2c) (BuildId: 63f45f231e69bca511fe6399beb10ef1c6eb8a7e)

SUMMARY: AddressSanitizer: 864 byte(s) leaked in 2 allocation(s).

Monirzadeh avatar Aug 27 '24 19:08 Monirzadeh

d/server/scrcpy-server: 1 file pushed, 0 skipped. Aborted DEBUG: Interrupting socket DEBUG: Server disconnected DEBUG: Server terminated ERROR: Server connection failed

Oh, the segfault (Aborted) happens on the device, not on the client (which still prints more logs after the device crashed).

In the end, there are just a memory leak in SDL:

#13 0xaaaaafd0e16c in scrcpy ../app/src/scrcpy.c:458

https://github.com/Genymobile/scrcpy/blob/44b3fd82b1831f4aa436268870adf32bddb81924/app/src/scrcpy.c#L458

Can you reproduce the problem on another device?

What is the stack trace in adb logcat?

rom1v avatar Aug 27 '24 19:08 rom1v

random undervoltage in raspberry can be the reason? same things happen in wireless mode too (use prebuild scrcpy-server-v2.6.1 ) this android device work prefect on a system with x86. i will test rpi with other android device. adb logcat give me a really long log do you want to check specific things in it?

Monirzadeh avatar Aug 27 '24 20:08 Monirzadeh

adb logcat give me a really long log do you want to check specific things in it?

Clear the logs before running scrcpy:

adb logcat -c   # clear logcat
scrcpy
adb logcat -d > logcat.txt

rom1v avatar Aug 27 '24 20:08 rom1v

adb logcat give me a really long log do you want to check specific things in it?

Clear the logs before running scrcpy:

adb logcat -c   # clear logcat
scrcpy
adb logcat -d > logcat.txt

https://paste.mozilla.org/PHhkOF9P

Monirzadeh avatar Aug 27 '24 20:08 Monirzadeh

08-28 00:48:48.723 8964 8964 W ziparchive: Unable to open '/data/local/tmp/scrcpy-server.dm': No such file or directory
08-28 00:48:48.723 8964 8964 W app_process: Failed to find magic
08-28 00:48:48.730 8964 8964 E appproc : ERROR: could not find class 'com.genymobile.scrcpy.Server'
08-28 00:48:48.731 8964 8964 F app_process: thread.cc:2468] No pending exception expected: java.lang.ClassNotFoundException: com.genymobile.scrcpy.Server

That's weird.

Can you push scrcpy-server to /data/local/tmp? Does this folder exists on the device?

rom1v avatar Aug 27 '24 20:08 rom1v

08-28 00:48:48.723 8964 8964 W ziparchive: Unable to open '/data/local/tmp/scrcpy-server.dm': No such file or directory
08-28 00:48:48.723 8964 8964 W app_process: Failed to find magic
08-28 00:48:48.730 8964 8964 E appproc : ERROR: could not find class 'com.genymobile.scrcpy.Server'
08-28 00:48:48.731 8964 8964 F app_process: thread.cc:2468] No pending exception expected: java.lang.ClassNotFoundException: com.genymobile.scrcpy.Server

That's weird.

Can you push scrcpy-server to /data/local/tmp? Does this folder exists on the device?

i test other device and same things happen both android device work fine on amd64 pc but this problem happen in rpi push prebuild version? there is a scrcpy-server.jar there. should i backup that?

Monirzadeh avatar Aug 27 '24 20:08 Monirzadeh

after push prebuild and rename to scrcpy-server.jar to the destination same things happen. Update: that server work fine to mirror screen on a amd64 linux machine just happen in rpi with aarch64

Monirzadeh avatar Aug 27 '24 20:08 Monirzadeh

Try to stream a video using a standalone server to try to understand where it fails: https://github.com/Genymobile/scrcpy/blob/master/doc/develop.md#standalone-server

rom1v avatar Aug 27 '24 20:08 rom1v

this problem happen in wayland i just try this on xorg and not get segmentation fault instead of get killed after a warrning about opengl. is it possible this problem be because of wayland in aarch? what is exactly the program show me the screen?

Monirzadeh avatar Aug 31 '24 22:08 Monirzadeh

Note that every time you run scrcpy-server, if you don't pass cleanup=false, the binary is deleted on the devixe and you must push it again.

this problem happen in wayland

Not the problem causing the exception on the device.

rom1v avatar Sep 01 '24 05:09 rom1v