rust-ffmpeg-sys icon indicating copy to clipboard operation
rust-ffmpeg-sys copied to clipboard

Overly aggressive compilation paramters can produce IllegalInstruction seg fault

Open SeanEClarke opened this issue 7 months ago • 0 comments

We have encountered some instances where we build a Rust application that uses rust-ffmpeg-sys and on certain hosts it fails to initialise on startup and seg faults with an illegal instruction error. Doing some digging, we think that when compiled in our CI platform, the compiler switches setting the architecture to be native and tuning option to be native means it uses aggressive/extended instructions such as AVX-512 which aren't available on all processes.

To be clear, all the systems are x64, and not archaic, however it may be the CI is on the latest generation Intel's and some of our deployment hosts may well be slightly older AMD (which were slower to adopt some extended instruction sets)

We can't see a way to work around this - surprisingly, even without release optimisation ( -O3 ) i.e. debug builds, it still appears to cause problems, again we assume because of the additional extended instructions.

This line of code sets the arch and tuning flags and appears to be select if you are not cross compiling: https://github.com/zmwangx/rust-ffmpeg-sys/blob/master/build.rs#L333

Is this a genuine issue or do we need to set some addition environment variables to make the builds more generic x64.

(note: I have used AVX-512 as an example, we haven't examined the binary at that micro level - just looking at examples of IllegalInstruction seg faults and why it would work on certain hosts and not others)

SeanEClarke avatar Jul 14 '25 09:07 SeanEClarke