์๋ ์กด,
๋๋ # 1160์์ ์ธ๊ธ ํ ๋๋ต์ ์ธ ์ปจ๋ณผ ๋ฃจ์ ์ผ๋ก ์คํํ๊ณ ์์๋๋ฐ ์ง์์ ์ธ segfault๋ฅผ ๋ฐ๊ฒฌํ์ง๋ง ushort ์ด๋ฏธ์ง๋ฅผ ์ปจ๋ณผ ๋ฃจ์ ํ ๋๋ง ๋ฐ์ํ์ต๋๋ค. ์ด๋ฏธ์ง์ ํฌ๊ธฐ์ ๋ฐ๋ผ python ๋๋ libvips์์ segfault๊ฐ ๋ฐ์ํ๋๋ก ๋ง๋ค ์ ์์ผ๋ฏ๋ก ์ด๊ฒ์ด ์ด์ค ๋ฌด๋ฃ๋ผ๊ณ ์๊ฐํฉ๋๋ค. ๋ค์์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ ์์น๋ฅผ ํ์ธํ๊ธฐ์ํ ๋ช ๊ฐ์ง ์คํ์ด ํฌํจ ๋ ํ ์คํธ ํ๋ก๊ทธ๋จ์ ๋๋ค. ๊ทธ ์๋๋ libvips.so.42.9.0 ๋ด๋ถ์ segfault ์์น์ ๋ํ ์คํ ์ถ์ ์ ๋๋ค (ํ์ฌ ๋๋ฒ๊น ๋น๋๋ฅผ ์ฌ์ฉํ์ง ์์์ผ๋ฏ๋ก ๋์์ด๋์ง ์์ ์ ์์).
python Python 2.7.15 :: Anaconda custom (64-bit)
์์ pyvips ์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉํ์ฌ vips vips-8.7.0-Sun Jan 28 17:23:05 UTC 2018
์คํ ์ค์
๋๋ค.
๋ฏธ๋ฆฌ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
์ฐธ๊ณ : ์ค์ ๋ก .py ํ์ผ :
segfault.txt
# /usr/bin/env python
import pyvips
slab = pyvips.Image.new_from_array([[1]*10]*10, scale=100) # 10x10 moving average
n = 30000 # also segfaults when n=30000. See note below.
# The following are all fine
uchar_im = pyvips.Image.black(n, n).cast('uchar') # just to be sure it's uchar
uchar_im.conv(slab, precision='approximate', layers=1).write_to_file('uchar_conv.v')
float_im = pyvips.Image.black(n, n).cast('float')
float_im.conv(slab, precision='approximate', layers=1).write_to_file('float_conv.v')
# EVERY CONVOLUTION BELOW THIS LINE SEGFAULTS
# if n=1, completes by writing result to file, then segfaults in python:
# *** Error in `python': free(): invalid pointer: 0x00005651d79154c0 ***
# if n=30000, does not complete and segfaults in libvips
# [1049087.739802] worker[599]: segfault at 7f4cd631a000 ip 00007f4ce7f93318 sp 00007f4cd2caea70 error 4 in libvips.so.42.9.0[7f4ce7eb6000+1f5000]
ushort_im = pyvips.Image.black(n, n).cast('ushort')
ushort_im.conv(slab.cast('ushort'), precision='approximate', layers=1).write_to_file('ushort_conv.v') # segfault happens here
ushort_im = pyvips.Image.black(n, n).cast('ushort')
ushort_im.conv(slab, precision='approximate', layers=1).write_to_file('ushort_conv.v') # segfault would also happen here
short_im = pyvips.Image.black(n, n).cast('short')
short_im.conv(slab, precision='approximate', layers=1).write_to_file('short_conv.v') # segfault would also happen here
n = 30000 ์ผ ๋ ๊ด๋ จ ์คํ ์ถ์ ์ผ ์ ์์ต๋๋ค.
Thread 52 "worker" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe64d5700 (LWP 4069)]
0x00007ffff4ab4c7d in ?? () from /usr/lib/libvips.so.42
(gdb) up
#1 0x00007ffff4b4e411 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#2 0x00007ffff4b4f0c9 in vips_region_fill () from /usr/lib/libvips.so.42
(gdb) up
#3 0x00007ffff4b50d53 in vips_region_prepare () from /usr/lib/libvips.so.42
(gdb) up
#4 0x00007ffff4ab65b3 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#5 0x00007ffff4b4e411 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#6 0x00007ffff4b4f0c9 in vips_region_fill () from /usr/lib/libvips.so.42
(gdb) up
#7 0x00007ffff4b50d53 in vips_region_prepare () from /usr/lib/libvips.so.42
(gdb) up
#8 0x00007ffff4b40d59 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#9 0x00007ffff4b4e411 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#10 0x00007ffff4b4f0c9 in vips_region_fill () from /usr/lib/libvips.so.42
(gdb) up
#11 0x00007ffff4b50d53 in vips_region_prepare () from /usr/lib/libvips.so.42
(gdb) up
#12 0x00007ffff4b40d59 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#13 0x00007ffff4b4e411 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#14 0x00007ffff4b4f0c9 in vips_region_fill () from /usr/lib/libvips.so.42
(gdb) up
#15 0x00007ffff4b50d53 in vips_region_prepare () from /usr/lib/libvips.so.42
(gdb) up
#16 0x00007ffff4b40d59 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#17 0x00007ffff4b4e411 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#18 0x00007ffff4b4f615 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#19 0x00007ffff4b50f5f in vips_region_prepare_to () from /usr/lib/libvips.so.42
(gdb) up
#20 0x00007ffff4b48228 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#21 0x00007ffff4b5171b in ?? () from /usr/lib/libvips.so.42
(gdb) up
#22 0x00007ffff4b51504 in ?? () from /usr/lib/libvips.so.42
(gdb) up
#23 0x00007ffff44e0a8a in g_thread_proxy (data=0x5555559df720) from /opt/anaconda/lib/libglib-2.0.so.0
(gdb) up
#24 0x00007ffff77e36ba in start_thread (arg=0x7fffe64d5700) at pthread_create.c:333
333 pthread_create.c: No such file or directory.
์์ segfault.txt ๋งํฌ๋ github์์ .py ํ์ผ ์ฒจ๋ถ๋ฅผ ํ์ฉํ์ง ์๊ธฐ ๋๋ฌธ์ ์ค์ ๋ก ํ ์คํธ ํ๋ก๊ทธ๋จ์ด์๋ .py ํ์ผ์ ๋๋ค.
์, conva
์ (๋) ์ค์ ๋ก ์ ์ ํ์ง์ด ์๋๋๋ค.
๋๋ ์์ ๐ฑ๐ฟ ๐ท ๋ฌธ์ ๋ฅผํ๊ณ ์์ผ๋ฉฐ์ด ๋ฌธ์ ์ ์ง๋ฉดํ์ต๋๋ค. ๊ฝค ์ค๋ ๋์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ด ์ฌ์ ํ ๊ด๋ จ์ด ์๋์ง ๋ฌป๊ณ ์ถ์์ต๋๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๊น?
์ผ๋ถ ์ค๋๋ ๋ฌธ์ ๋ฅผ ๋ซ์์ผ๋ก์จ ์ด๋ฆฐ ๋ฌธ์ ๋ชฉ๋ก์๋ณด๋ค ๊ด๋ฆฌํ๊ธฐ ์ฌ์ด ์ธํธ๋ก ์ค์ ๋๋ค.
์ด๊ฒ์ ์์ ์ด ํ์ํ ๋ฒ๊ทธ์ด๋ฏ๋ก์ด ๋ฒ๊ทธ๋ ์ด๋ ค ์์ด์ผํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ด๊ฒ์ ์์ ์ด ํ์ํ ๋ฒ๊ทธ์ด๋ฏ๋ก์ด ๋ฒ๊ทธ๋ ์ด๋ ค ์์ด์ผํ๋ค๊ณ ์๊ฐํฉ๋๋ค.