scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

MacOS Segmentation fault: 11

Open wudelu opened this issue 5 years ago • 25 comments

/usr/local/Cellar/scrcpy/1.8/share/scr...shed. 0.6 MB/s (19850 bytes in 0.030s) 2020-05-21 18:31:56.356 scrcpy[30780:1970626] INFO: Initial texture: 1080x2160 Segmentation fault: 11 JokerWudeMacBook-Pro:~ jokerwu$ scrcpy -v scrcpy 1.8

dependencies:

  • SDL 2.0.9
  • libavcodec 58.35.100
  • libavformat 58.20.100
  • libavutil 56.22.100

wudelu avatar May 21 '20 10:05 wudelu

Which device? Which Android version?

Try with the latest scrcpy version (1.13).

rom1v avatar May 21 '20 11:05 rom1v

I get the same. Using prebuild server 1.13 and scrcpy built in MacPorts: scrcpy 1.13

dependencies:

  • SDL 2.0.12
  • libavcodec 58.65.102
  • libavformat 58.35.101
  • libavutil 56.38.100

Running lldb on scrcpy, it seems that adb push fails for some reason

(lldb) target create "scrcpy"
Current executable set to 'scrcpy' (x86_64).
(lldb) run
Process 25502 launched: '/usr/local/bin/scrcpy' (x86_64)
2020-05-21 22:45:39.568061+0200 scrcpy[25502:253291] INFO: scrcpy 1.13 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 11.1 MB/s (27694 bytes in 0.002s)
2020-05-21 22:45:39.645469+0200 scrcpy[25502:253291] ERROR: "adb push" exited unexpectedly
Process 25502 exited with status = 1 (0x00000001)
(lldb)

Android Debug Bridge version 1.0.41 Version 30.0.1-6435776

Climax777 avatar May 21 '20 20:05 Climax777

adb shell ls -l /data/local/tmp

rom1v avatar May 21 '20 21:05 rom1v

-rw-rw-rw- root     root      4322329 1970-01-01 02:00 apk1590094170308.apk
-rwxr-xr-x root     root        17880 2018-09-11 03:44 getport
-rw-rw-rw- root     root           55 2020-05-18 17:00 mobile_info.properties
drwxrwxrwx shell    shell             2020-05-18 16:49 tc
-rw-rw-rw- root     root            7 1970-01-01 02:00 vysor.pwd

Climax777 avatar May 21 '20 21:05 Climax777

I guess the segfault occurs on the device. Could you adb logcat when it happens?

rom1v avatar May 21 '20 21:05 rom1v

https://pastebin.com/9ANvAMeV

Climax777 avatar May 21 '20 21:05 Climax777

哪个设备?哪个Android版本?

尝试使用最新的scrcpy版本(1.13)。

XIAO MI mix2 Android 9.0 adb log 2020-05-22 08:32:02.985 20079-20079/? E/libc: Access denied finding property "ro.vendor.at_library" 2020-05-22 08:32:03.055 965-2356/? E/OMXNodeInstance: setParameter(0xe89a7284:qcom.encoder.avc, OMX.google.android.index.allocateNativeHandle(0x7f00005d): Output:1 en=0) ERROR: UnsupportedSetting(0x80001019) 2020-05-22 08:32:03.088 965-10879/? E/OMXNodeInstance: getConfig(0xe89a7284:qcom.encoder.avc, ConfigLatency(0x6f800005)) ERROR: UnsupportedIndex(0x8000101a) 2020-05-22 08:32:03.114 965-2356/? E/OMXNodeInstance: getConfig(0xe89a7284:qcom.encoder.avc, ??(0x7f000062)) ERROR: UnsupportedSetting(0x80001019) 2020-05-22 08:32:03.117 965-2356/? E/OMXNodeInstance: getParameter(0xe89a7284:qcom.encoder.avc, ParamConsumerUsageBits(0x6f800004)) ERROR: UnsupportedIndex(0x8000101a) 2020-05-22 08:32:03.120 965-2356/? E/OMXNodeInstance: getParameter(0xe89a7284:qcom.encoder.avc, ParamConsumerUsageBits(0x6f800004)) ERROR: UnsupportedIndex(0x8000101a)

wudelu avatar May 22 '20 00:05 wudelu

@Climax777

Could you please execute these two commands manually (adapt PATH/TO/YOUR/scrcpy_server):

adb push PATH/TO/YOUR/scrcpy-server /data/local/tmp/scrcpy-server.jar
adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.13 0 8000000 0 -1 false - true true 0

rom1v avatar May 24 '20 21:05 rom1v

@rom1v

That seemed to work. Obviously the socket won't connect since there isn't anything listening.

$ adb -t 2 push scrcpy-server-v1.13 /data/local/tmp/scrcpy-server.jar
scrcpy-server-v1.13: 1 file pushed, 0 skipped. 0.1 MB/s (27694 bytes in 0.365s)
$ adb -t 2 shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.13 0 8000000 0 -1 false - true true 0
[server] INFO: Device: alps IH16 (Android 5.1)
[server] ERROR: Exception on thread Thread[main,5,main]
java.io.IOException: Connection refused
	at android.net.LocalSocketImpl.connectLocal(Native Method)
	at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:290)
	at android.net.LocalSocket.connect(LocalSocket.java:130)
	at com.genymobile.scrcpy.DesktopConnection.connect(DesktopConnection.java:40)
	at com.genymobile.scrcpy.DesktopConnection.open(DesktopConnection.java:63)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:22)
	at com.genymobile.scrcpy.Server.main(Server.java:177)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:250)

