rbczmq icon indicating copy to clipboard operation
rbczmq copied to clipboard

ZMQ::Message#print fails with binding error

Open wokibe opened this issue 9 years ago • 1 comments

When executing the following ruby snippet: module ZMQ class Socket def dump_messages loop do message = recv_message message.print break unless rcvmore? end end end end

I get this result: dyld: lazy symbol binding failed: Symbol not found: _zmsg_dump Referenced from: /Users/kittekat/.rvm/gems/ruby-2.1.3@noko/extensions/x86_64-darwin-13/2.1.0-static/rbczmq-1.7.8/rbczmq_ext.bundle Expected in: flat namespace

The analysis showed, that this is related to a version mismatch of rbczmq and the czmq library. I am using a brew installed czmq version 2.2.0 (see issue 36), but the rbczmq 1.7.8 seems to use version 2.0.1 (result of calling ZMQ.czmq_version).

The source of Message#print references zmsg_dump (ext/rbczmq/message.c): static VALUE rb_czmq_message_print(VALUE obj) { ZmqGetMessage(obj); ZmqReturnNilUnlessOwned(message); zmsg_dump(message->message); return Qnil; }

But in the actual czmq socket.h the zmsg_dump has been depricated: // Deprecated method aliases

define zmsg_dump(s) zmsg_print(s)

Do you have plans to update rbczmq to the actual czmq?

Best regards Wokibe

wokibe avatar Mar 05 '15 15:03 wokibe

As ad hoc workaround I defined the following monkey patch

require 'rbczmq'

module ZMQ
  class Message
    def print
      msg = self
      frame = msg.first
      while frame
        frame.print
        frame = msg.next
      end
    end
  end

  class Socket
    def dump_messages
      loop do
        message = recv_message
        message.print
        break unless rcvmore?
      end
    end
  end
end

Best regards Wokibe

wokibe avatar Mar 06 '15 19:03 wokibe