Results 1 to 4 of 4

Thread: IceRuby stringify has null characters

  1. #1
    swaj is offline Registered User
    Name: Scott Anderson
    Organization: Personal
    Project: Murmur Rails Control Panel
    Join Date
    Aug 2010
    Posts
    4

    Unhappy IceRuby stringify has null characters

    Recently I've been trying to work with an Ice client written in Ruby. I have been able to generate the appropriate modules using slice2rb, and I can establish a connection just fine. The problem with stringify happens when I call certain methods on the generated module.

    The ice file for this project can be found here: http://geeksharp.com/dl/Murmur.ice

    Here's the log for my session with IRB:

    Code:
    irb(main):001:0> $LOAD_PATH << '/opt/Ice-3.4.1/ruby'
    => ["/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/i686-linux", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/vendor_ruby/1.8", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/vendor_ruby/1.8/i686-linux", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/vendor_ruby", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8", "/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/i686-linux", ".", "/opt/Ice-3.4.1/ruby"]
    irb(main):002:0> require "murmur.rb"
    => true
    irb(main):003:0> comm = Ice.initialize()
    => #<Ice::CommunicatorI:0x93d3520>
    irb(main):004:0> proxy = comm.stringToProxy("Meta:tcp -h 127.0.0.1 -p 6502")
    => Meta -t:tcp -h 127.0.0.1 -p 6502
    irb(main):005:0> meta = Murmur::MetaPrx::checkedCast(proxy)
    => Meta -t:tcp -h 127.0.0.1 -p 6502
    irb(main):006:0> server = meta.getServer(1)
    => s/1 -t:tcp -h 127.0.0.1 -p 6502
    irb(main):007:0> users = server.getUsers()
    ArgumentError: string contains null byte
            from ./murmur.rb:111:in `__stringify'
            from ./murmur.rb:111:in `inspect'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:310:in `output_value'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:159:in `eval_input'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:271:in `signal_status'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:155:in `eval_input'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:154:in `eval_input'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:71:in `start'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:70:in `catch'
            from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/irb.rb:70:in `start'
            from /opt/ruby-enterprise-1.8.7-2010.02/bin/irb:13
    irb(main):008:0>
    So you'll notice I'm using Ruby Enterprise Edition, however I have tested this with my vendor-supplied (Ubuntu) default ruby install and the same problem happens. I was even able to compile IceRuby on MacOSX at home using Ruby 1.8.7, and again, I get the same problem.

    Just to see if there was a problem with the Murmur program (Mumble) I decided to try the same thing in C# and Python. Using slice2cs and slice2py, I generated modules from the slice definition I linked above. When using C# and Python to perform this same function, I did not encounter any problems. For reference, here's the python code I used:

    Code:
    import Murmur_ice
    import Ice
    import Murmur
    
    murmur_host = '127.0.0.1'
    murmur_port = '6502'
    murmur_server_id = 1
    
    comm = Ice.initialize()
    meta = Murmur.MetaPrx.checkedCast(comm.stringToProxy('Meta:tcp -h %(host)s -p %(port)s' % {'host': murmur_host, 'port': murmur_port}))
    server = meta.getServer(murmur_server_id)
    userdict = server.getUsers()
    You can see at the end that I call the same method as in the Ruby code, but within Python I have no problems. Any help would be greatly appreciated. I'd much prefer to use Ruby for this project, and I was hoping that the IceRuby libraries would be able to handle it for me.

    Thanks in advance for your help! If I've left anything out, or if one of your developers would like a shell account on my server to investigate this issue, I'll be happy to oblige.
    Last edited by swaj; 08-05-2010 at 09:22 AM.

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi,

    Welcome to the forum.

    I think the problem here is that irb attempts to display the results of every line it executes. The dictionary returned by getUsers appears to contain a string with a null byte that (for some reason) Ruby finds offensive. I'm guessing the null byte is in the address member of the User structure.

    Have you tried running this code in a standalone script (outside of irb)? I suspect it will work just fine.

    To further investigate this ArgumentError exception, it would be very helpful to see the contents of the dictionary returned by getUsers. I'm still not sure whether the Ice extension is doing anything wrong here, as this exception is raised by Ruby and not by the extension, but perhaps we can do something to work around it in the future.

    Regards,
    Mark

  3. #3
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    I looked into this a bit more. It turns out the Ice extension needs to be a bit smarter about how it prints sequence<byte> values. We'll fix this in the next release.

    At this point I'm afraid your only solution is to avoid printing these values.

    Regards,
    Mark

  4. #4
    swaj is offline Registered User
    Name: Scott Anderson
    Organization: Personal
    Project: Murmur Rails Control Panel
    Join Date
    Aug 2010
    Posts
    4

    Smile

    Thanks for your help. You were right. When I wrap this code in an actual script and run it, I'm able to execute the method just fine. I'm glad to hear this will be fixed in the future.

    Cheers!

    EDIT: As a side note, if you need any more information to help fix this bug, please let me know!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Implementing null object pattern for proxies on client-side
    By Alexey Romanov in forum Help Center
    Replies: 7
    Last Post: 07-12-2010, 11:35 AM
  2. why is my Ice.Application.communicator() is null?
    By cnhome in forum Help Center
    Replies: 1
    Last Post: 07-01-2010, 11:26 PM
  3. Ice do not support Chinese characters
    By IvanFly in forum Bug Reports
    Replies: 1
    Last Post: 06-03-2010, 02:12 PM
  4. Ice.Current.hashCode() can throw a NPE on null enum
    By joshmoore in forum Bug Reports
    Replies: 1
    Last Post: 08-20-2007, 03:46 AM
  5. null sequence in C#
    By chris92 in forum Help Center
    Replies: 3
    Last Post: 09-29-2006, 08:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •