Subject:
Re: [ruby-ffi] Re: Is the release interface supposed to swallow errors?
From:
Kim Burgestrand
Date:
10/9/13 3:25 AM
To:
ruby-ffi@googlegroups.com

Also, if you set $DEBUG to true, or start ruby with the -d-flag, all exceptions are printed to stderr, no matter if they are caught or not. This output can be noisy, depending on how much exceptions are used for flow control.

— Kim Burgestrand


On Wed, Oct 9, 2013 at 9:04 AM, Wayne Meissner <wmeissner@gmail.com> wrote:

All errors from the release method are indeed swallowed - release is called from a garbage collection thread, so it has to quash any exceptions.  

If you explicitly call kptr.pointer.free(), it should propagate exceptions from KStatCtl.release().


On Wednesday, 9 October 2013 02:52:15 UTC+11, Daniel Berger wrote:
Hi,

ffi 1.9.0

I noticed that if I declare a struct using .auto_ptr, that the corresponding release method seems to swallow errors.

require 'ffi'

class Solaris
  extend FFI::Library
  ffi_lib :kstat

  class KstatCtl < FFI::Struct
    layout(:kc_chain_id, :int, :kc_chain, :pointer, :kc_kd, :int)

    def self.release(pointer)
      puts "Releasing..." # Yep, I see this
      bogus # Shouldn't this raise an error? Instead, nothing happens.
    end
  end

  attach_function :kstat_open, [], KstatCtl.auto_ptr
  attach_function :kstat_close, [KstatCtl], :int

  def self.kstat
    kptr = kstat_open()
    kstat_close(kptr)
  end
end

Solaris.kstat

What I'm really trying to do is have the release method call kstat_close inside the KstatCtl's release method. It fails, but I can't tell -why- it fails since the error is getting swallowed.

Help or advice appreciated.

Regards,

Dan

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.