Climax777 avatar May 24 '20 21:05 Climax777

Hmmm…

Running lldb on scrcpy, it seems that adb push fails for some reason

For some reason, it seems that lldb does not like when scrcpy executes adb: https://github.com/Genymobile/scrcpy/issues/1239#issuecomment-602746588 :confused:

Instead, could you enable ASAN:

meson x -Db_sanitize=address
# or just reconfigure if x already exists: meson configure x -Db_sanitize=address
ninja -Cx
./run x

It should print the stacktrace if the segfault occurs on the computer (not on the device).

rom1v avatar May 24 '20 23:05 rom1v

Ref #726

rom1v avatar May 24 '20 23:05 rom1v

@Climax777 Does it give a stacktrace?

rom1v avatar May 25 '20 18:05 rom1v

2020-05-25 21:41:50.021 scrcpy[1484:16146] INFO: scrcpy 1.13 <https://github.com/Genymobile/scrcpy>
x/server/scrcpy-server: 1 file pushed, 0 skipped. 0.1 MB/s (27694 bytes in 0.357s)
[server] INFO: Device: alps IH16 (Android 5.1)
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1484==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x7fff6f24a70a bp 0x000000000001 sp 0x700002788788 T6)
==1484==The signal is caused by a READ memory access.
==1484==Hint: this fault was caused by a dereference of a high value address (see registers below).  Dissassemble the provided pc to learn which register value was used.
2020-05-25 21:41:51.581 scrcpy[1484:16146] INFO: Renderer: metal
2020-05-25 21:41:51.581 scrcpy[1484:16146] WARN: Trilinear filtering disabled (not an OpenGL renderer)
2020-05-25 21:41:51.587 scrcpy[1484:16146] INFO: Initial texture: 480x800
    #0 0x7fff6f24a709 in dyld_stub_binder (libdyld.dylib:x86_64+0x19709)

==1484==Register values:
rax = 0x0000000000003358  rbx = 0x0000000000000004  rcx = 0x0000000111d3fa50  rdx = 0x0000000000000014
rdi = 0x00000001120ebe10  rsi = 0x0000000000000008  rbp = 0x0000000000000001  rsp = 0x0000700002788788
 r8 = 0x0000000000000001   r9 = 0x0000000000000001  r10 = 0x0000000000000000  r11 = 0x0000000111f4a160
r12 = 0x00007fff6f44c7a4  r13 = 0x0000000111f5a500  r14 = 0x00007000027888b0  r15 = 0x0000700002788850
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (libdyld.dylib:x86_64+0x19709) in dyld_stub_binder
Thread T6 created by T0 here:
    #0 0x110425b8a in wrap_pthread_create (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x3fb8a)
    #1 0x11037b576 in SDL_SYS_CreateThread (libSDL2-2.0.0.dylib:x86_64+0xb8576)
    #2 0x11031643e in SDL_CreateThreadWithStackSize_REAL (libSDL2-2.0.0.dylib:x86_64+0x5343e)
    #3 0x110316561 in SDL_CreateThread_REAL (libSDL2-2.0.0.dylib:x86_64+0x53561)
    #4 0x10fe64cb8 in scrcpy (scrcpy:x86_64+0x100010cb8)
    #5 0x10fe56edf in main (scrcpy:x86_64+0x100002edf)
    #6 0x7fff6f24bcc8 in start (libdyld.dylib:x86_64+0x1acc8)

==1484==ABORTING
./run: line 23:  1484 Abort trap: 6           SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" "$BUILDDIR/app/scrcpy" "$@"

Climax777 avatar May 25 '20 19:05 Climax777

Weird, it seems the problem is not in scrcpy, but in SDL :/

Could you build in debug mode and retry?

meson configure x --buildtype=debug
ninja -Cx
./run x

rom1v avatar May 25 '20 19:05 rom1v

Using prebuild server 1.13 and scrcpy built in MacPorts

Could you build scrcpy "manually" and retry?

rom1v avatar May 25 '20 19:05 rom1v

Do you mean the server?

Climax777 avatar May 25 '20 19:05 Climax777

