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

ffmpeg 7.1_4 segfault during transcode with x265 4.1 #202612

Open
4 tasks done
gajjanag opened this issue Dec 28, 2024 · 24 comments
Open
4 tasks done

ffmpeg 7.1_4 segfault during transcode with x265 4.1 #202612

gajjanag opened this issue Dec 28, 2024 · 24 comments
Labels
bug Reproducible Homebrew/homebrew-core bug

Comments

@gajjanag
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

gajjanag@Ganeshs-Mac-mini ~ % brew config
HOMEBREW_VERSION: 4.4.13
ORIGIN: https://github.com/Homebrew/brew
HEAD: 6ea9df68df4868ce12ea7c51c85b57dce514f2e8
Last commit: 5 days ago
Branch: stable
Core tap JSON: 28 Dec 04:10 UTC
Core cask tap JSON: 28 Dec 04:10 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: 10-core 64-bit arm_donan
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.2-arm64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.2
Rosetta 2: false

gajjanag@Ganeshs-Mac-mini ~ % brew doctor
Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Running my usual multimedia transcodes, via

ffmpeg -i foo.webm -c:v libx265 bar.mkv

They worked fine with x265 4.0_1 and ffmpeg 7.1_3 but stopped working today after a brew upgrade, segfaulting instead.

What happened (include all command output)?

zsh: segmentation fault ffmpeg -i foo.webm -c:v libx265 bar.mkv

What did you expect to happen?

Successful transcode

Step-by-step reproduction instructions (by running brew commands)

brew upgrade (and check that ffmpeg, x265 are at latest 7.1_4, 4.1 respectively) followed by sample transcode command reproduces the issue on my M4 Mac Mini, MacOS Sequoia 15.2.

Manually downgrading to x265 4.0_1 and ffmpeg 7.1_3 resolved the issue.
@gajjanag gajjanag added the bug Reproducible Homebrew/homebrew-core bug label Dec 28, 2024
@samuelhe52
Copy link

Seeing the same thing here.

bash-3.2$ ffmpeg -i input.mp4 -c:v libx265 -c:a copy out.mkv
# output:
...
Segmentation fault: 11

@carlocab
Copy link
Member

Can you try attaching ffmpeg to a debugger to get a backtrace?

@samuelhe52
Copy link

samuelhe52 commented Dec 28, 2024

I'm not super familiar with lldb, but I've managed to get this:

Process 24333 stopped
* thread #11, name = 'enc0:0:libx265', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001016c619c libavcodec.61.dylib`___lldb_unnamed_symbol7225 + 452
libavcodec.61.dylib`___lldb_unnamed_symbol7225:
->  0x1016c619c <+452>: ldr    q0, [x23]
    0x1016c61a0 <+456>: stur   q0, [x22, #0x8]
    0x1016c61a4 <+460>: ldr    w8, [x23, #0x54]
    0x1016c61a8 <+464>: sub    w8, w8, #0x1
Target 0: (ffmpeg) stopped.
(lldb) bt
* thread #11, name = 'enc0:0:libx265', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001016c619c libavcodec.61.dylib`___lldb_unnamed_symbol7225 + 452
    frame #1: 0x0000000101554bdc libavcodec.61.dylib`___lldb_unnamed_symbol4509 + 44
    frame #2: 0x0000000101555064 libavcodec.61.dylib`___lldb_unnamed_symbol4510 + 344
    frame #3: 0x0000000101554ec0 libavcodec.61.dylib`avcodec_send_frame + 388
    frame #4: 0x000000010001d064 ffmpeg`___lldb_unnamed_symbol658 + 1036
    frame #5: 0x000000010001cab0 ffmpeg`encoder_thread + 260
    frame #6: 0x0000000100030ef8 ffmpeg`___lldb_unnamed_symbol769 + 52
    frame #7: 0x00000001808082e4 libsystem_pthread.dylib`_pthread_start + 136

Hope this will be helpful.

@gajjanag
Copy link
Author

One possibility is that the ffmpeg brew formula did not get rebuilt with the newer x265; I have seen this issue on and off with the Arch Linux package management where maintainer forgets to do this.

@davehahn99
Copy link

davehahn99 commented Dec 28, 2024

I'm experiencing the same issue with libx265 encoding after doing a 'brew update && brew upgrade' today.

Question - you said "Manually downgrading to x265 4.0_1 and ffmpeg 7.1_3 resolved the issue" - how do you easily do that? Is there an easy way to downgrade ffmpeg and x265?

