ruby-vips: Ruby script crashes on Windows when using hist_find

Hi, I am having an issue with ruby-vips on windows. When I run some_image.hist_find it seems like ruby crashes. I condensed my problem down to the following script which reliably crashes each time for me:

require 'vips'

img = Vips::Image.new_from_file('test.jpg', access: :sequential)
puts('Loaded image')
img.hist_find
puts('Ran hist_find')

start_time = Time.now
while true
    puts "Elapsed: #{ Time.now - start_time} seconds"
end

The output is:

Loaded image
Ran hist_find
Elapsed: 0.0 seconds
[omitted]
Elapsed: 0.5107214 seconds
Elapsed: 0.5107635 seconds
Elapsed: 0.5108055 seconds
Elapsed: 0.5108474 seconds
[crash]

The expected behavior would be that the for loop runs forever, but after around 0.5 seconds it just stops without any other output and $? returns false. I initially used a tiff image but the problem persists also if I use jpeg or other image formats. Also very small and very large images do not make a difference. Removing access: :sequential from new_from_file in order to use the default VIPS_ACCESS_RANDOM method also still makes it crash. The problem only occurs if I run hist_find. When leaving out img.hist_find it runs fine.

This problem only occurs on Windows. On Linux it runs fine.

My setup: Windows 10 ruby-vips 2.1.4 ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x64-mingw32]

To install ruby-vips I put

gem 'ruby-vips', '~> 2.0', '>= 2.0.7', :require => false

in my Gemfile and ran

bundler install

Can someone reproduce this? What could be the problem here? Thank you very much!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (11 by maintainers)

Most upvoted comments

Great! I wonder what the issue is? There were no bugs fixed around histograms, so I suppose it must be a general build issue in that package. Anyway, hopefully it’ll be resolved soon.

Okay it’s working now. I used pacman -Ql mingw-w64-x86_64-libvips from within msys2.exe and it showed me where the files are installed.

$ pacman -Ql mingw-w64-x86_64-libvips
mingw-w64-x86_64-libvips /mingw64/
mingw-w64-x86_64-libvips /mingw64/bin/
mingw-w64-x86_64-libvips /mingw64/bin/batch_crop
mingw-w64-x86_64-libvips /mingw64/bin/batch_image_convert
mingw-w64-x86_64-libvips /mingw64/bin/batch_rubber_sheet
mingw-w64-x86_64-libvips /mingw64/bin/libvips-42.dll
mingw-w64-x86_64-libvips /mingw64/bin/libvips-cpp-42.dll
mingw-w64-x86_64-libvips /mingw64/bin/light_correct
...
$ cd /mingw64/
$ pwd -W
C:/Ruby27-x64/msys64/mingw64

So I created a backup of C:/Ruby27-x64/msys64/mingw64 and copied the v8.12.2-build2 files into there and I get the new version and the code is working fine like you stated before.

ruby-vips version = 2.1.4
libvips version = 8.12.2-Tue Jan 25 09:34:32 UTC 2022

At least the workaround is working now and I hope the pacman package can be updated soon. Thanks for your help!