macOS Catalina 10.15.1环境下编译的ffmpeg无法运行,启动就崩溃

我在一台macOS Catalina 10.15.1的机器上,源码编译ffmpeg,生成的ffmpeg和ffprobe等所有可执行程序都无法正常运行。一运行就报段错误崩溃。就像这样:

1
2
$./ffmpeg
[1] 13651 segmentation fault ./ffmpeg

即使是./configure时不加任何参数也不行。

这已经是我第无数次被这个macOS 10.15新版本系统坑了。。

在这个帖子的末尾,提供了解决方案,在./configure加上--extra-cflags="-fno-stack-check"即可,帖子的原文内容如下:

It seems the 10.15 toolchain turns on “-fstack-check” by default for Clang, like some Linux distributions do. You can see that here:

Stack checking is on by default on all platforms to prevent memory corruptions. (25859140)

Some discussion here traces it back to AVX, although turning off AVX (“–disable-avx”) didn’t seem to help building FFMPEG. (Nor, as skyzyx saw above, did turning off ASM entirely.)

Accordingly, adding “-fno-stack-check” to “CFLAGS” - f.ex., by ‘–extra-cflags=”-fno-stack-check”‘ when configuring works around the problem and builds a functioning FFMPEG.

Don’t quite know what that means for us. I imagine having stack checking on is desirable, but there’s at least a workaround while the source is further investigated.

另外帖子中也有关于用lldb调试ffmpeg,对应的崩溃信息,大家如果遇到同样的问题,也可以调起来确定下是不是这个原因引起的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ lldb $(which ffmpeg)
(lldb) target create "/usr/local/bin/ffmpeg"
Current executable set to '/usr/local/bin/ffmpeg' (x86_64).
(lldb) run
Process 95311 launched: '/usr/local/bin/ffmpeg' (x86_64)
Process 95311 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x00007fff6e08c366 libdyld.dylib`stack_not_16_byte_aligned_error
libdyld.dylib`stack_not_16_byte_aligned_error:
-> 0x7fff6e08c366 <+0>: movdqa %xmm0, (%rsp)
0x7fff6e08c36b <+5>: int3
0x7fff6e08c36c <+6>: nop
0x7fff6e08c36d <+7>: nop
Target 0: (ffmpeg) stopped.
(lldb) run --help
There is a running process, kill it and restart?: [Y/n] y
Process 95311 exited with status = 9 (0x00000009)
Process 95317 launched: '/usr/local/bin/ffmpeg' (x86_64)
Process 95317 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x00007fff6e08c366 libdyld.dylib`stack_not_16_byte_aligned_error
libdyld.dylib`stack_not_16_byte_aligned_error:
-> 0x7fff6e08c366 <+0>: movdqa %xmm0, (%rsp)
0x7fff6e08c36b <+5>: int3
0x7fff6e08c36c <+6>: nop
0x7fff6e08c36d <+7>: nop
Target 0: (ffmpeg) stopped.

本文完,作者yoko,尊重劳动人民成果,转载请注明原文出处: https://pengrl.com/p/20042/

0%