Trying to run examples under XP
So far I had no success setting up environment to run your examples under Windows XPSP3 (32bit). I have successfully built zeromq-2.0.10 - with Visual Studio from Windows package and from sources under Cygwin. So, I have zeromq library working and in path.
Here are the Rubies that I tried (since it is indicated that either JRuby or 1.9.2 are adequate, I only tried those): Ruby 1.9.2-p0 (Rubyinstaller) JRuby 1.5.2 Ruby 1.9.2-p0 (built from source under Cygwin)
Unfortunately, trying to run example from https://github.com/andrewvc/learn-ruby-zeromq/ fails with a following trace:
Y:\Dev\apps\win\learn-ruby-zeromq\001_Socket_Types>jruby -v jruby 1.5.2 (ruby 1.8.7 patchlevel 249) (2010-08-20 1c5e29d) (Java HotSpot(TM) Client VM 1.6.0_20) [x86-java]
Y:\Dev\apps\win\learn-ruby-zeromq\001_Socket_Types>gem list
columnize (0.3.1) ffi (0.6.3) ffi-rzmq (0.6.0) rake (0.8.7) rspec (1.3.0) ruby-debug (0.10.3) ruby-debug-base (0.10.3.2) sources (0.0.1) zmqmachine (0.3.2)
Y:\Dev\apps\win\learn-ruby-zeromq\001_Socket_Types>jruby 001_push_pull.rb
C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/site_ruby/shared/ffi/ffi.rb:112:in create_invoker': Function 'valloc' not found in [msvcrt] (FFI::NotFoundError) from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/site_ruby/shared/ffi/library.rb:98:inattach_function'
from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/site_ruby/shared/ffi/library.rb:96:in each' from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/site_ruby/shared/ffi/library.rb:96:inattach_function'
from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/gems/1.8/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq/wrapper.rb:11
from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/gems/1.8/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq/wrapper.rb:31:in require' from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/gems/1.8/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:71
from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/gems/1.8/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:70:in each' from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/gems/1.8/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:70 from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/gems/1.8/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:36:inrequire'
from C:/Documents and Settings/bezrodnykh/.pik/rubies/JRuby-152/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from 001_push_pull.rb:2
$ ruby -v ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-cygwin]
$ gem list
ffi (0.6.3) ffi-rzmq (0.6.0) rake (0.8.7) rubygems-update (1.3.7) zmqmachine (0.3.2)
vb@vb-mac /y/dev/apps/win/learn-ruby-zeromq/001_Socket_Types
$ ruby 001_push_pull.rb
/home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-0.6.3/lib/ffi/library.rb:129:in attach_function': Function 'valloc' not found in [msvcrt.dll] (FFI::NotFoundError) from /home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq/wrapper.rb:11:inmodule:LibC'
from /home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq/wrapper.rb:3:in <top (required)>' from /home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:71:inrequire'
from /home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:71:in block in <top (required)>' from /home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:70:ineach'
from /home/bezrodnykh/.rvm/gems/ruby-1.9.2-preview1/gems/ffi-rzmq-0.6.0/lib/ffi-rzmq.rb:70:in <top (required)>' from 001_push_pull.rb:2:inrequire'
from 001_push_pull.rb:2:in `
Any advice/suggestion/hint to help me moving forward?
Thanks for reporting the issue! I think you found a bug in ffi-rzmq
From what I can look up It looks like valloc is linux only. This is issue is likely from https://github.com/chuckremes/ffi-rzmq/blob/master/lib/ffi-rzmq/wrapper.rb#L11 However, I don't see valloc used anywhere in ffi-rzmq, so it may be safe to remove.
You could try uninstalling the ffi-rzmq gem removing that line, then building it from github (just run rake gem:package in the ffi-rzmq directory after you clone it off github, then install the custom gem from the pkg folder).
Let me know how it goes, I don't have windows, so I can't test it myself. If that fixes it, try submitting a but to ffi-rzmq, chuck's good about fixes.
Thanks for your tip, Andrew!
Indeed, commenting out valloc and bcopy (as well as redefining :size_t) resolved this particular issue. Now, I've got to the point where I'm "Sending 1 Potato", but nothing comes out just yet. ;)
I recall that trying your example on OSX under 1.9.1 got me the same result at first. But after I installed 1.9.2, example run on OSX.
Under Windows, I have 1.9.2, but it's still stuck "Sending 1 Potato". Any suggestions how I can troubleshoot further?
Glad I could help!
Are you sure you're running the latest FFI lib built custom using the FFI gem from github?
gem install ffi installs an old one with broken threading. It sounds like that's what you're hitting (receive will block ALL threads with the bad FFI).
BTW, I've been running my ZMQ stuff under rubinius lately, works really well.
Oh, also rubinius doesn't need the FFI gem installed, neither does jruby.
OK, I now tried it with JRuby, and it worked!
However, my target environment is WinXP/MRI, so I just have to make it work for 1.9.2.
Yes, in my excitement I totally forgot about the need to install custom ffi gem (that's what stalled my progress on OSX too). Now, trying to install the gem that you have in your master failed to build native extensions under Windows/MRI 1.9.2p0:
Y:\Dev\apps\win\learn-ruby-zeromq\gems>gem install *.gem Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing ffi-0.6.3.gem: ERROR: Failed to build gem native extension.
C:/Dev/ruby/bin/ruby.exe extconf.rb checking for rb_thread_blocking_region()... yes checking for ruby_thread_has_gvl_p()... yes checking for ruby_native_thread_p()... yes checking for rb_thread_call_with_gvl()... yes creating extconf.h creating Makefile
make gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o AbstractMemory.o -c AbstractMemory.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o ArrayType.o -c ArrayType.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o AutoPointer.o -c AutoPointer.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o Buffer.o -c Buffer.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o Call.o -c Call.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o ClosurePool.o -c ClosurePool.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o DataConverter.o -c DataConverter.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o DynamicLibrary.o -c DynamicLibrary.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o ffi.o -c ffi.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o Function.o -c Function.c Function.c:87:0: warning: "DEFER_ASYNC_CALLBACK" redefined Function.c:78:0: note: this is the location of the previous definition Function.c: In function 'async_cb_wait': Function.c:453:25: error: 'async_cb_mutex' undeclared (first use in this function) Function.c:453:25: note: each undeclared identifier is reported only once for each function it appears in Function.c:456:28: error: 'async_cb_cond' undeclared (first use in this function) Function.c: In function 'async_cb_stop': Function.c:474:25: error: 'async_cb_mutex' undeclared (first use in this function) Function.c:476:26: error: 'async_cb_cond' undeclared (first use in this function) Function.c: In function 'async_cb_call': Function.c:488:27: error: 'struct gvl_callback' has no member named 'async_mutex' Function.c:489:28: error: 'struct gvl_callback' has no member named 'async_cond' Function.c:490:29: error: 'struct gvl_callback' has no member named 'async_mutex' Function.c: In function 'callback_with_gvl': Function.c:584:13: warning: excess elements in scalar initializer Function.c:584:13: warning: (near initialization for 'values') Function.c:585:13: warning: passing argument 4 of 'rb_funcall2' makes pointer from integer without a cast c:/Dev/ruby/include/ruby-1.9.1/ruby/ruby.h:1108:7: note: expected 'const VALUE ' but argument is of type 'VALUE' Function.c:594:9: warning: excess elements in scalar initializer Function.c:594:9: warning: (near initialization for 'values') Function.c:595:9: warning: passing argument 4 of 'rb_funcall2' makes pointer from integer without a cast c:/Dev/ruby/include/ruby-1.9.1/ruby/ruby.h:1108:7: note: expected 'const VALUE *' but argument is of type 'VALUE' make: ** [Function.o] Error 1
Gem files will remain installed in C:/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3 for inspection. Results logged to C:/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/gem_make.out
Trying to clone and install ffi HEAD from Github exploded with different trace:
gem.bat install --local pkg/ffi-0.6.3 Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing pkg/ffi-0.6.3: ERROR: Failed to build gem native extension.
C:/Dev/ruby/bin/ruby.exe extconf.rb checking for rb_thread_blocking_region()... yes checking for ruby_thread_has_gvl_p()... yes checking for ruby_native_thread_p()... yes checking for rb_thread_call_with_gvl()... yes creating extconf.h creating Makefile
make gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o AbstractMemory.o -c AbstractMemory.c AbstractMemory.c: In function 'memory_op_put_int32': AbstractMemory.c:153:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_op_get_int32': AbstractMemory.c:153:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_put_array_of_int32': AbstractMemory.c:153:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_get_array_of_int32': AbstractMemory.c:153:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_op_put_int64': AbstractMemory.c:155:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_op_get_int64': AbstractMemory.c:155:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_put_array_of_int64': AbstractMemory.c:155:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_get_array_of_int64': AbstractMemory.c:155:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_op_put_long': AbstractMemory.c:157:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_op_get_long': AbstractMemory.c:157:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_put_array_of_long': AbstractMemory.c:157:1: warning: signed and unsigned type in conditional expression AbstractMemory.c: In function 'memory_get_array_of_long': AbstractMemory.c:157:1: warning: signed and unsigned type in conditional expression gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o ArrayType.o -c ArrayType.c gcc -I. -IC:/Dev/ruby/include/ruby-1.9.1/i386-mingw32 -I/C/Dev/ruby/include/ruby-1.9.1/ruby/backward -I/C/Dev/ruby/include/ruby-1.9.1 -I. -I/c/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/libffi/include -DRUBY_EXTCONF_H="extconf.h" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -o AutoPointer.o -c AutoPointer.c AutoPointer.c: In function 'autoptr_allocate': AutoPointer.c:28:14: error: 'AbstractMemory' has no member named 'access' make: *** [AutoPointer.o] Error 1
Gem files will remain installed in C:/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3 for inspection.
Results logged to C:/Dev/ruby/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ext/ffi_c/gem_make.out
rake aborted!
Command failed with status (1): [ gem.bat install --local pkg/ffi-0.6.3...]
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:993:in block in sh' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:1008:incall'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:1008:in sh' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:1092:insh'
Y:/Dev/apps/win/ffi/tasks/gem.rake:171:in block (2 levels) in <top (required)>' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:634:incall'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:634:in block in execute' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:629:ineach'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:629:in execute' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:595:inblock in invoke_with_call_chain'
C:/Dev/ruby/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:588:ininvoke_with_call_chain'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:581:in invoke' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:2041:ininvoke_task'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:2019:in block (2 levels) in top_level' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:2019:ineach'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:2019:in block in top_level' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:2058:instandard_exception_handling'
C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:2013:in top_level' C:/Dev/ruby/lib/ruby/1.9.1/rake.rb:1992:inrun'
C:/Dev/ruby/bin/rake:31:in `
Any idea what may be wrong with this?
Hmm, not quite sure. Maybe try the FFI guys see what they say?
Not sure if this is feasible, but rubinius probably would have fewer issues, and is mostly MRI compatible these days.
Just installed ffi gem from your master under Cygwin (Guthub HEAD still won't build) and got Potatoes sent and received under Cygwin/MRI 1.9.2 now.
So, now the only problematic environment that remains is plain WinXP/MRI 1.9.2, which unfortunately is my target. This still fails since both your ffi gem and github HEAD fail to build, with different backtraces.
Since the root cause seems to be FFI gem, I'm off to bug FFI guys about it. ;)
Thanks for all your help and also helpful examples that I'm sure to follow once I've bent my target environment into submission!