I tried using brew install https://github.com/Homebrew/homebrew-core/blob/c1fc61315283f9f0f87ef538aa21329eef57f37e/Formula/f/ffmpeg.rb but it didn't work. I then tried to curl -O "https://github.com/Homebrew/homebrew-core/blob/c1fc61315283f9f0f87ef538aa21329eef57f37e/Formula/f/ffmpeg.rb" and install locally with brew install ./ffmpeg but that didn't work for me either.

@gajjanag
Copy link
Author

I'm experiencing the same issue with libx265 encoding after doing a 'brew update && brew upgrade' today.

Question - you said "Manually downgrading to x265 4.0_1 and ffmpeg 7.1_3 resolved the issue" - how do you easily do that? Is there an easy way to downgrade ffmpeg and x265?

I tried using brew install https://github.com/Homebrew/homebrew-core/blob/c1fc61315283f9f0f87ef538aa21329eef57f37e/Formula/f/ffmpeg.rb but it didn't work. I then tried to curl -O "https://github.com/Homebrew/homebrew-core/blob/c1fc61315283f9f0f87ef538aa21329eef57f37e/Formula/f/ffmpeg.rb" and install locally with brew install ./ffmpeg but that didn't work for me either.

I think you have to do a downgrade of both

curl -o x265.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/23067ae1b9e93e35f321a6ba6f89a14ac8822247/Formula/x/x265.rb

curl -o ffmpeg.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/c1fc61315283f9f0f87ef538aa21329eef57f37e/Formula/f/ffmpeg.rb

brew unlink ffmpeg
brew unlink x265
brew install ffmpeg.rb
brew install x265.rb

@gromgit
Copy link
Member

gromgit commented Dec 29, 2024

Just did a couple of quick tests before my busy Sunday starts, and I can confirm that:

  1. the failure is cross-platform (Linux segfaults too), and
  2. the problem seems to be in x265 4.1, as downgrading just that formula to 4.0.1 makes everything work even with the latest ffmpeg bottle.

Smells like an upstream x265 bug to me.

@cho-m
Copy link
Member

cho-m commented Dec 29, 2024

See if locally building #202680 helps which backports FFmpeg/FFmpeg@099f88b

@gromgit
Copy link
Member

gromgit commented Dec 29, 2024

Just did a quick rebuild, and HEVC encoding seems to work again. Thanks much, @cho-m!

@qupig
Copy link

qupig commented Dec 29, 2024

@cho-m There is no bump revision, so I guess users already stuck with the issue won't receive the fix?

@carlocab
Copy link
Member

You can do

brew update && brew reinstall ffmpeg

to pick up the fix.

@gromgit
Copy link
Member

gromgit commented Dec 29, 2024

Something went wrong with the PR, the bottle stanza was not updated.

@carlocab
Copy link
Member

Yep, my mistake. New bottles dispatched: https://github.com/Homebrew/homebrew-core/actions/runs/12535995059

@carlocab
Copy link
Member

Should be fixed by #202717

@gromgit
Copy link
Member

gromgit commented Dec 29, 2024

Yup, brew reinstall ffmpeg now pulls in new bottles which actually work. Thanks much, @carlocab!

@qupig
Copy link

qupig commented Dec 29, 2024

You can do

brew update && brew reinstall ffmpeg

to pick up the fix.

@carlocab Thank you. And yes I know this I could reinstall.

But is this expected?
Every user who encounters the problem should read this issue and reinstall manually?
Instead of simply updating to a new revision?

Please note that I'm not talking about myself, but probably thousands of brew users.

I'm just asking about the expected repair process and how it works.

Anyway, thanks everyone for the work and quick fix. ❤️

@gajjanag
Copy link
Author

Confirmed it works for me as well, thanks all!

@vmachiel

This comment was marked as off-topic.

@gromgit

This comment was marked as off-topic.

@vmachiel

This comment was marked as off-topic.

@gromgit

This comment was marked as off-topic.

@vmachiel

This comment was marked as off-topic.

@carlocab
Copy link
Member

carlocab commented Jan 2, 2025

I did build ffmpeg to be able to use the libfdk_aac lib by doing:

brew tap homebrew-ffmpeg/ffmpeg brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-fdk-aac

could that be an issue?

Yes. That installs a formula from the homebrew-ffmpeg tap, not this one. Please report issues with that formula there and not here (because we cannot fix problems with code in that repository here).

@vmachiel
Copy link

vmachiel commented Jan 2, 2025

Ok thanks, I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/homebrew-core bug
Projects
None yet
Development

No branches or pull requests

8 participants