Subject:
[ruby-ffi] segfault on windows MRI but not windows JRuby
From:
Jon
Date:
11/27/09 11:41 AM
To:
ruby-ffi@googlegroups.com

In the Novice section of http://wiki.github.com/ffi/ffi/windows-examples I'm trying to finish the Enumerate Top Level Windows example and am getting segfaults under MRI 1.8.6 and 1.9.1 but not JRuby 1.4.0 in either 1.8 or 1.9 modes.

I'm ramping up to speed on FFI and not yet sure whether it's my code or the MRI FFI impl or a Ruby impl issue or something else.

Details below, but in the segfault cases the top-level windows are enumerated and then the segfault occurs.  I've futzed with the signatures (e.g. changed EnumDesktopWindows return type from :bool to :int as windows "typedef int BOOL"), kept the Ruby script alive with "STDIN.gets" at script end, and futzed with param types to EnumDesktopWindows all to no avail.

What have I missed?

Jon



DETAILS
=======
> ruby --version
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]

> gem --version
1.3.5

> gem list ffi

*** LOCAL GEMS ***

ffi (0.5.3)


> ruby ffi_enumwin.rb
[001] Found ''
<..SNIP..>
[303] Found ''
[304] Found ''
[305] Found ''
[306] Found ''
[307] Found ''
[308] Found ''
[309] Found ''
[310] Found ''
[311] Found ''
[312] Found ''
[313] Found ''
[314] Found ''
[315] Found ''
(eval):3: [BUG] Segmentation fault
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]

-- control frame ----------
c:0005 p:---- s:0018 b:0018 l:000017 d:000017 CFUNC  :call
c:0004 p:0016 s:0012 b:0012 l:000011 d:000011 METHOD (eval):3
c:0003 p:0073 s:0007 b:0007 l:001bb4 d:001888 EVAL   ffi_enumwin.rb:20
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001bb4 d:001bb4 TOP
---------------------------
-- Ruby level backtrace information-----------------------------------------
(eval):3:in `call'
(eval):3:in `EnumDesktopWindows'
ffi_enumwin.rb:20:in `<main>'