ffi-msgpack icon indicating copy to clipboard operation
ffi-msgpack copied to clipboard

Data corruption with jruby

Open chadrem opened this issue 10 years ago • 1 comments

ffi-msgpack (0.2.1) corrupts data when used with JRuby (1.7.11). Unfortunately I don't know the cause. The same code works fine with MRI 2.1.1.

Ruby version:

jruby 1.7.11 (1.9.3p392) 2014-02-24 86339bb on Java HotSpot(TM) 64-Bit Server VM 1.7.0_51-b13 [darwin-x86_64]

Gemfile:

source 'http://rubygems.org'
gem 'ffi-msgpack', '0.2.1'

Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    ffi (1.9.3-java)
    ffi-msgpack (0.2.1)
      ffi (~> 1.0)

PLATFORMS
  java

DEPENDENCIES
  ffi-msgpack (= 0.2.1)

Script code:

require 'rubygems'
require 'bundler/setup'
require 'ffi/msgpack'

100000.times do |i|
  input = { 'hello' => 'world' }
  packed = FFI::MsgPack.pack(input)
  unpacked = FFI::MsgPack.unpack(packed)
  if input != unpacked
    puts "Corruption (#{i})! #{input.inspect} != #{unpacked.inspect}, packed=#{packed.inspect}"
  end
end

Script output:

Corruption (8013)! {"hello"=>"world"} != nil, packed=""
Corruption (13962)! {"hello"=>"world"} != nil, packed=""
Corruption (31809)! {"hello"=>"world"} != nil, packed=""
Corruption (42713)! {"hello"=>"world"} != nil, packed=""
Corruption (65398)! {"hello"=>"world"} != nil, packed=""

chadrem avatar Mar 09 '14 18:03 chadrem

Just tried to repro with JRuby 9.2.11.1, FFI 1.13.1, and libmsgpack 3.1.0 and worked fine. Only significant changes since your issue have been 6c315255b5e79f30798c04ccf64235f198b1729f and d0f0054721e9c30c93cad7b70b40a6787c034294. Could you try reproing again to see if this is still an issue?

postmodern avatar Nov 28 '20 17:11 postmodern