Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed when actively use draw_line #140

Closed
Nakilon opened this issue Oct 8, 2017 · 6 comments
Labels

Comments

@Nakilon
Copy link
Contributor

Nakilon commented Oct 8, 2017

(test.rb:93224): GLib-GObject-WARNING **: instance of invalid non-instantiatable type '(null)'

(test.rb:93224): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(test.rb:93224): GLib-GObject-WARNING **: instance of invalid non-instantiatable type '(null)'

(test.rb:93224): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(test.rb:93224): GLib-GObject-WARNING **: instance of invalid non-instantiatable type '(null)'

(test.rb:93224): GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

Program seems to produce valid images, but there are warnings printed. So I minified my program as much possible to reproduce it:

$ cat Gemfile
source "https://rubygems.org"
ruby "2.0.0"

gem "ruby-vips"
$ cat Gemfile.lock 
GEM
  remote: https://rubygems.org/
  specs:
    ffi (1.9.18)
    ruby-vips (2.0.7)
      ffi (~> 1.9)

PLATFORMS
  ruby

DEPENDENCIES
  ruby-vips

RUBY VERSION
   ruby 2.0.0p648

BUNDLED WITH
   1.15.4

Mac OS

require "vips"

a, b = Array.new(2).map{ |f| Vips::Image.new_from_file "../images/1d468d064d2e26b5b5de9a0241ef2d4b.jpg" }.map do |image|
  image = image.draw_line 0, 0, 1, 0, 2
  image
end

a, b = [a, b].map do |image|
  45.times do
    image = image.draw_line 0, 0, 1, 0, 2
  end
  image
end

a.join(b, :horizontal, expand: true).write_to_file "ab.jpg"

Warnings will disappear if I decrease the number 45 or if I remove the first .draw_line call. Also when I use Vips::Image.blank 1000, 1000 instead of a real file, and some images cause this issue, some are not. Also they were disappearing even depending on the number of lines in this source file. Or when I used Array.new(2) instead of ARGV passing two arguments, etc.
Probably you will need try different images or increase the number of image = image.draw_line lines to execute.

@jcupitt
Copy link
Member

jcupitt commented Oct 9, 2017

I made a slight variation :

require "vips"

a = b = Vips::Image.new_from_file "/home/john/pics/k2.jpg"
a = a.draw_line 0, 0, 1, 0, 2
b = b.draw_line 0, 0, 1, 0, 2

a, b = [a, b].map do |image|
    30.times do |i|
        puts "iteration #{i} .."
        image = image.draw_line 0, 0, 1, 0, 2
    end
    image
end

puts "writing .."
a.join(b, :horizontal, expand: true).write_to_file "ab.jpg"

Make messages fatal with:

$ export G_DEBUG=fatal-warnings

And you can see it fails at different points each time, and with slightly different messages, which is interesting.

gdb shows that it's perhaps something to do with progress feedback system.

@jcupitt jcupitt added the bug label Oct 9, 2017
@jcupitt
Copy link
Member

jcupitt commented Oct 9, 2017

Commenting out this line:

https://github.com/jcupitt/libvips/blob/master/libvips/foreign/foreign.c#L813

Seems to fix it. I'll investigate.

Thanks for the report!

jcupitt added a commit to libvips/libvips that referenced this issue Oct 9, 2017
we were leaving a few bits of the original image around after
vips_image_copy_memory(), including the progress signal ... if earlier images
were freed, perhaps by a GC in a language binding, we could get a dangling
pointer

thanks Nakilon, see libvips/ruby-vips#140
@jcupitt
Copy link
Member

jcupitt commented Oct 9, 2017

I've pushed a proper fix to 8.5, it seems to work now. I'll do an 8.5.9 in the next day or so.

Thanks again for the report.

@Nakilon
Copy link
Contributor Author

Nakilon commented Oct 10, 2017

Nice. I use brew to install and update vips on Mac OS -- who updates the formula there?

@jcupitt
Copy link
Member

jcupitt commented Oct 10, 2017

I'm the main contact for the formula, but anyone can put in a PR, of course.

jcupitt added a commit to libvips/libvips that referenced this issue Oct 11, 2017
when writing to a non-partial image, vips_image_write() now carefully severs
all connections between the two images on completion

this fixes a couple of cases where we had bad behaviour: writing to a
temp file could leave dangling pointers, see

https://github.com/jcupitt/libvips/issues/708

and writing to a memory buffer during copy_memory coud leave dangling
pointers too, see:

libvips/ruby-vips#140
@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2017

OK, 8.5.9 is up with this fix. You should just be able to edit your vips.rb formula.

@jcupitt jcupitt closed this as completed Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants