-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Labels
Description
The below reproduction script triggers a series of different issues when I run it. It generates
a black image and then loops over a single remotely-hosted image asset and composites it some number of times with a small offset each time. Running it results in one of a few outcomes:
- A segfault (https://gist.github.com/taylorthurlow/e3c3e22b339920bace61dae586efc525, plus accompanying crash report https://gist.github.com/taylorthurlow/af4e8e72f82de5ba88481037e6abf211)
- Prints
SEGV received in BUS handler
and aborts - The script freezes and loads up the CPU, and works until killed
- Prints
read: unexpected return
a few times and exits. Corresponding to the number of failed reads, some portion of the composited images will be the typical "broken jpg gray" but still composited into the final image. - Occasionally, particularly with low numbers of input images, the image is rendered successfully.
The outcome does seem mostly random, but at times it does seem like the number of URLs in the input array might have some effect.
Using VIPS_CONCURRENCY=1
does not seem to have an effect.
To Reproduce
require "vips"
require "open-uri"
IMAGE_URLS = ["https://cdn.filestackcontent.com/bnTGtQw5ShqMPpxH2tMw"] * 10
image = Vips::Image.black(1500, 1500)
streams = []
IMAGE_URLS.each_with_index do |url, i|
puts "loading #{url}"
stream = URI.parse(url).open("rb")
streams << stream
source = Vips::SourceCustom.new
source.on_read { |length| stream.read(length) }
overlay = Vips::Image.new_from_source(source, "")
image = image.composite2(overlay, :over, x: 50 * (i + 1), y: 50 * (i + 1))
end
image.write_to_file("output.jpg")
streams.each(&:close)
Expected behavior
No error is printed and the image is composited correctly each time it is called.
Desktop:
- macOS Sonoma 14.2.1, Mac Mini M3 Pro (apple silicon)
- Ruby 3.1, 3.2, and 3.3
- vips 8.15.1
- ruby-vips 2.2.0