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

Crash on macOS arm64 #51

Closed
joeyparrish opened this issue Oct 30, 2024 · 3 comments · Fixed by #54
Closed

Crash on macOS arm64 #51

joeyparrish opened this issue Oct 30, 2024 · 3 comments · Fixed by #54
Assignees
Labels
CPU: arm64 Issues affecting arm64 builds platform: macOS Issues affecting macOS priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@joeyparrish
Copy link
Member

macOS arm64 builds of FFmpeg are currently crashing on GitHub VMs when testing Shaka Streamer.

@joeyparrish joeyparrish added type: bug Something isn't working correctly priority: P1 Big impact or workaround impractical; resolve before feature release platform: macOS Issues affecting macOS CPU: arm64 Issues affecting arm64 builds labels Oct 30, 2024
@joeyparrish joeyparrish self-assigned this Oct 30, 2024
@joeyparrish joeyparrish changed the title Crash on macOS arm64. Crash on macOS arm64 Oct 30, 2024
@github-actions github-actions bot added this to the Backlog milestone Oct 30, 2024
@joeyparrish
Copy link
Member Author

FFmpeg gives no indication of what it is doing when it crashes, even with -loglevel trace. Not sure if it's an encoder or decoder issue, or something else. My gut says videotoolbox is to blame.

Letting Rosetta handle the x64 binaries on arm64 seems to work seamlessly.

There are no debug symbols in the builds we shipped, so lldb tells me nothing.

I'm debugging the macOS arm64 builds on my fork.

I will try the binaries directly on the machine that built them to see if there is some difference between the GitHub VM and my actual M1 device.

Then I will try a debug build and lldb to see if we can get a meaningful backtrace.

Finally, if nothing else works, I'll experiment with removing --enable-videotoolbox (not a solution, but may provide a clue) and with adding -fno-stack-check, which is used explicitly in the ffmpeg builds at https://www.osxexperts.net/ .

@joeyparrish
Copy link
Member Author

Builds made on the GitHub VM crash on the system that built them.

A debug build (-g -O0) also crashes.

lldb shows this when it crashes:

* thread #5, name = 'av:h264:df3', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100498454 ffmpeg`ff_h264_idct_add16intra_neon + 40
ffmpeg`ff_h264_idct_add16intra_neon:
->  0x100498454 <+40>: ldrb   w3, [x7], #0x1
    0x100498458 <+44>: ldrsw  x0, [x5], #0x4
    0x10049845c <+48>: ldrb   w3, [x4, w3, uxtw]
    0x100498460 <+52>: add    x0, x0, x6
Target 0: (ffmpeg) stopped.

Configuring with --disable-neon failed to build.

@joeyparrish
Copy link
Member Author

The M1 mac in the lab couldn't build ffmpeg at all with these instructions. The error was about "illegal text relocations" in some assembly functions for aarch64. I'm not sure why this is different from the build environment of the GitHub VMs.

I couldn't quite solve this, until I found a reference to --enable-pic being required for iOS builds. Since position independent code (PIC) is related to relocation (that's my very surface level understanding), I tried configuring with --enable-pic, and that got the lab machine to build ffmpeg. The resulting build did not crash on the same machine.

I'm trying --enable-pic now on the GitHub VMs to see if this helps fix the crash.

joeyparrish added a commit to joeyparrish/static-ffmpeg-binaries that referenced this issue Nov 10, 2024
Enabling position independent code (PIC) resolves a crash in macOS arm64 builds.  The idea to try this came from a relocation-related build failure on another machine, followed by me stubmling across a note that iOS requires PIC.

Closes shaka-project#51
joeyparrish added a commit to shaka-project/shaka-streamer that referenced this issue Nov 10, 2024
Closes #197
Could have prevented #194

For a test run with macOS arm64 enabled, showing how this would have
caught #194, see
https://github.com/joeyparrish/shaka-streamer/actions/runs/11762714145/job/32765885894

Once shaka-project/static-ffmpeg-binaries#51
is closed, and we have new builds in the binary package, we can
re-enable macOS arm64 testing for #179.
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jan 9, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CPU: arm64 Issues affecting arm64 builds platform: macOS Issues affecting macOS priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant