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

WebP loading segfaults when built with 32 bit MSVC #403

Closed
Starbuck5 opened this issue Dec 10, 2023 · 9 comments
Closed

WebP loading segfaults when built with 32 bit MSVC #403

Starbuck5 opened this issue Dec 10, 2023 · 9 comments

Comments

@Starbuck5
Copy link
Contributor

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.

@sezero
Copy link
Contributor

sezero commented Dec 10, 2023

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

@Starbuck5
Copy link
Contributor Author

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!! 🙏

@sezero
Copy link
Contributor

sezero commented Dec 10, 2023

OMG THOSE WORK!! 🙏

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

@Starbuck5
Copy link
Contributor Author

Starbuck5 commented Dec 10, 2023

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.

sezero added a commit that referenced this issue Dec 10, 2023
sezero added a commit that referenced this issue Dec 10, 2023
@sezero
Copy link
Contributor

sezero commented Dec 10, 2023

OK, thanks for the confirmation!

Fixed in the SDL2 branch as of f7c1e9b

Cherry-picked to release-2.8.x bd8728e

Closing as fixed.

@sezero sezero closed this as completed Dec 10, 2023
@Starbuck5
Copy link
Contributor Author

Thanks for such a quick fix!

What did you change in the webp builds?

@sezero
Copy link
Contributor

sezero commented Dec 10, 2023

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.)

Starbuck5 pushed a commit to pygame-community/SDL_image that referenced this issue Dec 10, 2023
@sezero
Copy link
Contributor

sezero commented Dec 10, 2023

@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
Copy link
Collaborator

slouken commented Dec 10, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants