{"action":"created","issue":{"url":"https://api.github.com/repos/jcupitt/libvips/issues/322","labels_url":"https://api.github.com/repos/jcupitt/libvips/issues/322/labels{/name}","comments_url":"https://api.github.com/repos/jcupitt/libvips/issues/322/comments","events_url":"https://api.github.com/repos/jcupitt/libvips/issues/322/events","html_url":"https://github.com/jcupitt/libvips/issues/322","id":100949316,"number":322,"title":"Ruby vips8 read then write image files loop crashes after n images","user":{"login":"PaulHowson","id":11267299,"avatar_url":"https://avatars.githubusercontent.com/u/11267299?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulHowson","html_url":"https://github.com/PaulHowson","followers_url":"https://api.github.com/users/PaulHowson/followers","following_url":"https://api.github.com/users/PaulHowson/following{/other_user}","gists_url":"https://api.github.com/users/PaulHowson/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulHowson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulHowson/subscriptions","organizations_url":"https://api.github.com/users/PaulHowson/orgs","repos_url":"https://api.github.com/users/PaulHowson/repos","events_url":"https://api.github.com/users/PaulHowson/events{/privacy}","received_events_url":"https://api.github.com/users/PaulHowson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jcupitt/libvips/labels/bug","name":"bug","color":"e10c02"},{"url":"https://api.github.com/repos/jcupitt/libvips/labels/in%20development","name":"in development","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-08-14T07:01:54Z","updated_at":"2015-08-28T09:25:12Z","closed_at":null,"body":"Hi John,\r\n\r\nI have run into what seems to be a bug in vips8 or the Ruby interface to it.\r\n\r\nI am processing large numbers of 2K tif video images: 2048 x 1556 pixels. For each image: Image file gets read. Modified in some way. Modified image file gets written to a new file.\r\n\r\nThis was working OK with ruby-vips (vips7). I changed over to vips8 and the gir_ffi-vips interface. All was working OK when processing just a handful of files (testing). When I tried to ramp it up to hundreds of files, there was a crash after about 30 files.\r\n\r\nI have isolated this to a very simple example ruby script which just reads a series of numbered 2048 x 1556 pixel all-black tif images and writes each image out — all to the same output file — the error appears when reading a series of different files — writing to different output files or to the same output file makes no difference. This bombs on my system after 16 images. The error message trace back to Vips::Image.write_to_file is:\r\n\r\nGLib-GObject-CRITICAL **: g_value_type_compatible: assertion 'G_TYPE_IS_VALUE (src_type)' failed\r\nvalue.rb:158: in `check_type_compatibility': Vips::Image is incompatible with VipsImage (ArgumentError)\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/ffi-gobject/value.rb:139:in `set_instance_enhanced'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/ffi-gobject/value.rb:53:in `set_value'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/ffi-gobject/object.rb:77:in `set_property_with_override'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/argument.rb:130:in `set_value'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/call.rb:73:in `call_base'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/image.rb:384:in `write_to_file'\r\n\r\nMostly this is the error I get. One time the error was an address error (a zero address).\r\n\r\nHere is the simple test script:\r\n```ruby\r\nrequire 'vips8'\r\nrequire 'pathname'\r\n\r\nimage_folder = Pathname(__FILE__).dirname + \"IMAGE_FOLDER\"\r\n\r\n(1..50).each do |image_number|\r\n  \r\n  puts \"Image #{image_number}\"\r\n  \r\n  source_file_path = image_folder + \"test-2K-image-#{sprintf('%02d', image_number)}.tif\"\r\n\r\n  test_image = Vips::Image.new_from_file (source_file_path).to_s\r\n\r\n  test_image.write_to_file((image_folder + \"output_image.tif\").to_s)\r\nend\r\n```\r\n\r\nThe test files are named \"test-2K-image-01\", etc. I can't attach a sample file because GitHub doesn't support uploading tif files. Just create a test file in Photoshop then duplicate and number the duplicates.\r\n\r\nAs I say, the ruby-vips equivalent code worked without a problem.\r\n\r\nAny ideas?\r\n\r\nPaul Howson"},"comment":{"url":"https://api.github.com/repos/jcupitt/libvips/issues/comments/135709736","html_url":"https://github.com/jcupitt/libvips/issues/322#issuecomment-135709736","issue_url":"https://api.github.com/repos/jcupitt/libvips/issues/322","id":135709736,"user":{"login":"PaulHowson","id":11267299,"avatar_url":"https://avatars.githubusercontent.com/u/11267299?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulHowson","html_url":"https://github.com/PaulHowson","followers_url":"https://api.github.com/users/PaulHowson/followers","following_url":"https://api.github.com/users/PaulHowson/following{/other_user}","gists_url":"https://api.github.com/users/PaulHowson/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulHowson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulHowson/subscriptions","organizations_url":"https://api.github.com/users/PaulHowson/orgs","repos_url":"https://api.github.com/users/PaulHowson/repos","events_url":"https://api.github.com/users/PaulHowson/events{/privacy}","received_events_url":"https://api.github.com/users/PaulHowson/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T09:25:12Z","updated_at":"2015-08-28T09:25:12Z","body":"Hello again John,\r\n\r\nInfuriating indeed. However…\r\n\r\nI realised that the version of vips on my Mac was still 7.4.2 (or whatever it was). Maybe that explains why gir_ffi-vips was not linking to it correctly. :)\r\n\r\nSo I used homebrew to update vips. Spent a looooong time on that because of dependencies, permission problems, etc. Finally got everything updated. Then vips complained of libraries being out of date. Seems homebrew had installed latest versions but symlinks from /usr/local/lib were still old. Fixed those manually. Now vips runs:\r\n\r\n```\r\n$ vips -v\r\nvips-8.0.2-Sat May 16 05:51:25 PDT 2015\r\n```\r\n\r\nand\r\n\r\n```\r\nvips invert bw2.tif out.tif\r\n```\r\n…inverts a tif file. So command line vips is version 8 and it's working.\r\n\r\nBut this very basic script still fails:\r\n\r\n```ruby\r\nrequire 'vips8'\r\n\r\ninclude Vips\r\n\r\nim = Image.black(200, 200)\r\n\r\nim.write_to_file('test_image.png')\r\n```\r\n\r\nHere is error message:\r\n\r\n```\r\ntype_builder.rb:37: in `builder_for': undefined method `new' for nil:NilClass (NoMethodError)\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/gir_ffi/builders/type_builder.rb:32:in `build'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/gir_ffi/builder.rb:14:in `build_class'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/gir_ffi/builders/module_builder.rb:40:in `build_namespaced_class'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/gir_ffi/module_base.rb:16:in `setup_class'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-0.7.9/lib/gir_ffi/module_base.rb:11:in `const_missing'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/argument.rb:80:in `unwrap'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/argument.rb:135:in `get_value'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/call.rb:161:in `block in call_base'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/call.rb:156:in `each'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/call.rb:156:in `call_base'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/gir_ffi-vips-0.1.0/lib/vips8/image.rb:244:in `method_missing'\r\n\tfrom /Users/paul/Dev/projects/MovieStabiliser/mps-code/vips/vips8-tests/write-black.rb:5:in `<main>'\r\n```\r\n\r\n…which is same as error reported two days ago. I'm flummoxed. I thought upgrading vips would fix these problems.\r\n\r\nThis is obviously a very basic failure of gir_ffi to connect properly with the vips library.\r\n\r\nWhere do I look now? Must be something obvious.\r\n\r\nHope you can help.\r\n\r\nPaul"}}