2020-05-25 21:50:12.350 scrcpy[1942:26342] INFO: scrcpy 1.13 <https://github.com/Genymobile/scrcpy>
2020-05-25 21:50:12.351 scrcpy[1942:26342] DEBUG: Using SCRCPY_SERVER_PATH: x/server/scrcpy-server
x/server/scrcpy-server: 1 file pushed, 0 skipped. 2.5 MB/s (27694 bytes in 0.011s)
[server] INFO: Device: alps IH16 (Android 5.1)
2020-05-25 21:50:13.333 scrcpy[1942:26342] DEBUG: Starting stream thread
2020-05-25 21:50:13.334 scrcpy[1942:26342] DEBUG: Starting controller thread
2020-05-25 21:50:13.334 scrcpy[1942:26342] DEBUG: Starting receiver thread
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1942==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x7fff6f24a70a bp 0x000000000001 sp 0x700004deba18 T5)
==1942==The signal is caused by a READ memory access.
==1942==Hint: this fault was caused by a dereference of a high value address (see registers below).  Dissassemble the provided pc to learn which register value was used.
2020-05-25 21:50:13.365 scrcpy[1942:26342] INFO: Created renderer: metal
2020-05-25 21:50:13.365 scrcpy[1942:26342] INFO: Renderer: metal
2020-05-25 21:50:13.365 scrcpy[1942:26342] WARN: Trilinear filtering disabled (not an OpenGL renderer)
2020-05-25 21:50:13.370 scrcpy[1942:26342] INFO: Initial texture: 480x800
    #0 0x7fff6f24a709 in dyld_stub_binder (libdyld.dylib:x86_64+0x19709)

==1942==Register values:
rax = 0x0000000000003358  rbx = 0x0000000000000004  rcx = 0x000000010e7d3a50  rdx = 0x0000000000000014
rdi = 0x000000010eb7fe10  rsi = 0x0000000000000008  rbp = 0x0000000000000001  rsp = 0x0000700004deba18
 r8 = 0x0000000000000001   r9 = 0x0000000000000001  r10 = 0x0000000000000000  r11 = 0x000000010e9de160
r12 = 0x00007fff6f44c7a4  r13 = 0x000000010e9ee500  r14 = 0x0000700004debb40  r15 = 0x0000700004debae0
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (libdyld.dylib:x86_64+0x19709) in dyld_stub_binder
Thread T5 created by T0 here:
    #0 0x10ceb5b8a in wrap_pthread_create (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x3fb8a)
    #1 0x10ce05576 in SDL_SYS_CreateThread (libSDL2-2.0.0.dylib:x86_64+0xb8576)
    #2 0x10cda043e in SDL_CreateThreadWithStackSize_REAL (libSDL2-2.0.0.dylib:x86_64+0x5343e)
    #3 0x10cda0561 in SDL_CreateThread_REAL (libSDL2-2.0.0.dylib:x86_64+0x53561)
    #4 0x10c8d4f49 in stream_start (scrcpy:x86_64+0x100020f49)
    #5 0x10c8ca48d in scrcpy (scrcpy:x86_64+0x10001648d)
    #6 0x10c8b6b2c in main (scrcpy:x86_64+0x100002b2c)
    #7 0x7fff6f24bcc8 in start (libdyld.dylib:x86_64+0x1acc8)

==1942==ABORTING
./run: line 23:  1942 Abort trap: 6           SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" "$BUILDDIR/app/scrcpy" "$@"

Doesn't seem much different in terms of output.

Climax777 avatar May 25 '20 19:05 Climax777

Do you mean the server?

No, the client. But I'm not sure what "MacPorts" is :)

rom1v avatar May 25 '20 19:05 rom1v

MacPorts is just an alternative to Homebrew. I did build it manually, as per instructions in the README.md.

Climax777 avatar May 25 '20 19:05 Climax777

What macOS version?

rom1v avatar May 26 '20 08:05 rom1v

Catalina, all dependencies up to date according to macports. Adb (android-platform-tools) also from macports.

On Tue, May 26, 2020 at 10:29 AM Romain Vimont [email protected] wrote:

What macOS version?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Genymobile/scrcpy/issues/1414#issuecomment-633885626, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF3XHMF4DXGJKONSXCKWDTRTN4XZANCNFSM4NGXMANA .

Climax777 avatar May 26 '20 10:05 Climax777

I also use Macports (instead of Homebrew) in Catalina and build it manually and not getting any error message. I use the latest version of scrcpy (1.14).

laylamajnun:scrcpy sangprabo$ ninja -Cx
ninja: Entering directory `x'
[12/26] Compiling C object 'app/a172ced@@scrcpy@exe/src_server.c.o'.
../app/src/server.c:204:24: warning: format specifies type 'unsigned short' but the argument has type 'int' [-Wformat]
                 port, port + 1);
                 ~~~~~~^~~~~~~~~
../app/src/util/log.h:16:61: note: expanded from macro 'LOGW'
#define LOGW(...) SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
                                                            ^~~~~~~~~~~
1 warning generated.

prabowomurti avatar May 29 '20 08:05 prabowomurti

You don't build the latest client, this warning has been fixed by 7eb16ce36458011d87972715f08bd9f03ff39807, between v1.12 and v1.13.

You should git pull.

rom1v avatar May 29 '20 08:05 rom1v

For any future readers, just to note that scrcpy is on MacPorts with binaries for 10.12+ (project page):

sudo port install scrcpy

See https://github.com/Genymobile/scrcpy/issues/2256#issuecomment-833440717 for more details, and note that this also sorts out the adb tools for you. MacPorts can be installed from here.

harens avatar May 06 '21 14:05 harens

scrcpy for macOS

Coool avatar Sep 16 '22 22:09 Coool