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

[Linux] 段错误 #44

Open
Sam0523 opened this issue Jul 3, 2021 · 22 comments · Fixed by #65
Open

[Linux] 段错误 #44

Sam0523 opened this issue Jul 3, 2021 · 22 comments · Fixed by #65

Comments

@Sam0523
Copy link

Sam0523 commented Jul 3, 2021

版本:git master

环境:
OS: openSUSE Tumbleweed x86_64
Kernel: 5.12.12-1-default
DE: GNOME 40.2
Qt 5.15.2

(gdb) r
Starting program: /home/sam/repo/KikoPlay/KikoPlay 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[New Thread 0x7fffe997b640 (LWP 19704)]
[New Thread 0x7fffe3fff640 (LWP 19705)]
[New Thread 0x7fffe37fe640 (LWP 19707)]
[Thread 0x7fffe37fe640 (LWP 19707) exited]
[New Thread 0x7fffe37fe640 (LWP 19708)]
[New Thread 0x7fffe2ecb640 (LWP 19709)]
[Thread 0x7fffe37fe640 (LWP 19708) exited]
[Thread 0x7fffe2ecb640 (LWP 19709) exited]
[New Thread 0x7fffe2ecb640 (LWP 19710)]
[New Thread 0x7fffe37fe640 (LWP 19711)]
[New Thread 0x7fffe259b640 (LWP 19712)]
[New Thread 0x7fffe1d9a640 (LWP 19713)]
[New Thread 0x7fffe1599640 (LWP 19714)]
[New Thread 0x7fffe0d98640 (LWP 19715)]
[Thread 0x7fffe1599640 (LWP 19714) exited]
[Thread 0x7fffe0d98640 (LWP 19715) exited]
[New Thread 0x7fffe0d98640 (LWP 19716)]
[New Thread 0x7fffe1599640 (LWP 19717)]
[Thread 0x7fffe0d98640 (LWP 19716) exited]
[Thread 0x7fffe1599640 (LWP 19717) exited]
[New Thread 0x7fffe1599640 (LWP 19718)]
[New Thread 0x7fffe0d98640 (LWP 19719)]
[New Thread 0x7fffc3fff640 (LWP 19720)]
[New Thread 0x7fffc37fe640 (LWP 19721)]
[New Thread 0x7fffc2ffd640 (LWP 19722)]

Thread 17 "mpv/lua script " received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffc3fff640 (LWP 19720)]
lua_cpcall (L=L@entry=0x7fffc80022a8, func=func@entry=0x7ffff7de93b0 <run_lua>, ud=ud@entry=0x7fffc8000c50) at /usr/src/debug/moonjit-2.2.0-2.8.x86_64/src/lj_api.c:1218
1218	  uint8_t oldh = hook_save(g);

(gdb) bt
#0  lua_cpcall (L=L@entry=0x7fffc80022a8, func=func@entry=0x7ffff7de93b0 <run_lua>, ud=ud@entry=0x7fffc8000c50) at /usr/src/debug/moonjit-2.2.0-2.8.x86_64/src/lj_api.c:1218
#1  0x00007ffff7ded8d0 in load_lua (args=<optimized out>) at ../player/lua.c:451
#2  0x00007ffff7df9344 in run_script (arg=arg@entry=0xa8e4b0) at ../player/scripting.c:91
#3  0x00007ffff7df93c9 in script_thread (p=0xa8e4b0) at ../player/scripting.c:103
#4  0x00007ffff3b61259 in start_thread (arg=0x7fffc3fff640) at pthread_create.c:481
#5  0x00007ffff626a2b3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) i thr
  Id   Target Id                                           Frame 
  1    Thread 0x7fffeba6efc0 (LWP 19653) "KikoPlay"        clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:78
  2    Thread 0x7fffe997b640 (LWP 19704) "QXcbEventQueue"  0x00007ffff625f59f in __GI___poll (fds=0x7fffe997a448, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  3    Thread 0x7fffe3fff640 (LWP 19705) "QDBusConnection" 0x00007ffff625f59f in __GI___poll (fds=0x7fffdc004a30, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  7    Thread 0x7fffe2ecb640 (LWP 19710) "gmain"           0x00007ffff625f59f in __GI___poll (fds=0x96db40, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  8    Thread 0x7fffe37fe640 (LWP 19711) "gdbus"           0x00007ffff625f59f in __GI___poll (fds=0x90b160, nfds=3, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  9    Thread 0x7fffe259b640 (LWP 19712) "pool-KikoPlay"   syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  10   Thread 0x7fffe1d9a640 (LWP 19713) "pool-KikoPlay"   syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  15   Thread 0x7fffe1599640 (LWP 19718) "workThread"      0x00007ffff625f59f in __GI___poll (fds=0x7fffc4004b00, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  16   Thread 0x7fffe0d98640 (LWP 19719) "mpv/mpv core"    0x00007ffff3b6d9da in __futex_abstimed_wait_common64 (futex_word=futex_word@entry=0x9dd990, expected=expected@entry=0, 
    clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0, cancel=cancel@entry=true) at ../sysdeps/nptl/futex-internal.c:74
* 17   Thread 0x7fffc3fff640 (LWP 19720) "mpv/lua script " lua_cpcall (L=L@entry=0x7fffc80022a8, func=func@entry=0x7ffff7de93b0 <run_lua>, ud=ud@entry=0x7fffc8000c50)
    at /usr/src/debug/moonjit-2.2.0-2.8.x86_64/src/lj_api.c:1218
  18   Thread 0x7fffc37fe640 (LWP 19721) "mpv/lua script " lua_cpcall (L=L@entry=0x7fffbc000eb8, func=func@entry=0x7ffff7de93b0 <run_lua>, ud=ud@entry=0x7fffbc000bb0)
    at /usr/src/debug/moonjit-2.2.0-2.8.x86_64/src/lj_api.c:1218
  19   Thread 0x7fffc2ffd640 (LWP 19722) "KikoPlay"        clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:78
(gdb) 
@Protostars
Copy link
Collaborator

从调用栈来看,错误发生在mpv加载lua的过程中,不知道你用的libmpv的信息?

@Sam0523
Copy link
Author

Sam0523 commented Jul 14, 2021

从调用栈来看,错误发生在mpv加载lua的过程中,不知道你用的libmpv的信息?

是 Tumbleweed 官方仓库提供的版本:
0.33.1+git.20210630T163736.f2afae55e9

@Protostars
Copy link
Collaborator

从调用栈来看,错误发生在mpv加载lua的过程中,不知道你用的libmpv的信息?

是 Tumbleweed 官方仓库提供的版本:
0.33.1+git.20210630T163736.f2afae55e9

系统上其他使用libmpv的播放器有没有问题呢?这个我现在也没有条件来复现

@Sam0523
Copy link
Author

Sam0523 commented Jul 21, 2021

从调用栈来看,错误发生在mpv加载lua的过程中,不知道你用的libmpv的信息?

是 Tumbleweed 官方仓库提供的版本:
0.33.1+git.20210630T163736.f2afae55e9

系统上其他使用libmpv的播放器有没有问题呢?这个我现在也没有条件来复现

Celluloid 是正常的。

@MrAru
Copy link

MrAru commented Jan 14, 2022

同样的问题。
环境:ArchLinux, KikoPlay AUR 0.8.1, mpv 0.34.1, lua 5.3.6, luajit 2.0.5

(gdb) r
Starting program: /usr/bin/KikoPlay
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe150b640 (LWP 52319)]
[New Thread 0x7fffdb084640 (LWP 52320)]
[New Thread 0x7fffda178640 (LWP 52321)]
[New Thread 0x7fffd9977640 (LWP 52322)]
[New Thread 0x7fffd9176640 (LWP 52323)]
[New Thread 0x7fffd8975640 (LWP 52324)]
[New Thread 0x7fffcbfff640 (LWP 52325)]

Thread 6 "mpv/lua script " received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd9176640 (LWP 52323)]
0x00007ffff3f717c0 in lua_cpcall () from /usr/lib/libluajit-5.1.so.2
(gdb) bt
#0  0x00007ffff3f717c0 in lua_cpcall () at /usr/lib/libluajit-5.1.so.2
#1  0x00007ffff7e193ad in  () at /usr/lib/libmpv.so.1
#2  0x00007ffff7e25259 in  () at /usr/lib/libmpv.so.1
#3  0x00007ffff7e252df in  () at /usr/lib/libmpv.so.1
#4  0x00007ffff6234259 in start_thread () at /usr/lib/libpthread.so.0
#5  0x00007ffff64a35e3 in clone () at /usr/lib/libc.so.6
(gdb) i thr
  Id   Target Id                                           Frame
  1    Thread 0x7fffe1d74100 (LWP 52315) "KikoPlay"        0x00007ffff64a35d5 in clone ()
   from /usr/lib/libc.so.6
  2    Thread 0x7fffe150b640 (LWP 52319) "QXcbEventQueue"  0x00007ffff6498b2f in poll ()
   from /usr/lib/libc.so.6
  3    Thread 0x7fffdb084640 (LWP 52320) "QDBusConnection" 0x00007ffff6498b2f in poll ()
   from /usr/lib/libc.so.6
  4    Thread 0x7fffda178640 (LWP 52321) "workThread"      0x00007ffff6498b2f in poll ()
   from /usr/lib/libc.so.6
  5    Thread 0x7fffd9977640 (LWP 52322) "mpv/mpv core"    0x00007ffff62408ca in __futex_abstimed_wait_common64 () from /usr/lib/libpthread.so.0
* 6    Thread 0x7fffd9176640 (LWP 52323) "mpv/lua script " 0x00007ffff3f717c0 in lua_cpcall ()
   from /usr/lib/libluajit-5.1.so.2
  7    Thread 0x7fffd8975640 (LWP 52324) "mpv/lua script " 0x00007ffff3f717c0 in lua_cpcall ()
   from /usr/lib/libluajit-5.1.so.2
  8    Thread 0x7fffcbfff640 (LWP 52325) "KikoPlay"        0x00007ffff64a35d5 in clone ()
   from /usr/lib/libc.so.6

@Protostars
Copy link
Collaborator

挺奇怪的,要不试一下编译mpv官方这个例子 https://github.com/mpv-player/mpv-examples/tree/master/libmpv/qt_opengl ,看看可以正常运行吗

@MrAru
Copy link

MrAru commented Jan 14, 2022

挺奇怪的,要不试一下编译mpv官方这个例子 https://github.com/mpv-player/mpv-examples/tree/master/libmpv/qt_opengl ,看看可以正常运行吗

正常运行。

❯ ./qt_opengl
[cplayer] mpv 0.34.1-dirty Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
[cplayer]  built on UNKNOWN
[cplayer] FFmpeg library versions:
[cplayer]    libavutil       56.70.100
[cplayer]    libavcodec      58.134.100
[cplayer]    libavformat     58.76.100
[cplayer]    libswscale      5.9.100
[cplayer]    libavfilter     7.110.100
[cplayer]    libswresample   3.9.100
[cplayer] FFmpeg version: n4.4.1
[cplayer]
[cplayer] Configuration: /usr/bin/waf configure --prefix=/usr --confdir=/etc/mpv --enable-cdda --enable-dvb --enable-dvdnav --enable-libarchive --enable-libmpv-shared --disable-build-date --disable-caca
[cplayer] List of enabled features: alsa asm cdda cplayer cplugins cuda-hwaccel cuda-interop debug-build drm dvbin dvdnav egl egl-drm egl-helpers egl-x11 ffmpeg ffmpeg-aviocontext-bytes-read ffnvcodec gbm gbm.h gl gl-wayland glibc-thread-name glob glob-posix gpl iconv jack javascript jpeg lcms2 libarchive libass libavdevice libbluray libdl libm libmpv-shared libplacebo librt linux-fstatfs linux-input-event-codes lua luajit memfd_create optimize plain-gl posix posix-or-mingw pthreads pulse rubberband shaderc shaderc-shared stdatomic uchardet vaapi vaapi-drm vaapi-egl vaapi-vulkan vaapi-wayland vaapi-x-egl vaapi-x11 vdpau vector vt.h vulkan wayland wayland-protocols x11 xv zimg zlib
[cplayer] Waiting for scripts...
[osd/libass] libass API version: 0x1502000
[osd/libass] libass source: commit: 0.15.2-0-gc967a5a3d9ec0d36af1148b3fdf2f307a21dd122-dirty
[osd/libass] Shaper: FriBidi 1.0.10 (SIMPLE) HarfBuzz-ng 3.2.0 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
[cplayer] Done loading scripts.
[libmpv_render] GL_VERSION='4.6 (Compatibility Profile) Mesa 21.3.4'
[libmpv_render] Detected desktop OpenGL 4.6.
[libmpv_render] GL_VENDOR='Intel'
[libmpv_render] GL_RENDERER='Mesa Intel(R) UHD Graphics 630 (CFL GT2)'
[libmpv_render] GL_SHADING_LANGUAGE_VERSION='4.60'
[libmpv_render] GL_*_swap_control extension missing.
[libmpv_render] Testing FBO format rgba16f
[libmpv_render] Using FBO format rgba16f.
[libmpv_render] No advanced processing required. Enabling dumb mode.
[libmpv_render] Loading hwdec driver 'vaapi-egl'
[libmpv_render/vaapi-egl] VAAPI hwdec only works with OpenGL or Vulkan backends.
[libmpv_render] Loading failed.
[libmpv_render] Loading hwdec driver 'cuda-nvdec'
[libmpv_render/cuda-nvdec] cu->cuInit(0) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
[libmpv_render] Loading failed.
[libmpv_render] Loading hwdec driver 'drmprime-drm'
[libmpv_render/drmprime-drm] Failed to retrieve DRM fd from native display.
[libmpv_render] Loading failed.

@MrAru
Copy link

MrAru commented Jan 14, 2022

https://github.com/KikoPlayProject/KikoPlay/blob/master/Play/Video/mpvplayer.cpp#L113 https://github.com/KikoPlayProject/KikoPlay/blob/master/Play/Video/mpvplayer.cpp#L123 https://github.com/KikoPlayProject/KikoPlay/blob/master/Play/Video/mpvplayer.cpp#L123 https://github.com/KikoPlayProject/KikoPlay/blob/master/Play/Video/mpvplayer.cpp#L100 试着把这几行都注释掉 之后把settings.ini里的Play/ShowPreview 改成false (如果没有找到,就直接把这里https://github.com/KikoPlayProject/KikoPlay/blob/master/Play/Video/mpvplayer.cpp#L149的true改成false),之后重新编译测试看看

你提到的四个链接里事实上只涉及到了三行代码(L100, L113 和 L123)。把这三行注释掉,并将 L149 改为 false 重新编译后运行,仍然报 Segmentation fault. gdb 结果与 #44 (comment) 中完全一致。

@Protostars
Copy link
Collaborator

Protostars commented Jan 14, 2022

系统的mpv有加载什么脚本吗,有条件可否在源码上单步调试一下?

@MrAru
Copy link

MrAru commented Jan 14, 2022

系统的mpv有加载什么脚本吗,有条件可否在源码上单步调试一下?

没有加载脚本。我可以尝试一下单步调试,具体需要在哪几处打断点,或是看哪些变量?

@Protostars
Copy link
Collaborator

可以从MPVPlayer的构造函数开始MPVPlayer::MPVPlayer(QWidget *parent)
还有就是KikoPlay自己也会加载脚本,你可以把script目录下的脚本先删了之后试试

@CHN-beta
Copy link
Contributor

CHN-beta commented Jan 15, 2022

我的环境是gentoo,也有同样的问题。逐步调试后发现是mpv加载youtube-dl的脚本时发生错误。应该是mpv的问题。

一个临时的解决办法是,关掉mpv的lua支持:

# /etc/portage/package.use
media-video/mpv -lua

@hooke007
Copy link
Contributor

hooke007 commented Feb 4, 2022

试试libmpv调用原始的lua@5.1而不是luajit/moonjit

@widsnoy
Copy link

widsnoy commented Feb 5, 2022

试试libmpv调用原始的lua@5.1而不是luajit/moonjit

请问具体怎么操作?

@hooke007
Copy link
Contributor

hooke007 commented Feb 5, 2022

不熟悉linux,只知道libmpv应由lua5.1构建

@CHN-beta
Copy link
Contributor

CHN-beta commented Feb 5, 2022

试试libmpv调用原始的lua@5.1而不是luajit/moonjit

请问具体怎么操作?

如果是用gentoo的话:

# /etc/portage/package.use
media-video/mpv  LUA_SINGLE_TARGET: -luajit lua5-1

但是亲测还会段错误。

@vowstar
Copy link
Contributor

vowstar commented Feb 20, 2022

试试libmpv调用原始的lua@5.1而不是luajit/moonjit

请问具体怎么操作?

如果是用gentoo的话:

# /etc/portage/package.use
media-video/mpv  LUA_SINGLE_TARGET: -luajit lua5-1

但是亲测还会段错误。

我猜测是因为mpv 依赖lua5.1,但是用kikoplay启用后我观测到mpv错误调用了lua5.3的库,API不相容,直接就崩溃了。我不得不把gentoo的kikoplay的依赖里加了mpv[-lua]这样的限制去掉它的lua5.1支持。
关于mpv还有一个讨论,mpv-player/mpv#5205
结论是他们好几年完全没有升级lua版本的计划。现在我们得想办法让kikoplay用着lua5.3的同时,还得让libmpv正确使用lua5.1的链接库才能不崩溃

@Protostars
Copy link
Collaborator

试试libmpv调用原始的lua@5.1而不是luajit/moonjit

请问具体怎么操作?

如果是用gentoo的话:

# /etc/portage/package.use
media-video/mpv  LUA_SINGLE_TARGET: -luajit lua5-1

但是亲测还会段错误。

我猜测是因为mpv 依赖lua5.1,但是用kikoplay启用后我观测到mpv错误调用了lua5.3的库,API不相容,直接就崩溃了。我不得不把gentoo的kikoplay的依赖里加了mpv[-lua]这样的限制去掉它的lua5.1支持。 关于mpv还有一个讨论,mpv-player/mpv#5205 结论是他们好几年完全没有升级lua版本的计划。现在我们得想办法让kikoplay用着lua5.3的同时,还得让libmpv正确使用lua5.1的链接库才能不崩溃

linux上libmpv能不能静态链接lua 5.1

@vowstar
Copy link
Contributor

vowstar commented Feb 21, 2022

试试libmpv调用原始的lua@5.1而不是luajit/moonjit

请问具体怎么操作?

如果是用gentoo的话:

# /etc/portage/package.use
media-video/mpv  LUA_SINGLE_TARGET: -luajit lua5-1

但是亲测还会段错误。

我猜测是因为mpv 依赖lua5.1,但是用kikoplay启用后我观测到mpv错误调用了lua5.3的库,API不相容,直接就崩溃了。我不得不把gentoo的kikoplay的依赖里加了mpv[-lua]这样的限制去掉它的lua5.1支持。 关于mpv还有一个讨论,mpv-player/mpv#5205 结论是他们好几年完全没有升级lua版本的计划。现在我们得想办法让kikoplay用着lua5.3的同时,还得让libmpv正确使用lua5.1的链接库才能不崩溃

linux上libmpv能不能静态链接lua 5.1

可以是可以,但是这些Linux发行版的维护者那边不容易沟通,估计写了后不让提交package进去会被打回来,他们的哲学是linux要尽可能的复用所有的so文件,会让我们正面解决这个问题。现在workaround是直接禁用了mpv本身的lua依赖,后面看再想想办法怎样让libmpv load liblua5.1.so的同时让kikoplay可以load liblua5.3.so然后再load libmpv.so

@vowstar
Copy link
Contributor

vowstar commented Feb 21, 2022

我分析错了,现在看起来是mpv的问题很大

Thread 9 "mpv/lua script " received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd9ffb640 (LWP 1721858)]
0x00007ffff646bdc6 in ?? () from /usr/lib64/liblua5.1.so.0
(gdb) bt
#0  0x00007ffff646bdc6 in  () at /usr/lib64/liblua5.1.so.0
#1  0x00007ffff6472a9b in  () at /usr/lib64/liblua5.1.so.0
#2  0x00007ffff6473919 in  () at /usr/lib64/liblua5.1.so.0
#3  0x00007ffff646ee17 in lua_cpcall () at /usr/lib64/liblua5.1.so.0
#4  0x00007ffff7e31c95 in  () at /usr/lib64/libmpv.so.1
#5  0x00007ffff7e3bc24 in  () at /usr/lib64/libmpv.so.1
#6  0x00007ffff7e3c0a9 in  () at /usr/lib64/libmpv.so.1
#7  0x00007ffff651e387 in  () at /lib64/libc.so.6
#8  0x00007ffff65a01ac in  () at /lib64/libc.so.6

@vowstar
Copy link
Contributor

vowstar commented Feb 21, 2022

Thread 9 "mpv/lua script " received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd9ffb640 (LWP 1830055)]
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in  ()
#1  0x00007ffff461280b in  () at /usr/lib64/libluajit-5.1.so.2
#2  0x00007ffff46161dc in  () at /usr/lib64/libluajit-5.1.so.2
#3  0x00007ffff4620c39 in  () at /usr/lib64/libluajit-5.1.so.2
#4  0x00007ffff460ee2c in  () at /usr/lib64/libluajit-5.1.so.2
#5  0x00007ffff46233ed in lua_cpcall () at /usr/lib64/libluajit-5.1.so.2
#6  0x00007ffff7e31c95 in  () at /usr/lib64/libmpv.so.1
#7  0x00007ffff7e3bc24 in  () at /usr/lib64/libmpv.so.1
#8  0x00007ffff7e3c0a9 in  () at /usr/lib64/libmpv.so.1
#9  0x00007ffff651e387 in  () at /lib64/libc.so.6
#10 0x00007ffff65a01ac in  () at /lib64/libc.so.6

现在证实了无论是luajit还是lua5.1支持的libmpv都会崩溃,去掉lua支持的libmpv是正常的,看样子真的是lua5.1和lua5.3符号冲突问题,可见静态链接说不定是最快的解决方法了。
我用mpv官方的QT example直接链接lua5.3也能复现这个问题

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

Successfully merging a pull request may close this issue.

7 participants