sekrit-twc / zimg

Scaling, colorspace conversion, and dithering library
Do What The F*ck You Want To Public License
405 stars 77 forks source link

Crashes due to incorrectly identified avx2 feature #176

Closed Zapeth closed 2 years ago

Zapeth commented 2 years ago

When the library code is called, the application (mpv) crashes on my CPU with SIGILL in zimg::depth::left_shift_b2w_avx2.

https://github.com/sekrit-twc/zimg/pull/174 would fix this, but it was closed without comment.

sekrit-twc commented 2 years ago

Where is this CPU.

Zapeth commented 2 years ago

I don't see how this is relevant to the issue, as quoted in the linked discussion, the Intel instruction manual clearly says

If a value entered for CPUID.EAX is higher than the maximum input value for basic or extended function for that processor then the data for the highest basic information leaf is returned.

This is what happens in your code, meaning any CPU that doesn't support a higher feature level than requested (eax=7 in this case) returns data that might lead to an incorrectly identified feature set.

If you don't want to implement a trivial fix, then feel free to close this issue. I already spent a disproportional amount of time on this to fix it on my end, so I'm not going to bother with more interactions here.

sekrit-twc commented 2 years ago

If you don't want to contribute, that is on you, not me.