Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"zsh: illegal hardware instruction scrcpy" #1239

Open
BartmanEH opened this issue Mar 23, 2020 · 22 comments
Open

"zsh: illegal hardware instruction scrcpy" #1239

BartmanEH opened this issue Mar 23, 2020 · 22 comments

Comments

@BartmanEH
Copy link

BartmanEH commented Mar 23, 2020

relatively fresh Catalina install with fresh Homebrew and scrcpy install is throwing the following error:

bin % scrcpy
2020-03-23 11:18:15.448 scrcpy[715:16382] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
* daemon not running; starting now at tcp:5037
* daemon started successfully
/usr/local/Cellar/scrcpy/1.12.1/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 4.5 MB/s (26202 bytes in 0.006s)
2020-03-23 11:18:16.302 scrcpy[715:16382] INFO: Initial texture: 1080x2160
zsh: illegal hardware instruction  scrcpy
@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

It seems the binary you're running uses CPU instructions not supported by your CPU :/

It should work if you build it from your computer directly: https://github.com/Genymobile/scrcpy/blob/master/BUILD.md

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

Unless you trigger some undefined behavior :/

If you can build it in debug and reproduce, I'm interested.

@BartmanEH
Copy link
Author

BartmanEH commented Mar 23, 2020

do I need to build the server? [edit] and to install Android SDK, do I need to download and install the whole Android IDE?

[edit2] this problem seems to be related to Catalina as I had run older versions of scrcpy on this same iMac when it was running High Sierra.

Anyway, I'm trying to build it and the server now.

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

do I need to build the server? [edit] and to install Android SDK

No: https://github.com/Genymobile/scrcpy/blob/master/BUILD.md#prebuilt-server

@BartmanEH
Copy link
Author

BartmanEH commented Mar 23, 2020

I am in way over my head:

scrcpy % meson x --buildtype release --strip -Db_lto=true \
    -Dprebuilt_server=/Users/[edit]/scrcpy/server-prebuilt/scrcpy-server-v1.12.1
Directory already configured.

results in:

No Java runtime present, requesting install.
FAILED: server/scrcpy-server

now I'm trying to figure out how to install JDK...

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

Directory already configured.

Your meson command did nothing, because x already existed.

Either use meson configure x … or just rm -rf x and retry.

@BartmanEH
Copy link
Author

BartmanEH commented Mar 23, 2020

meson configure x didn't work but rm -rf x did but I'm still getting:

scrcpy % scrcpy
2020-03-23 12:55:57.701 scrcpy[4002:81574] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 1.5 MB/s (26202 bytes in 0.017s)
2020-03-23 12:55:59.200 scrcpy[4002:81574] INFO: Initial texture: 1080x2160
zsh: illegal hardware instruction  scrcpy

how do I know I'm using the compiled version as opposed to the brew version?

[edit] I guess because it's running server out of .../share/... instead of .../Cellar/...?

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

Once you meson x …, you must build with ninja -Cx.

Then, to run, execute:

./run x

@BartmanEH
Copy link
Author

BartmanEH commented Mar 23, 2020

everytime it aborts it leaves a copy s̶c̶r̶c̶p̶y̶ adb running which I need to manually kill or else I get a could not listen error. Anyway, after doing that:

scrcpy % ./run x                            
2020-03-23 13:04:10.014 scrcpy[4081:85814] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
x/server/scrcpy-server: 1 file pushed, 0 skipped. 4.4 MB/s (26202 bytes in 0.006s)
2020-03-23 13:04:10.715 scrcpy[4081:85814] INFO: Initial texture: 1080x2160
./run: line 23:  4081 Illegal instruction: 4  SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" "$BUILDDIR/app/scrcpy" "$@"

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

I need to manually kill or else I get a could not listen error.

Use the dev branch instead of master, it will try another port automatically.

Illegal instruction: 4

OK, great, so you reproduce with your own build 👍

Now, build in debug mode and run with gdb:

meson d -Dprebuilt_server=/Users/[edit]/scrcpy/server-prebuilt/scrcpy-server-v1.12.1
ninja -Cd
export SCRCPY_SERVER_PATH=d/server/scrcpy-server
gdb d/app/scrcpy

In the gdb prompt, type r then Enter.

When it crashes, type bt then Enter.

@BartmanEH
Copy link
Author

I got so close:

scrcpy % gdb d/app/scrcpy
zsh: command not found: gdb

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

lldb instead of gdb?

@BartmanEH
Copy link
Author

BartmanEH commented Mar 23, 2020

justs sits there not crashing:

scrcpy % lldb d/app/scrcpy 
(lldb) target create "d/app/scrcpy"
Current executable set to 'd/app/scrcpy' (x86_64).
(lldb) 

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

in the gdb lldb prompt, type r then Enter.

When it crashes, type bt then Enter.

@BartmanEH
Copy link
Author

scrcpy % lldb d/app/scrcpy 
(lldb) target create "d/app/scrcpy"
Current executable set to 'd/app/scrcpy' (x86_64).
(lldb) r
Process 4500 launched: '/Users/bastian.stassen/scrcpy/d/app/scrcpy' (x86_64)
2020-03-23 13:31:14.010180-0400 scrcpy[4500:103850] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
2020-03-23 13:31:14.015343-0400 scrcpy[4500:103850] DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 2.1 MB/s (26202 bytes in 0.012s)
2020-03-23 13:31:14.076369-0400 scrcpy[4500:103850] ERROR: "adb push" exited unexpectedly
Process 4500 exited with status = 1 (0x00000001) 
(lldb) bt
error: invalid thread
(lldb) 

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

ERROR: "adb push" exited unexpectedly

Before debugging, it must at least work "normally":

d/app/scrcpy

(without lldb)

@BartmanEH
Copy link
Author

bastian.stassen@Bastians-iMac scrcpy % d/app/scrcpy                       
2020-03-23 13:34:56.413 scrcpy[4550:106277] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
2020-03-23 13:34:56.413 scrcpy[4550:106277] DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 3.3 MB/s (26202 bytes in 0.008s)
2020-03-23 13:34:57.017 scrcpy[4550:106277] DEBUG: Starting stream thread
2020-03-23 13:34:57.017 scrcpy[4550:106277] DEBUG: Starting controller thread
2020-03-23 13:34:57.019 scrcpy[4550:106277] DEBUG: Starting receiver thread
2020-03-23 13:34:57.046 scrcpy[4550:106277] DEBUG: Failed to obtain Metal device
2020-03-23 13:34:57.117 scrcpy[4550:106277] INFO: OpenGL shaders: ENABLED
2020-03-23 13:34:57.118 scrcpy[4550:106277] INFO: Created renderer: opengl
2020-03-23 13:34:57.122 scrcpy[4550:106277] INFO: Initial texture: 1080x2160
zsh: illegal hardware instruction  d/app/scrcpy
bastian.stassen@Bastians-iMac scrcpy % ps aux | grep scrcpy | grep -v grep
bastian.stassen   4553   0.0  0.0  4282912   1552 s000  S     1:34pm   0:00.01 adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.12.1 0 8000000 0 false - true true
bastian.stassen@Bastians-iMac scrcpy % kill 4553                          
bastian.stassen@Bastians-iMac scrcpy % d/app/scrcpy                       
2020-03-23 13:35:32.477 scrcpy[4562:107040] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
2020-03-23 13:35:32.478 scrcpy[4562:107040] DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 5.3 MB/s (26202 bytes in 0.005s)
2020-03-23 13:35:33.105 scrcpy[4562:107040] DEBUG: Starting stream thread
2020-03-23 13:35:33.106 scrcpy[4562:107040] DEBUG: Starting controller thread
2020-03-23 13:35:33.106 scrcpy[4562:107040] DEBUG: Starting receiver thread
2020-03-23 13:35:33.136 scrcpy[4562:107040] DEBUG: Failed to obtain Metal device
2020-03-23 13:35:33.202 scrcpy[4562:107040] INFO: OpenGL shaders: ENABLED
2020-03-23 13:35:33.202 scrcpy[4562:107040] INFO: Created renderer: opengl
2020-03-23 13:35:33.208 scrcpy[4562:107040] INFO: Initial texture: 1080x2160
zsh: illegal hardware instruction  d/app/scrcpy
bastian.stassen@Bastians-iMac scrcpy % ps aux | grep scrcpy | grep -v grep
bastian.stassen   4565   0.0  0.0  4274720   1540 s000  S     1:35pm   0:00.01 adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.12.1 0 8000000 0 false - true true
bastian.stassen@Bastians-iMac scrcpy % kill 4565                          
bastian.stassen@Bastians-iMac scrcpy % lldb d/app/scrcpy                  
(lldb) target create "d/app/scrcpy"
Current executable set to 'd/app/scrcpy' (x86_64).
(lldb) r
Process 4576 launched: '/Users/bastian.stassen/scrcpy/d/app/scrcpy' (x86_64)
2020-03-23 13:36:01.588087-0400 scrcpy[4576:107691] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
2020-03-23 13:36:01.588715-0400 scrcpy[4576:107691] DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 4.8 MB/s (26202 bytes in 0.005s)
2020-03-23 13:36:01.653303-0400 scrcpy[4576:107691] ERROR: "adb push" exited unexpectedly
Process 4576 exited with status = 1 (0x00000001) 
(lldb) quit
bastian.stassen@Bastians-iMac scrcpy % 

@BartmanEH
Copy link
Author

I am running Catalina on (technically) unsupported Mac. See the message about Failed to obtain Metal device? That might be the clue. Something in the toolchain you're using is not compatible with my patched Catalina install :-(

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2020

But I don't understand why you get ERROR: "adb push" exited unexpectedly only while debugging.

@BartmanEH
Copy link
Author

should I get gdb running instead of lldb?

@BartmanEH
Copy link
Author

BartmanEH commented Apr 6, 2020

I'm trying to build the dev branch but getting this error:

[24/25] Linking target app/scrcpy.
FAILED: server/scrcpy-server 
/Users/bastian.stassen/scrcpy-dev/scrcpy/server/./scripts/build-wrapper.sh /Users/bastian.stassen/scrcpy-dev/scrcpy/server server/scrcpy-server release
ninja: build stopped: subcommand failed.

same when I build the release version of the main branch:

FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 58s
[25/26] Linking target app/scrcpy.
FAILED: server/scrcpy-server 
/Users/bastian.stassen/scrcpy/server/./scripts/build-wrapper.sh /Users/bastian.stassen/scrcpy/server server/scrcpy-server release
ninja: build stopped: subcommand failed.

[edit] uninstalling JDK14 and installing JDK8 in the hopes that building will work...and I'm getting further:

bastian.stassen@Bastians-iMac scrcpy % rm -rf d
bastian.stassen@Bastians-iMac scrcpy % meson d -Dprebuilt_server=/Users/bastian.stassen/scrcpy/server-prebuilt/scrcpy-server-v1.12.1
The Meson build system
Version: 0.53.2
Source dir: /Users/bastian.stassen/scrcpy
Build dir: /Users/bastian.stassen/scrcpy/d
Build type: native build
Project name: scrcpy
Project version: 1.12.1
C compiler for the host machine: cc (clang 11.0.3 "Apple clang version 11.0.3 (clang-1103.0.32.29)")
C linker for the host machine: cc ld64 556.5
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/local/bin/pkg-config (0.29.2)
Run-time dependency libavformat found: YES 58.29.100
Run-time dependency libavcodec found: YES 58.54.100
Run-time dependency libavutil found: YES 56.31.100
Run-time dependency sdl2 found: YES 2.0.12
Configuring config.h using configuration
Build targets in project: 10

Found ninja-1.10.0 at /usr/local/bin/ninja
bastian.stassen@Bastians-iMac scrcpy % ninja -Cd
ninja: Entering directory `d'
[24/46] Compiling C object 'app/a172ced@@scrcpy@exe/src_sys_unix_command.c.o'.
In file included from ../app/src/sys/unix/command.c:21:
In file included from ../app/src/util/log.h:4:
In file included from /usr/local/include/SDL2/SDL_log.h:40:
/usr/local/include/SDL2/SDL_stdinc.h:426:5: warning: implicit declaration of function 'memset_pattern4' is invalid in C99 [-Wimplicit-function-declaration]
    memset_pattern4(dst, &val, dwords * 4);
    ^
1 warning generated.
[46/46] Linking target app/test_strutil.
bastian.stassen@Bastians-iMac scrcpy % export SCRCPY_SERVER_PATH=d/server/scrcpy-server
bastian.stassen@Bastians-iMac scrcpy % lldb d/app/scrcpy 
(lldb) target create "d/app/scrcpy"
Current executable set to '/Users/bastian.stassen/scrcpy/d/app/scrcpy' (x86_64).
(lldb) r
Process 1812 launched: '/Users/bastian.stassen/scrcpy/d/app/scrcpy' (x86_64)
2020-04-06 15:07:29.497590-0400 scrcpy[1812:6015687] INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
2020-04-06 15:07:29.498556-0400 scrcpy[1812:6015687] DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 1.7 MB/s (26202 bytes in 0.015s)
2020-04-06 15:07:29.547046-0400 scrcpy[1812:6015687] ERROR: "adb push" exited unexpectedly
Process 1812 exited with status = 1 (0x00000001) 
(lldb) 

ugh, still erroring out in debug mode with adb push

@BartmanEH
Copy link
Author

I just did a brew upgrade scrcpy to install v1.13 and it's working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants