Skip to content

Random segfaults, lockups @ high CPU usage, and "read: unexpected return" messages #384

@taylorthurlow

Description

@taylorthurlow

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions