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

Segfault on 16-bit image #9

Closed
Gin-no-kami opened this issue Feb 21, 2023 · 2 comments
Closed

Segfault on 16-bit image #9

Gin-no-kami opened this issue Feb 21, 2023 · 2 comments

Comments

@Gin-no-kami
Copy link

I am consistently getting a segfault (in src/stb_image.h) when trying to run on images with a 16 bit image depth. Below is the simple test script that I use to show the behavior with an example image.
test2

from waifu2x_vulkan import waifu2x_vulkan as waifu2x
sts = waifu2x.init()
sts = waifu2x.initSet(0)
fileIn = "/home/gin/Pictures/test2.png"

f = open(fileIn, "rb")
data = f.read()
f.close()
waifu2x.add(data, waifu2x.MODEL_ANIME_STYLE_ART_RGB_NOISE3, 1, 2)

Since the code segfaults in the cpython library, I ran with gdb to get a backtrace:

Thread 4 "python3" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe76bc6c0 (LWP 21377)]
stbi__convert_16_to_8 (channels=4, h=<optimized out>, w=<optimized out>, orig=0x0) at src/stb_image.h:1140
1140    src/stb_image.h: No such file or directory.
(gdb) bt
#0  stbi__convert_16_to_8 (channels=4, h=<optimized out>, w=<optimized out>, orig=0x0) at src/stb_image.h:1140
#1  stbi_xload (v=...) at src/other_image.h:174
#2  0x00007ffff631863b in to_load (v=...) at src/other_image.h:232
#3  0x00007ffff6318c36 in waifu2x_decode (args=<optimized out>) at src/waifu2x_main.cpp:70
#4  0x00007ffff789ebb5 in ?? () from /usr/lib/libc.so.6
#5  0x00007ffff7920d90 in ?? () from /usr/lib/libc.so.6

The issue appears to be localized to the stbi__convert_16_to_8 function. If I convert the image to 8-bit first (using PIL) then waifu2x does not segfault, leading me to think it's isolated to 16-bit images.

tonquer added a commit that referenced this issue Feb 22, 2023
@tonquer
Copy link
Owner

tonquer commented Feb 22, 2023

I try to fix this problem, please update waifu2x-vulkan

pip3 install --upgrade waifu2x-vulkan -v

@Gin-no-kami
Copy link
Author

I updated to v1.1.6 and tried the test case image again. The issue seems resolved. Thanks for your hard work!

I use waifu2x in a python program that upreses images before they are applied as a wallpaper on my desktop (new wallpaper every 15 seconds). My program kept segfaulting on these 16-bit images. I will close the issue for now, but if something pops up as it runs over more images I will re-open with new debug info.

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

2 participants