ruby-vips
ruby-vips copied to clipboard
Got segfault while playing with `.conv`
require "vips"
mask = Array.new(10){ |i| Array.new(10){ |j| 1 / Math::hypot(i-4.5, j-4.5) } }
hm = Vips::Image.new_from_file("PlayerSpawnsHeatMap.png").extract_band(0)
hm.conv(mask, precision: :integer).to_a.flatten.sort.uniq
p hm.cast(:int).conv(mask, precision: :approximate).to_a.flatten.sort.uniq
p hm.cast(:int).conv(mask, precision: :approximate).to_a.flatten.sort.uniq
$ bundle exec ruby bug.rb
/Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:695: [BUG] Segmentation fault at 0x00007fc2b47f8010
ruby 2.4.9p362 (2019-10-02 revision 67824) [x86_64-darwin18]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0006 p:---- s:0032 e:000031 CFUNC :vips_image_write_to_memory
c:0005 p:0033 s:0026 e:000025 METHOD /Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:695
c:0004 p:0066 s:0020 e:000019 METHOD /Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:1211
c:0003 p:0008 s:0013 e:000012 METHOD /Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:1224
c:0002 p:0092 s:0009 E:0010f0 EVAL bug.rb:5 [FINISH]
c:0001 p:0000 s:0003 E:001c90 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
bug.rb:5:in `<main>'
/Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:1224:in `to_a'
/Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:1211:in `to_enum'
/Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:695:in `write_to_memory'
/Users/nakilon/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:695:in `vips_image_write_to_memory'
-- Machine register context ------------------------------------------------
rax: 0x0000000000000000 rbx: 0x0000000000000004 rcx: 0x0000000000000700
rdx: 0x00007fc2b5e20af0 rdi: 0x00007fc2b5ed8f00 rsi: 0x0000000000000000
rbp: 0x000070000eb59b00 rsp: 0x000070000eb59a60 r8: 0x000000000000007e
r9: 0x0000000000000080 r10: 0x00007fc2b47f6410 r11: 0x00007fc2b476ec10
r12: 0x000000000000000c r13: 0x00007fc2b7e7b000 r14: 0x00007fc2b5e210e0
r15: 0x00007fc2b7e83d4c rip: 0x000000010dc0f072 rfl: 0x0000000000010202
-- C level backtrace information -------------------------------------------
0 libruby.2.4.9.dylib 0x000000010d6ff158 rb_vm_bugreport + 136
1 libruby.2.4.9.dylib 0x000000010d5885b3 rb_bug_context + 467
2 libruby.2.4.9.dylib 0x000000010d674288 sigsegv + 72
3 libsystem_platform.dylib 0x00007fff20410d7d _sigtramp + 29
4 libvips.42.dylib 0x000000010dc0f072 vips_conva_vgenerate + 3702
5 libvips.42.dylib 0x000000010dcb1a92 vips_region_generate + 74
6 libvips.42.dylib 0x000000010dcad56a vips_region_fill + 62
7 libvips.42.dylib 0x000000010dcb19fe vips_region_prepare + 154
8 libvips.42.dylib 0x000000010dc9f6cf vips_image_write_gen + 31
9 libvips.42.dylib 0x000000010dcb1a92 vips_region_generate + 74
10 libvips.42.dylib 0x000000010dcad56a vips_region_fill + 62
11 libvips.42.dylib 0x000000010dcb19fe vips_region_prepare + 154
12 libvips.42.dylib 0x000000010dc9f6cf vips_image_write_gen + 31
13 libvips.42.dylib 0x000000010dcb1a92 vips_region_generate + 74
14 libvips.42.dylib 0x000000010dcad56a vips_region_fill + 62
15 libvips.42.dylib 0x000000010dcb19fe vips_region_prepare + 154
16 libvips.42.dylib 0x000000010dc9f6cf vips_image_write_gen + 31
17 libvips.42.dylib 0x000000010dcb1a92 vips_region_generate + 74
18 libvips.42.dylib 0x000000010dcb1d87 vips_region_prepare_to_generate + 110
19 libvips.42.dylib 0x000000010dcb1cc6 vips_region_prepare_to + 499
20 libvips.42.dylib 0x000000010dca7216 sink_memory_area_work_fn + 41
21 libvips.42.dylib 0x000000010dcb2d70 vips_task_run + 326
22 libvips.42.dylib 0x000000010dcb29fc vips_thread_main_loop + 58
23 libglib-2.0.0.dylib 0x000000010d9db6b3 g_thread_pool_thread_proxy + 163
24 libglib-2.0.0.dylib 0x000000010d9da472 g_thread_proxy + 66
25 libsystem_pthread.dylib 0x00007fff203cb8fc _pthread_start + 224
-- Other runtime information -----------------------------------------------
* Loaded script: bug.rb
...
Is this a bug or a free RAM issue? How do I know?
When using precision: :integer there is no segfault:
[0, 255, 510, 765, 1020, 1275, 1530, 1785, 2040, 2295, 2550, 2805, 3060]
[0, 255, 510, 765, 1020, 1275, 1530, 1785, 2040, 2295, 2550, 2805, 3060]
image: https://drive.google.com/file/d/1TlRKhZdWZpbKIEXTj4sOxV5HkdjDou40/view
$ ruby -v
ruby 2.4.9p362 (2019-10-02 revision 67824) [x86_64-darwin18]
$ vips -v
vips-8.11.3-Wed Aug 11 09:29:27 UTC 2021
$ bundle exec gem list ruby-vips
ruby-vips (2.1.4)