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

[FFI] FFI::AutoPointer#free causes FFI::AutoPointer#autorelease? to cast NullPointerException #654

Closed
Burgestrand opened this Issue Apr 24, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@Burgestrand
Copy link

Burgestrand commented Apr 24, 2013

require "ffi"

class Releasable < FFI::AutoPointer
  def self.release(pointer)
    puts "Release"
    # no op
  end
end

p = FFI::Pointer.new(1)
r = Releasable.new(p)
r.free
p r.autorelease? # => NullPointerException

It’s because when AutoPointer#free is called, the reaper (managed for releasing the pointer) is reassigned to null. This causes AutoPointer#autorelease? to fail, since reaper is now no longer.

@ghost ghost closed this in c253096 Apr 24, 2013

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.