libsdl-org / SDL_image

Image decoding for many popular formats for Simple Directmedia Layer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WebP loading segfaults when built with 32 bit MSVC

Starbuck5 opened this issue · comments

Hello,

I normally use the prebuilt binaries provided on releases, which have been great, but I was hoping to customize my SDL_image build (for pygame-ce distribution w/ libpng and libjpeg rather than stbimage).

How I compiled:
Visual Studio 2022
Built SDL from the SDL2 branch in a sibling directory as the Visual Studio project include paths expect
Built SDL_image from the SDL2 branch with no changes in Visual Studio
Tested using the showimage program

Results:
x64: Works great
Win32: showimage program can load other formats, but segfaults intermittently (75% of the time) on webp

I also tested the 32 bit prebuilt from the 2.8.0 release, which did not have this problem.

I tested several images from this page https://developers.google.com/speed/webp/gallery1 to make sure this wasn't isolated to a specific image.

I tried to debug further by putting printfs into IMG_Webp, and these modified builds actually started working when tested in pygame-ce (they still didn't work in showimage, because printf can't be used in an all SDL environment because it doesn't have the library?)

I made sure WebP reports successfully initialization using IMG_Init, and I tried to fix it also by turning off optimizations on IMG_LoadWebp_RW using #pragma optimize( "", off ).

I would like to get this resolved but I'm all out of debugging ideas, I'd appreciate any help from here. Thanks.

Assuming that you are using the webp dlls provided in the 2.8.0 release distribution:
Does the attached new build of webp dlls work? webp-dlls.zip

I was using the ones in VisualC/external/optional, which I think are the same as the 2.8.0 release distribution.

OMG THOSE WORK!! 🙏

OMG THOSE WORK!! 🙏

The attached new rebuild of dlls work: Can you confirm?

Yes, sorry for the imprecise language.

Tested the attached DLLs from webp-dlls.zip (x86) with my build of SDL_image, and WEBP loading is now successful 100% of the time.

OK, thanks for the confirmation!

Fixed in the SDL2 branch as of f7c1e9b

Cherry-picked to release-2.8.x bd8728e

Closing as fixed.

Thanks for such a quick fix!

What did you change in the webp builds?

Nothing in the source, only a different toolchain. (Don't know why, but the old builds seem to had been made using an old compiler toolchain -- I had possibly forgotten updating them.)

@slouken: This warrants a patch release?

P.S.: I will update our libavif from 1.0.2 to 1.0.3 today or tomorrow in SDL2 and SDL3. Should I do that in release branch too?

@slouken: This warrants a patch release?

P.S.: I will update our libavif from 1.0.2 to 1.0.3 today or tomorrow in SDL2 and SDL3. Should I do that in release branch too?

Yes, go for it. I have a fix for PNG loading that I want to get in as well, so we'll probably do a 2.8.1 release in a couple weeks.