[ruby-core:32847] [Ruby 1.9-Bug#3752][Rejected] ruby/dl and segmentation fault

From: Aaron Patterson <redmine@...>
Date: 2010-10-18 20:56:50 UTC
List: ruby-core #32847
Issue #3752 has been updated by Aaron Patterson.

Status changed from Assigned to Rejected

If you pass a wrong pointer to a function, it will segv just like the C code would segv.  DL is not meant to protect you from errors you could also make in C.

Here is an example of doing a null check, but with a crash.  Provide a good file to taglib, and it won't crash.

    require 'dl'
    require 'dl/import'
    
    module Foo
      extend DL::Importer
      dlload '/opt/local/lib/libtag_c.dylib'
      extern 'void* taglib_file_tag(void*)'
      extern 'void* taglib_file_new(char*)'
    end
    
    taglib_file = Foo.taglib_file_new(ARGV[0] || 'foo')
    
    if taglib_file.null?
      puts "bad file"
      Foo.taglib_file_tag(taglib_file) # This will SEGV because it's a NULL pointer
    else
      file_tag = Foo.taglib_file_tag(taglib_file)
    end

----------------------------------------
http://redmine.ruby-lang.org/issues/show/3752

----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next