Comments (24)
Thank you for your report.
Leaks come from other libs (dbus and nvidia driver).
For the segfault, I will investigate. Please post the full result of scrcpy --version
.
from scrcpy.
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.30.0 / 2.30.3
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
- libusb: - / 1.0.27
from scrcpy.
How was your ffmpeg compiled?
It seems you compiled scrcpy against an old version but linked a newer version. It should be perfectly ok, but It is surprising, since you're building manually.
I can't understand/reproduce your segfault.
Could you try on dev
branch? Also, I prepared a minor change that impacts the line where you segfaults: icon_decoder
. Could you please test this branch?
from scrcpy.
It seems you compiled scrcpy against an old version but linked a newer version. It should be perfectly ok,
Oh, no, it is not perfectly ok since they have a different major number, they are not ABI compatible:
FFmpeg guarantees backward API and ABI compatibility for each library as long as its major version number is unchanged.
You get other similar errors related to this incompatibility:
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
from scrcpy.
How was your ffmpeg compiled?
The ffmpeg binary is from package ffmpeg 2:6.1.1-7 from the manjaro extra repository
You can see the PKGBUILD here:
https://gitlab.archlinux.org/archlinux/packaging/packages/ffmpeg/-/blob/169a765abd4a55ae622dbcc3f7051b15c472a65d/PKGBUILD
It seems you compiled scrcpy against an old version but linked a newer version.
How can you tell ?
from scrcpy.
It seems you compiled scrcpy against an old version but linked a newer version.
How can you tell ?
Dependencies (compiled / linked):
[…]
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
[…]
You must recompile scrcpy (against your current ffmpeg libraries).
from scrcpy.
I prepared a minor change that impacts the line where you segfaults:
icon_decoder
. Could you please test this branch?
$ git fetch origin icon_decoder
$ git checkout icon_decoder
$ ./install_release.sh
...
Found ninja-1.12.1 at /usr/bin/ninja
[33/69] Compiling C object app/scrcpy.p/src_icon.c.o
FAILED: app/scrcpy.p/src_icon.c.o
ccache cc -Iapp/scrcpy.p -Iapp -I../app -I../app/src -I/usr/include/SDL2 -I/usr/include/libusb-1.0 -flto=auto -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=c11 -O3 -Wmissing-prototypes -D_REENTRANT -MD -MQ app/scrcpy.p/src_icon.c.o -MF app/scrcpy.p/src_icon.c.o.d -o app/scrcpy.p/src_icon.c.o -c ../app/src/icon.c
../app/src/icon.c: In function ‘decode_image’:
../app/src/icon.c:84:62: error: passing argument 5 of ‘av_find_best_stream’ from incompatible pointer type [-Wincompatible-pointer-types]
84 | av_find_best_stream(ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);
| ^~~~~~
| |
| const AVCodec **
In file included from ../app/src/icon.h:8,
from ../app/src/icon.c:1:
/usr/local/include/libavformat/avformat.h:2281:35: note: expected ‘AVCodec **’ but argument is of type ‘const AVCodec **’
2281 | AVCodec **decoder_ret,
| ~~~~~~~~~~^~~~~~~~~~~
[50/69] Compiling C object app/scrcpy.p/src_scrcpy.c.o
ninja: build stopped: subcommand failed.
from scrcpy.
Could you try on
dev
branch?
$ git checkout dev
$ ./install_release.sh
...
$ /usr/local/bin/scrcpy -V debug
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO: --> (usb) XXX device SM_G970F
DEBUG: Device serial: XXX
DEBUG: Using server: /usr/local/share/scrcpy/scrcpy-server
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 135.7 MB/s (69007 bytes in 0.000s)
[server] INFO: Device: [samsung] samsung SM-G970F (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 550.54.14
INFO: Trilinear filtering enabled
DEBUG: Using icon: /usr/local/share/icons/hicolor/256x256/apps/scrcpy.png
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Display: using SurfaceControl API
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[1] 448189 segmentation fault (core dumped) /usr/local/bin/scrcpy -V debug
[server] DEBUG: Audio encoder stopped
[server] DEBUG: Screen streaming stopped
from scrcpy.
/usr/local/include/libavformat/avformat.h:2281:35: note: expected ‘AVCodec **’ but argument is of type ‘const AVCodec **’
2281 | AVCodec **decoder_ret,
| ~~~~~~~~~~^~~~~~~~~~~
Please test with this additional change:
diff --git a/app/src/icon.c b/app/src/icon.c
index 52537d2ba..0dddefa3c 100644
--- a/app/src/icon.c
+++ b/app/src/icon.c
@@ -78,7 +78,16 @@ decode_image(const char *path) {
goto close_input;
}
+
+// In ffmpeg/doc/APIchanges:
+// 2021-04-27 - 46dac8cf3d - lavf 59.0.100 - avformat.h
+// av_find_best_stream now uses a const AVCodec ** parameter
+// for the returned decoder.
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 0, 100)
const AVCodec *codec;
+#else
+ AVCodec *codec;
+#endif
int stream =
av_find_best_stream(ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);
If it build for you, I'll merge it into dev
.
$ git checkout dev
$ ./install_release.sh
Note: in theory, the prebuilt server is only built for each release, so the client on dev
branch might be incompatible with the prebuilt server. But in any case, it should NEVER segfault.
[1] 448189 segmentation fault (core dumped) /usr/local/bin/scrcpy -V debug
What is the result of /usr/local/bin/scrcpy -v
?
from scrcpy.
You must recompile scrcpy (against your current ffmpeg libraries).
isn't that what ./install_release.sh supposed to do ? I'm getting the same compiled/linked discrepancies after it
from scrcpy.
isn't that what ./install_release.sh supposed to do ?
Yes.
I'm getting the same compiled/linked discrepancies after it
So with the same compiled and link dependencies, you still get the segfault? I could not reproduce.
Please retry in debug and with ASAN enabled:
diff --git a/install_release.sh b/install_release.sh
index 0be5675c6..478297702 100755
--- a/install_release.sh
+++ b/install_release.sh
@@ -12,7 +12,7 @@ echo "$PREBUILT_SERVER_SHA256 scrcpy-server" | sha256sum --check
echo "[scrcpy] Building client..."
rm -rf "$BUILDDIR"
-meson setup "$BUILDDIR" --buildtype=release --strip -Db_lto=true \
+meson setup "$BUILDDIR" --buildtype=debug -Db_sanitize=address \
-Dprebuilt_server=scrcpy-server
cd "$BUILDDIR"
ninja
from scrcpy.
If it build for you
on icon_decoder it builds but after patching I get:
$ d_ic/app/scrcpy -V debug
...
DEBUG: Using icon: /usr/local/share/icons/hicolor/256x256/apps/scrcpy.png
AddressSanitizer:DEADLYSIGNAL
=================================================================
==491268==ERROR: AddressSanitizer: SEGV on unknown address 0x000200000004 (pc 0x7f4b4de064ef bp 0x7ffed0dd9e30 sp 0x7ffed0dd9cd0 T0)
==491268==The signal is caused by a READ memory access.
#0 0x7f4b4de064ef in avcodec_parameters_to_context (/usr/lib/libavcodec.so.60+0x2064ef) (BuildId: 6062be614616d2aaa7b103b2fd6bcf17aa07e92d)
#1 0x55d6e5c1eafe in decode_image ../app/src/icon.c:107
#2 0x55d6e5c1f0eb in load_from_path ../app/src/icon.c:198
#3 0x55d6e5c1fa6d in scrcpy_icon_load ../app/src/icon.c:286
#4 0x55d6e5c3ca06 in sc_screen_init ../app/src/screen.c:449
#5 0x55d6e5c38d4c in scrcpy ../app/src/scrcpy.c:743
#6 0x55d6e5bff5c7 in main_scrcpy ../app/src/main.c:88
#7 0x55d6e5bff6eb in main ../app/src/main.c:107
#8 0x7f4b4c676ccf (/usr/lib/libc.so.6+0x29ccf) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#9 0x7f4b4c676d89 in __libc_start_main (/usr/lib/libc.so.6+0x29d89) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#10 0x55d6e5bff024 in _start (/mnt/d/GitHub/scrcpy/d_ic/app/scrcpy+0x2c024) (BuildId: 929ae4336a7de23d01a90ae593bdbb736612a0da)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/libavcodec.so.60+0x2064ef) (BuildId: 6062be614616d2aaa7b103b2fd6bcf17aa07e92d) in avcodec_parameters_to_context
==491268==ABORTING
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Display: using SurfaceControl API
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[server] DEBUG: Audio encoder stopped
[server] DEBUG: Screen streaming stopped
from scrcpy.
on icon_decoder it builds
👍
The fact that you need this patch suggests that you're building for an old version (otherwise you'll get the new API).
What is the result of scrcpy -v
with your new build?
from scrcpy.
What is the result of
scrcpy -v
with your new build?
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.30.3 / 2.30.3
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
- libusb: - / 1.0.27
from scrcpy.
OK so you build against an old ffmpeg and run against a newer one:
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
from scrcpy.
So with the same compiled and link dependencies, you still get the segfault? I could not reproduce.
Please retry in debug and with ASAN enabled:
same error in both master & dev branches.
from scrcpy.
OK so you build against an old ffmpeg and run against a newer one:
That's weird because I only have one ffmpeg binary installed
from scrcpy.
pkg-config --print-provides libavformat
from scrcpy.
pkg-config --print-provides libavformat
libavformat = 60.16.100
from scrcpy.
That's the new version (so it's correct).
If you create a builddir, what is the full output:
meson setup tmpbuilddir
from scrcpy.
$ meson setup tmpbuilddir
The Meson build system
Version: 1.4.0
Source dir: /mnt/d/GitHub/scrcpy
Build dir: /mnt/d/GitHub/scrcpy/tmpbuilddir
Build type: native build
Project name: scrcpy
Project version: 2.4
C compiler for the host machine: ccache cc (gcc 14.1.1 "cc (GCC) 14.1.1 20240507")
C linker for the host machine: cc ld.bfd 2.42.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 2.1.1
Run-time dependency libavformat found: YES 60.16.100
Run-time dependency libavcodec found: YES 60.31.102
Run-time dependency libavutil found: YES 58.29.100
Run-time dependency libswresample found: YES 4.12.100
Run-time dependency sdl2 found: YES 2.30.3
Run-time dependency libavdevice found: YES 60.3.100
Run-time dependency libusb-1.0 found: YES 1.0.27
Checking for function "strdup" : YES
Checking for function "asprintf" : YES
Checking for function "vasprintf" : YES
Checking for function "nrand48" : YES
Checking for function "jrand48" : YES
Checking for function "reallocarray" : YES
Header "sys/socket.h" has symbol "SOCK_CLOEXEC" : YES
Configuring config.h using configuration
Program ./scripts/build-wrapper.sh found: YES (/mnt/d/GitHub/scrcpy/server/./scripts/build-wrapper.sh)
Build targets in project: 13
Found ninja-1.12.1 at /usr/bin/ninja
from scrcpy.
Run-time dependency libavformat found: YES 60.16.100
Run-time dependency libavcodec found: YES 60.31.102
Run-time dependency libavutil found: YES 58.29.100
Run-time dependency libswresample found: YES 4.12.100
Run-time dependency sdl2 found: YES 2.30.3
Run-time dependency libavdevice found: YES 60.3.100
Run-time dependency libusb-1.0 found: YES 1.0.27
OK, that looks correct, so now if you build, you'll get the correct version:
ninja -Ctmpbuilddir
./run tmpbuilddir -v
./run tmpbuilddir
from scrcpy.
$ ./run tmpbuilddir -v
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.30.3 / 2.30.3
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
- libusb: - / 1.0.27
Same issue:
$ SCRCPY_ICON_PATH="dev/null" tmpbuilddir/app/scrcpy -V debug
...
ERROR: [FFmpeg] Value -510806320 for parameter 'in_sample_fmt' out of sample format range [-1 - 11]
ERROR: [FFmpeg] Requested input sample format -1 is invalid
...
from scrcpy.
Found pkg-config: YES (/usr/bin/pkg-config) 2.1.1 Run-time dependency libavformat found: YES 60.16.100 Run-time dependency libavcodec found: YES 60.31.102 Run-time dependency libavutil found: YES 58.29.100 Run-time dependency libswresample found: YES 4.12.100 Run-time dependency sdl2 found: YES 2.30.3 Run-time dependency libavdevice found: YES 60.3.100 Run-time dependency libusb-1.0 found: YES 1.0.27
$ ./run tmpbuilddir -v scrcpy 2.4 <https://github.com/Genymobile/scrcpy> Dependencies (compiled / linked): - SDL: 2.30.3 / 2.30.3 - libavcodec: 58.125.101 / 60.31.102 - libavformat: 58.68.100 / 60.16.100 - libavutil: 56.66.100 / 58.29.100 - libavdevice: 58.12.100 / 60.3.100 - libusb: - / 1.0.27
WTF!?
Meson correctly detects libavformat 60.16.100
, but LIBAVFORMAT_VERSION_MAJOR
is 58
and LIBAVFORMAT_VERSION_MINOR
is 68
🤔
Lines 32 to 39 in c27ab46
IMO there is something wrong with your ffmpeg headers or pkg-config.
Look at the version numbers in all your version_major.h
files:
fd version_major.h /usr
What is the value of LIBAVFORMAT_VERSION_MAJOR
in which directory? Do you have ffmpeg headers both in /usr and /usr/local?
from scrcpy.
Related Issues (20)
- Cannot pass left alt to device due to cursor being ungrabbed HOT 1
- windows PC keyboard to scrcpy connect Android HOT 3
- Usb debugging HOT 1
- Macbook Pro m3pro, mac crashs HOT 2
- Copy-paste broken on Honor Magic5 with Android 14 (getPrimaryClip NoSuchMethodException) HOT 8
- Android10 cannot cast screen HOT 1
- [Question] Bricked Screen (Never had Developer options enabled) HOT 2
- Mac Self Contained packages like windows
- 小米14链接出现问题,无法从电脑操作手机 HOT 3
- Video stream is disconnected HOT 1
- Unable to connect due to active rejection from the target computer。 (10061) HOT 1
- Could not find any ADB device HOT 1
- Couldn't get it to work - until I switched USB ports
- sincronização de fps HOT 5
- https://github.com/Genymobile/scrcpy/issues/1319 HOT 1
- Problem with my honor pad 9 HOT 3
- Blue 'overlay' when using scrcpy HOT 2
- PC screen skipping FPS but fps monitor in cmd shows 58-60 fps consistent HOT 6
- [BUG] Scrcpy is conflicted with Windows Sandbox
- Schließt sich nach 5 sekunden
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scrcpy.