Hello community, here is the log from the commit of package rubygem-msgpack for openSUSE:Factory checked in at 2018-02-10 18:00:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-msgpack (Old) and /work/SRC/openSUSE:Factory/.rubygem-msgpack.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-msgpack" Sat Feb 10 18:00:05 2018 rev:4 rq:574935 version:1.2.2 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-msgpack/rubygem-msgpack.changes 2017-12-19 10:58:36.041022481 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-msgpack.new/rubygem-msgpack.changes 2018-02-10 18:00:08.191854787 +0100 @@ -1,0 +2,15 @@ +Thu Feb 8 06:13:39 UTC 2018 - coolo@suse.com + +- updated to version 1.2.2 + see installed ChangeLog + + 2018-01-11 version 1.2.2: + + * Fix bug to occur SEGV occasionally (depends on GC timing) when exttype is used + * Fix bug to encode an ext type with wrong type id if superclass is also registered as ext type + + 2017-12-08 version 1.2.1: + + * Hotfix release only for JRuby: 1.2.0-java was built in incorrect way + +------------------------------------------------------------------- Old: ---- msgpack-1.2.0.gem New: ---- msgpack-1.2.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-msgpack.spec ++++++ --- /var/tmp/diff_new_pack.ppiAJB/_old 2018-02-10 18:00:09.747798461 +0100 +++ /var/tmp/diff_new_pack.ppiAJB/_new 2018-02-10 18:00:09.751798316 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-msgpack # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-msgpack -Version: 1.2.0 +Version: 1.2.2 Release: 0 %define mod_name msgpack %define mod_full_name %{mod_name}-%{version} ++++++ msgpack-1.2.0.gem -> msgpack-1.2.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2017-12-07 04:21:29.000000000 +0100 +++ new/.travis.yml 2018-01-11 07:11:14.000000000 +0100 @@ -1,20 +1,5 @@ language: ruby -rvm: - - 2.0.0 - - 2.1.6 - - 2.2.2 - - 2.3.0 - - 2.4.0 - - ruby-head - - jruby-19mode - - jruby-9.1.5.0 - - jruby-head - -os: - - linux - - osx - sudo: false branches: @@ -24,18 +9,30 @@ gemfile: - Gemfile +# http://rubies.travis-ci.org/ matrix: - exclude: - - rvm: 2.0.0 - os: osx - - rvm: jruby-19mode + include: + - rvm: 2.1.10 + os: linux + - rvm: 2.2.8 + os: linux + - rvm: 2.3.5 + os: linux + - rvm: 2.3.5 os: osx - - rvm: jruby-9.1.5.0 + - rvm: 2.4.2 + os: linux + - rvm: 2.4.2 os: osx + - rvm: ruby-head + os: linux + - rvm: jruby-9.1.9.0 + os: linux - rvm: jruby-head - os: osx + os: linux + - rvm: jruby-19mode + os: linux allow_failures: - rvm: ruby-head - rvm: jruby-head - rvm: jruby-19mode - os: osx diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ChangeLog new/ChangeLog --- old/ChangeLog 2017-12-07 04:21:29.000000000 +0100 +++ new/ChangeLog 2018-01-11 07:11:14.000000000 +0100 @@ -1,3 +1,12 @@ +2018-01-11 version 1.2.2: + +* Fix bug to occur SEGV occasionally (depends on GC timing) when exttype is used +* Fix bug to encode an ext type with wrong type id if superclass is also registered as ext type + +2017-12-08 version 1.2.1: + +* Hotfix release only for JRuby: 1.2.0-java was built in incorrect way + 2017-12-07 version 1.2.0: * Add MessagePack::Factory#dump and MessagePack::Factory#load as convenient methods Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Encoder.java new/ext/java/org/msgpack/jruby/Encoder.java --- old/ext/java/org/msgpack/jruby/Encoder.java 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/java/org/msgpack/jruby/Encoder.java 2018-01-11 07:11:14.000000000 +0100 @@ -384,7 +384,7 @@ lookupClass = object.getSingletonClass(); } - IRubyObject[] pair = registry.lookupPackerByModule(lookupClass); + IRubyObject[] pair = registry.lookupPackerForObject(object); if (pair != null) { RubyString bytes = pair[0].callMethod(runtime.getCurrentContext(), "call", object).asString(); int type = (int) ((RubyFixnum) pair[1]).getLongValue(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/java/org/msgpack/jruby/ExtensionRegistry.java new/ext/java/org/msgpack/jruby/ExtensionRegistry.java --- old/ext/java/org/msgpack/jruby/ExtensionRegistry.java 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/java/org/msgpack/jruby/ExtensionRegistry.java 2018-01-11 07:11:14.000000000 +0100 @@ -5,6 +5,7 @@ import org.jruby.RubyArray; import org.jruby.RubyModule; import org.jruby.RubyFixnum; +import org.jruby.RubySymbol; import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; @@ -74,22 +75,50 @@ } } - public IRubyObject[] lookupPackerByModule(RubyModule mod) { + public IRubyObject[] lookupPackerForObject(IRubyObject object) { + RubyModule lookupClass = null; + IRubyObject[] pair; + /* + * Objects of type Integer (Fixnum, Bignum), Float, Symbol and frozen + * String have no singleton class and raise a TypeError when trying to get + * it. + * + * Since all but symbols are already filtered out when reaching this code + * only symbols are checked here. + */ + if (!(object instanceof RubySymbol)) { + lookupClass = object.getSingletonClass(); + pair = fetchEntryByModule(lookupClass); + if (pair != null) { + return pair; + } + } + + pair = fetchEntryByModule(object.getType()); + if (pair != null) { + return pair; + } + + if (lookupClass == null) { + lookupClass = object.getType(); // only for Symbol + } + ExtensionEntry e = findEntryByModuleOrAncestor(lookupClass); + if (e != null && e.hasPacker()) { + extensionsByAncestor.put(e.getExtensionModule(), e); + return e.toPackerProcTypeIdPair(lookupClass.getRuntime().getCurrentContext()); + } + return null; + } + + private IRubyObject[] fetchEntryByModule(final RubyModule mod) { ExtensionEntry e = extensionsByModule.get(mod); if (e == null) { e = extensionsByAncestor.get(mod); } - if (e == null) { - e = findEntryByModuleOrAncestor(mod); - if (e != null) { - extensionsByAncestor.put(e.getExtensionModule(), e); - } - } if (e != null && e.hasPacker()) { return e.toPackerProcTypeIdPair(mod.getRuntime().getCurrentContext()); - } else { - return null; } + return null; } private ExtensionEntry findEntryByModuleOrAncestor(final RubyModule mod) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/buffer_class.c new/ext/msgpack/buffer_class.c --- old/ext/msgpack/buffer_class.c 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/buffer_class.c 2018-01-11 07:11:14.000000000 +0100 @@ -54,7 +54,7 @@ static VALUE Buffer_alloc(VALUE klass) { - msgpack_buffer_t* b = ALLOC_N(msgpack_buffer_t, 1); + msgpack_buffer_t* b = ZALLOC_N(msgpack_buffer_t, 1); msgpack_buffer_init(b); return Data_Wrap_Struct(klass, msgpack_buffer_mark, Buffer_free, b); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/compat.h new/ext/msgpack/compat.h --- old/ext/msgpack/compat.h 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/compat.h 2018-01-11 07:11:14.000000000 +0100 @@ -29,6 +29,16 @@ /* + * ZALLOC_N (ruby 2.2 or later) + */ +#ifndef RB_ZALLOC_N +# define RB_ZALLOC_N(type,n) ((type*)ruby_xcalloc((size_t)(n),sizeof(type))) +#endif +#ifndef ZALLOC_N +# define ZALLOC_N(type,n) RB_ZALLOC_N(type,n) +#endif + +/* * COMPAT_HAVE_ENCODING */ #ifdef HAVE_RUBY_ENCODING_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/factory_class.c new/ext/msgpack/factory_class.c --- old/ext/msgpack/factory_class.c 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/factory_class.c 2018-01-11 07:11:14.000000000 +0100 @@ -59,10 +59,7 @@ static VALUE Factory_alloc(VALUE klass) { - msgpack_factory_t* fc = ALLOC_N(msgpack_factory_t, 1); - - msgpack_packer_ext_registry_init(&fc->pkrg); - msgpack_unpacker_ext_registry_init(&fc->ukrg); + msgpack_factory_t* fc = ZALLOC_N(msgpack_factory_t, 1); VALUE self = Data_Wrap_Struct(klass, Factory_mark, Factory_free, fc); return self; @@ -72,6 +69,9 @@ { FACTORY(self, fc); + msgpack_packer_ext_registry_init(&fc->pkrg); + msgpack_unpacker_ext_registry_init(&fc->ukrg); + fc->has_symbol_ext_type = false; switch (argc) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/packer.c new/ext/msgpack/packer.c --- old/ext/msgpack/packer.c 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/packer.c 2018-01-11 07:11:14.000000000 +0100 @@ -125,25 +125,7 @@ { int ext_type; - VALUE lookup_class; - - /* - * Objects of type Integer (Fixnum, Bignum), Float, Symbol and frozen - * String have no singleton class and raise a TypeError when trying to get - * it. See implementation of #singleton_class in ruby's source code: - * VALUE rb_singleton_class(VALUE obj); - * - * Since all but symbols are already filtered out when reaching this code - * only symbols are checked here. - */ - if (SYMBOL_P(v)) { - lookup_class = rb_obj_class(v); - } else { - lookup_class = rb_singleton_class(v); - } - - VALUE proc = msgpack_packer_ext_registry_lookup(&pk->ext_registry, lookup_class, - &ext_type); + VALUE proc = msgpack_packer_ext_registry_lookup(&pk->ext_registry, v, &ext_type); if(proc != Qnil) { VALUE payload = rb_funcall(proc, s_call, 1, v); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/packer_class.c new/ext/msgpack/packer_class.c --- old/ext/msgpack/packer_class.c 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/packer_class.c 2018-01-11 07:11:14.000000000 +0100 @@ -56,14 +56,12 @@ VALUE MessagePack_Packer_alloc(VALUE klass) { - msgpack_packer_t* pk = ALLOC_N(msgpack_packer_t, 1); + msgpack_packer_t* pk = ZALLOC_N(msgpack_packer_t, 1); msgpack_packer_init(pk); VALUE self = Data_Wrap_Struct(klass, Packer_mark, Packer_free, pk); msgpack_packer_set_to_msgpack_method(pk, s_to_msgpack, self); - msgpack_packer_ext_registry_init(&pk->ext_registry); - pk->buffer_ref = MessagePack_Buffer_wrap(PACKER_BUFFER_(pk), self); return self; } @@ -97,6 +95,9 @@ PACKER(self, pk); + msgpack_packer_ext_registry_init(&pk->ext_registry); + pk->buffer_ref = MessagePack_Buffer_wrap(PACKER_BUFFER_(pk), self); + MessagePack_Buffer_set_options(PACKER_BUFFER_(pk), io, options); if(options != Qnil) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/packer_ext_registry.h new/ext/msgpack/packer_ext_registry.h --- old/ext/msgpack/packer_ext_registry.h 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/packer_ext_registry.h 2018-01-11 07:11:14.000000000 +0100 @@ -59,24 +59,64 @@ return ST_CONTINUE; } - -static inline VALUE msgpack_packer_ext_registry_lookup(msgpack_packer_ext_registry_t* pkrg, +static inline VALUE msgpack_packer_ext_registry_fetch(msgpack_packer_ext_registry_t* pkrg, VALUE lookup_class, int* ext_type_result) { + // fetch lookup_class from hash, which is a hash to register classes VALUE type = rb_hash_lookup(pkrg->hash, lookup_class); if(type != Qnil) { *ext_type_result = FIX2INT(rb_ary_entry(type, 0)); return rb_ary_entry(type, 1); } + // fetch lookup_class from cache, which stores results of searching ancestors from pkrg->hash VALUE type_inht = rb_hash_lookup(pkrg->cache, lookup_class); if(type_inht != Qnil) { *ext_type_result = FIX2INT(rb_ary_entry(type_inht, 0)); return rb_ary_entry(type_inht, 1); } + return Qnil; +} + +static inline VALUE msgpack_packer_ext_registry_lookup(msgpack_packer_ext_registry_t* pkrg, + VALUE instance, int* ext_type_result) +{ + VALUE lookup_class; + VALUE type; + + /* + * 1. check whether singleton_class of this instance is registered (or resolved in past) or not. + * + * Objects of type Integer (Fixnum, Bignum), Float, Symbol and frozen + * String have no singleton class and raise a TypeError when trying to get + * it. See implementation of #singleton_class in ruby's source code: + * VALUE rb_singleton_class(VALUE obj); + * + * Since all but symbols are already filtered out when reaching this code + * only symbols are checked here. + */ + if (!SYMBOL_P(instance)) { + lookup_class = rb_singleton_class(instance); + + type = msgpack_packer_ext_registry_fetch(pkrg, lookup_class, ext_type_result); + + if(type != Qnil) { + return type; + } + } + + /* + * 2. check the class of instance is registered (or resolved in past) or not. + */ + type = msgpack_packer_ext_registry_fetch(pkrg, rb_obj_class(instance), ext_type_result); + + if(type != Qnil) { + return type; + } + /* - * check all keys whether it is an ancestor of lookup_class, or not + * 3. check all keys whether it is an ancestor of lookup_class, or not */ VALUE args[2]; args[0] = lookup_class; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/msgpack/unpacker_class.c new/ext/msgpack/unpacker_class.c --- old/ext/msgpack/unpacker_class.c 2017-12-07 04:21:29.000000000 +0100 +++ new/ext/msgpack/unpacker_class.c 2018-01-11 07:11:14.000000000 +0100 @@ -58,14 +58,10 @@ VALUE MessagePack_Unpacker_alloc(VALUE klass) { - msgpack_unpacker_t* uk = ALLOC_N(msgpack_unpacker_t, 1); + msgpack_unpacker_t* uk = ZALLOC_N(msgpack_unpacker_t, 1); _msgpack_unpacker_init(uk); VALUE self = Data_Wrap_Struct(klass, Unpacker_mark, Unpacker_free, uk); - - msgpack_unpacker_ext_registry_init(&uk->ext_registry); - uk->buffer_ref = MessagePack_Buffer_wrap(UNPACKER_BUFFER_(uk), self); - return self; } @@ -101,6 +97,9 @@ UNPACKER(self, uk); + msgpack_unpacker_ext_registry_init(&uk->ext_registry); + uk->buffer_ref = MessagePack_Buffer_wrap(UNPACKER_BUFFER_(uk), self); + MessagePack_Buffer_set_options(UNPACKER_BUFFER_(uk), io, options); if(options != Qnil) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/msgpack/version.rb new/lib/msgpack/version.rb --- old/lib/msgpack/version.rb 2017-12-07 04:21:29.000000000 +0100 +++ new/lib/msgpack/version.rb 2018-01-11 07:11:14.000000000 +0100 @@ -1,3 +1,3 @@ module MessagePack - VERSION = "1.2.0" + VERSION = "1.2.2" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2017-12-07 04:21:29.000000000 +0100 +++ new/metadata 2018-01-11 07:11:14.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: msgpack version: !ruby/object:Gem::Version - version: 1.2.0 + version: 1.2.2 platform: ruby authors: - Sadayuki Furuhashi @@ -10,7 +10,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2017-12-07 00:00:00.000000000 Z +date: 2018-01-11 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler @@ -239,7 +239,7 @@ version: '0' requirements: [] rubyforge_project: msgpack -rubygems_version: 2.6.13 +rubygems_version: 2.7.3 signing_key: specification_version: 4 summary: MessagePack, a binary-based efficient data interchange format. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/factory_spec.rb new/spec/factory_spec.rb --- old/spec/factory_spec.rb 2017-12-07 04:21:29.000000000 +0100 +++ new/spec/factory_spec.rb 2018-01-11 07:11:14.000000000 +0100 @@ -331,6 +331,19 @@ end end + describe 'under stressful GC' do + it 'works well' do + begin + GC.stress = true + + f = MessagePack::Factory.new + f.register_type(0x0a, Symbol) + ensure + GC.stress = false + end + end + end + describe 'DefaultFactory' do it 'is a factory' do MessagePack::DefaultFactory.should be_kind_of(MessagePack::Factory) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/packer_spec.rb new/spec/packer_spec.rb --- old/spec/packer_spec.rb 2017-12-07 04:21:29.000000000 +0100 +++ new/spec/packer_spec.rb 2018-01-11 07:11:14.000000000 +0100 @@ -372,6 +372,50 @@ end end + context 'when it and its super class has an ext type' do + before { stub_const('Value', Class.new) } + before do + Value.class_eval do + def to_msgpack_ext + 'value_msgpacked' + end + end + end + before { packer.register_type(0x01, Value, :to_msgpack_ext) } + + context "when it is a child class" do + before { stub_const('InheritedValue', Class.new(Value)) } + before do + InheritedValue.class_eval do + def to_msgpack_ext + 'inherited_value_msgpacked' + end + end + end + + before { packer.register_type(0x02, InheritedValue, :to_msgpack_ext) } + subject { packer.pack(InheritedValue.new).to_s } + + it { is_expected.to eq "\xC7\x19\x02inherited_value_msgpacked" } + end + + context "even when it is a child class" do + before { stub_const('InheritedValue', Class.new(Value)) } + before do + InheritedValue.class_eval do + def to_msgpack_ext + 'inherited_value_msgpacked' + end + end + end + + before { packer.register_type(0x02, InheritedValue, :to_msgpack_ext) } + subject { packer.pack(Value.new).to_s } + + it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" } + end + end + context 'when it has no ext type but an included module has' do subject { packer.pack(Value.new).to_s }