Project

General

Profile

Bug #1453

dl in ruby-1.9 must check whether block is given to TempFunction

Added by sheepman (Takashi Tamura) about 11 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2009-05-02 trunk 23326) [i686-linux]
Backport:
[ruby-dev:38404]

Description

=begin
以下のようにブロック付きで呼ぶべきところで呼ばないと落ちます。

$ cat d7.rb
require 'dl/import'

require 'dl/import'
module M
extend DL::Importer
dlload "libc.so.6"
QsortCallbackWithoutBlock = bind("void qsort_callback(void, void*)", :temp)
extern 'void qsort(void *, int, int, void *)'
end
buff = "3465721"
M.qsort(buff, buff.size, 1, M::QsortCallbackWithoutBlock) # <= ここはブロックつきで呼ばないといけない。

$ ruby-1.9 d7.rb
/usr/local/pkg/ruby-1.9/lib/ruby/1.9.1/dl/func.rb:37: [BUG] Segmentation fault
ruby 1.9.2dev (2009-05-02 trunk 23326) [i686-linux]

ブロックが与えられたかをチェックするパッチです。

Index: lib/dl/value.rb
===================================================================
--- lib/dl/value.rb (リビジョン 23328)
+++ lib/dl/value.rb (作業コピー)
@@ -63,6 +63,8 @@ module DL
if( block )
arg.bind_at_call(&block)
funcs.push(arg)

  • elsif arg.is_a?(TempFunction)
  • raise(RuntimeError, "block must be given.") end return arg.to_i when String =end
#1

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23386.
=end

Also available in: Atom PDF