Project

General

Profile

Actions

Bug #3302

closed

segfault in 1.8.6 p398 in Ruby::DL

Added by juuser (Jarmo Pertman) almost 14 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:30271]

Description

=begin
I tried to call a simple method on Windows (XP 32bit, Win7 64bit - didn't matter)
machine and it seems that i will get a segmentation fault depending of
the Ruby version.

Here is the offending code (doc for EnumWindows is at
http://msdn.microsoft.com/en-us/library/ms633497(v=VS.85).aspx):

require 'dl/import'

module Testing

extend DL::Importable

dlload "user32.dll"

USER32 = DL.dlopen("user32")
EnumWindows = USER32['EnumWindows', 'IPL']

CALLBACK = DL.callback('ILL') do |curr_hwnd, p|
p curr_hwnd
0
end

module_function

def enumerate
EnumWindows.call(CALLBACK, 0)
end
end

Testing.enumerate


And when trying to run it with different Ruby 1.8.6 patchlevels, i see
the following output:

S:>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

S:>testing.rb
328312

S:>ruby -v
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

S:>testing.rb
393884
S:/testing.rb:20: [BUG] Segmentation fault
ruby 1.8.6 (2010-02-04) [i386-mingw32]

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.


So, p398 gives me a segfault. On the other hand FFI example at
http://wiki.github.com/ffi/ffi/windows-examples works perfectly. Also using Win32::API works.

Jarmo
=end

Actions #1

Updated by rogerdpack (Roger Pack) almost 14 years ago

=begin
Does this work with 1.9.x?
=end

Actions #2

Updated by juuser (Jarmo Pertman) almost 14 years ago

=begin
I'm not sure since it seems that Ruby 1.9.1 has changed it's API for DL and this code won't run without modifications. If you can understand all of the changes to be needed, then let me know and I can try. I myself, didn't understand how to modify line EnumWindows = USER32['EnumWindows', 'IPL'] to make it work with 1.9.1 for example.

Jarmo
=end

Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Tracker changed from Backport to Bug
  • Project changed from Backport186 to Ruby master
  • Description updated (diff)
  • Status changed from Open to Closed
  • Backport set to 2.5: UNKNOWN, 2.6: UNKNOWN
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0