Skip to content

Segfault on 16-bit image #9

@Gin-no-kami

Description

@Gin-no-kami

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions