msgpack 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1414cbfba4f8503d851d6084ef42eb39cfe652d0cadedcf75523e5f472bf425b
4
- data.tar.gz: a863d42ac8880a77afe84398b103f4b27d0782db70dd31aad4c785759bcfa20f
3
+ metadata.gz: c2caf680ff4cafade89a14da270f52528ba2a862cea237ad028ba27fa6a93e9b
4
+ data.tar.gz: 01d8cc906d925acbd32a88c22f6ace7f5534a0b447be1736ea58cfdf9abb85b6
5
5
  SHA512:
6
- metadata.gz: 9ffd9d63c8354684cedfcd682beaf525823646aa9b0b6854175e81f1879eea22fcbf3fba560744210129001263ff80b2fc83ebc99a7405d9f03570921567b1d7
7
- data.tar.gz: 4bd0b851caa3d39c05e32d6d90f9f52c376aae4f799247d3d9569db9bc273171c85973e6229de6b9c55e956e2f8c9790a9a4c23e8482944233ed499b421f30c6
6
+ metadata.gz: 48fcd12bfb13741d88a17e1a261cd742c903ba53cb1959a88b7083c2344817d90cfa898e775c136d785fbfcdd76be14b6dc5fc8ba3638a13ecabbb2d1387dbee
7
+ data.tar.gz: 310f3ea573cf41b15c47bc0033121496bd8ab7a723ef3667a96a38bc286feb79536ac5aeb8d27c3c71568149f93c8f36cc9ca8e050595e27ff87762cbccfe2dd
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2023-05-19 1.7.1:
2
+
3
+ * Fix JRuby 9.4 compatibility.
4
+ * Fix compilation on older compilers (gcc 4.x).
5
+ * Fix an infinite recursion issue when registering a Symbol type with a `nil` packer.
6
+
1
7
  2023-03-29 1.7.0:
2
8
 
3
9
  * Fix a possible double-free issue when GC triggers inside `_msgpack_rmem_alloc2`.
@@ -22,10 +22,10 @@ import org.jcodings.Encoding;
22
22
  @JRubyClass(name="MessagePack::Buffer")
23
23
  public class Buffer extends RubyObject {
24
24
  private static final long serialVersionUID = 8441244627425629412L;
25
- private IRubyObject io;
26
- private ByteBuffer buffer;
25
+ private transient IRubyObject io;
26
+ private transient ByteBuffer buffer;
27
27
  private boolean writeMode;
28
- private Encoding binaryEncoding;
28
+ private transient Encoding binaryEncoding;
29
29
 
30
30
  private static final int CACHE_LINE_SIZE = 64;
31
31
  private static final int ARRAY_HEADER_SIZE = 24;
@@ -141,11 +141,11 @@ public class ExtensionRegistry {
141
141
  }
142
142
 
143
143
  public boolean hasPacker() {
144
- return packerProc != null;
144
+ return packerProc != null && !packerProc.isNil();
145
145
  }
146
146
 
147
147
  public boolean hasUnpacker() {
148
- return unpackerProc != null;
148
+ return unpackerProc != null && !unpackerProc.isNil();
149
149
  }
150
150
 
151
151
  public IRubyObject getPackerProc() {
@@ -26,7 +26,7 @@ import static org.msgpack.jruby.Types.*;
26
26
  @JRubyClass(name="MessagePack::ExtensionValue")
27
27
  public class ExtensionValue extends RubyObject {
28
28
  private static final long serialVersionUID = 8451274621449322492L;
29
- private final Encoding binaryEncoding;
29
+ private transient final Encoding binaryEncoding;
30
30
 
31
31
  private RubyFixnum type;
32
32
  private RubyString payload;
@@ -26,8 +26,8 @@ import static org.jruby.runtime.Visibility.PRIVATE;
26
26
  @JRubyClass(name="MessagePack::Factory")
27
27
  public class Factory extends RubyObject {
28
28
  private static final long serialVersionUID = 8441284623445322492L;
29
- private final Ruby runtime;
30
- private ExtensionRegistry extensionRegistry;
29
+ private transient final Ruby runtime;
30
+ private transient ExtensionRegistry extensionRegistry;
31
31
  private boolean hasSymbolExtType;
32
32
  private boolean hasBigIntExtType;
33
33
 
@@ -82,6 +82,8 @@ public class Factory extends RubyObject {
82
82
 
83
83
  @JRubyMethod(name = "register_type", required = 2, optional = 1)
84
84
  public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args) {
85
+ testFrozen("MessagePack::Factory");
86
+
85
87
  Ruby runtime = ctx.runtime;
86
88
  IRubyObject type = args[0];
87
89
  IRubyObject mod = args[1];
@@ -91,10 +93,6 @@ public class Factory extends RubyObject {
91
93
 
92
94
  RubyHash options = null;
93
95
 
94
- if (isFrozen()) {
95
- throw runtime.newFrozenError("MessagePack::Factory");
96
- }
97
-
98
96
  if (args.length == 2) {
99
97
  packerArg = runtime.newSymbol("to_msgpack_ext");
100
98
  unpackerArg = runtime.newSymbol("from_msgpack_ext");
@@ -102,7 +100,13 @@ public class Factory extends RubyObject {
102
100
  if (args[args.length - 1] instanceof RubyHash) {
103
101
  options = (RubyHash) args[args.length - 1];
104
102
  packerArg = options.fastARef(runtime.newSymbol("packer"));
103
+ if (packerArg != null && packerArg.isNil()) {
104
+ packerArg = null;
105
+ }
105
106
  unpackerArg = options.fastARef(runtime.newSymbol("unpacker"));
107
+ if (unpackerArg != null && unpackerArg.isNil()) {
108
+ unpackerArg = null;
109
+ }
106
110
  IRubyObject optimizedSymbolsParsingArg = options.fastARef(runtime.newSymbol("optimized_symbols_parsing"));
107
111
  if (optimizedSymbolsParsingArg != null && optimizedSymbolsParsingArg.isTrue()) {
108
112
  throw runtime.newArgumentError("JRuby implementation does not support the optimized_symbols_parsing option");
@@ -149,7 +153,7 @@ public class Factory extends RubyObject {
149
153
 
150
154
  extensionRegistry.put(extModule, (int) typeId, recursive, packerProc, packerArg, unpackerProc, unpackerArg);
151
155
 
152
- if (extModule == runtime.getSymbol()) {
156
+ if (extModule == runtime.getSymbol() && !packerProc.isNil()) {
153
157
  hasSymbolExtType = true;
154
158
  }
155
159
 
@@ -28,12 +28,12 @@ import static org.jruby.runtime.Visibility.PRIVATE;
28
28
  @JRubyClass(name="MessagePack::Packer")
29
29
  public class Packer extends RubyObject {
30
30
  private static final long serialVersionUID = 8451274621499362492L;
31
- public ExtensionRegistry registry;
31
+ public transient ExtensionRegistry registry;
32
32
  private Buffer buffer;
33
- private Encoder encoder;
33
+ private transient Encoder encoder;
34
34
  private boolean hasSymbolExtType;
35
35
  private boolean hasBigintExtType;
36
- private Encoding binaryEncoding;
36
+ private transient Encoding binaryEncoding;
37
37
 
38
38
  public Packer(Ruby runtime, RubyClass type, ExtensionRegistry registry, boolean hasSymbolExtType, boolean hasBigintExtType) {
39
39
  super(runtime, type);
@@ -95,10 +95,9 @@ public class Packer extends RubyObject {
95
95
 
96
96
  @JRubyMethod(name = "register_type", required = 2, optional = 1)
97
97
  public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args, final Block block) {
98
+ testFrozen("MessagePack::Packer");
99
+
98
100
  Ruby runtime = ctx.runtime;
99
- if (isFrozen()) {
100
- throw runtime.newFrozenError("MessagePack::Packer");
101
- }
102
101
  IRubyObject type = args[0];
103
102
  IRubyObject mod = args[1];
104
103
 
@@ -129,7 +128,7 @@ public class Packer extends RubyObject {
129
128
 
130
129
  registry.put(extModule, (int) typeId, false, proc, arg, null, null);
131
130
 
132
- if (extModule == runtime.getSymbol()) {
131
+ if (extModule == runtime.getSymbol() && !proc.isNil()) {
133
132
  encoder.hasSymbolExtType = true;
134
133
  }
135
134
 
@@ -21,18 +21,17 @@ import org.jruby.runtime.ThreadContext;
21
21
  import org.jruby.anno.JRubyClass;
22
22
  import org.jruby.anno.JRubyMethod;
23
23
  import org.jruby.util.ByteList;
24
- import org.jruby.ext.stringio.StringIO;
25
24
 
26
25
  import static org.jruby.runtime.Visibility.PRIVATE;
27
26
 
28
27
  @JRubyClass(name="MessagePack::Unpacker")
29
28
  public class Unpacker extends RubyObject {
30
29
  private static final long serialVersionUID = 8451264671199362492L;
31
- private final ExtensionRegistry registry;
30
+ private transient final ExtensionRegistry registry;
32
31
 
33
- private IRubyObject stream;
34
- private IRubyObject data;
35
- private Decoder decoder;
32
+ private transient IRubyObject stream;
33
+ private transient IRubyObject data;
34
+ private transient Decoder decoder;
36
35
  private final RubyClass underflowErrorClass;
37
36
  private boolean symbolizeKeys;
38
37
  private boolean freeze;
@@ -129,10 +128,9 @@ public class Unpacker extends RubyObject {
129
128
 
130
129
  @JRubyMethod(name = "register_type", required = 1, optional = 2)
131
130
  public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args, final Block block) {
131
+ testFrozen("MessagePack::Unpacker");
132
+
132
133
  Ruby runtime = ctx.runtime;
133
- if (isFrozen()) {
134
- throw runtime.newFrozenError("MessagePack::Unpacker");
135
- }
136
134
  IRubyObject type = args[0];
137
135
 
138
136
  RubyModule extModule;
@@ -334,9 +332,7 @@ public class Unpacker extends RubyObject {
334
332
  @JRubyMethod(name = "stream=", required = 1)
335
333
  public IRubyObject setStream(ThreadContext ctx, IRubyObject stream) {
336
334
  RubyString str;
337
- if (stream instanceof StringIO) {
338
- str = stream.callMethod(ctx, "string").asString();
339
- } else if (stream instanceof RubyIO) {
335
+ if (stream instanceof RubyIO) {
340
336
  str = stream.callMethod(ctx, "read").asString();
341
337
  } else if (stream.respondsTo("read")) {
342
338
  str = stream.callMethod(ctx, "read").asString();
@@ -5,15 +5,20 @@ have_header("st.h")
5
5
  have_func("rb_enc_interned_str", "ruby.h") # Ruby 3.0+
6
6
  have_func("rb_hash_new_capa", "ruby.h") # Ruby 3.2+
7
7
 
8
- $CFLAGS << " -fvisibility=hidden "
8
+ append_cflags([
9
+ "-fvisibility=hidden",
10
+ "-I..",
11
+ "-Wall",
12
+ "-O3",
13
+ "-std=gnu99"
14
+ ])
15
+ append_cflags(RbConfig::CONFIG["debugflags"]) if RbConfig::CONFIG["debugflags"]
9
16
 
10
- unless RUBY_PLATFORM.include? 'mswin'
11
- $CFLAGS << %[ -I.. -Wall -O3 #{RbConfig::CONFIG["debugflags"]} -std=gnu99]
12
- end
17
+ append_cflags("-DRUBY_DEBUG=1") if ENV["MSGPACK_DEBUG"]
13
18
 
14
19
  if RUBY_VERSION.start_with?('3.0.') && RUBY_VERSION <= '3.0.5'
15
20
  # https://bugs.ruby-lang.org/issues/18772
16
- $CFLAGS << ' -DRB_ENC_INTERNED_STR_NULL_CHECK=1 '
21
+ append_cflags("-DRB_ENC_INTERNED_STR_NULL_CHECK=1")
17
22
  end
18
23
 
19
24
  # checking if Hash#[]= (rb_hash_aset) dedupes string keys (Ruby 2.6+)
@@ -23,21 +28,21 @@ r = rand.to_s
23
28
  h[%W(#{r}).join('')] = :foo
24
29
  x[%W(#{r}).join('')] = :foo
25
30
  if x.keys[0].equal?(h.keys[0])
26
- $CFLAGS << ' -DHASH_ASET_DEDUPE=1 '
31
+ append_cflags("-DHASH_ASET_DEDUPE=1")
27
32
  else
28
- $CFLAGS << ' -DHASH_ASET_DEDUPE=0 '
33
+ append_cflags("-DHASH_ASET_DEDUPE=0")
29
34
  end
30
35
 
31
36
  # checking if String#-@ (str_uminus) directly interns frozen strings... ' (Ruby 3.0+)
32
37
  begin
33
38
  s = rand.to_s.freeze
34
39
  if (-s).equal?(s) && (-s.dup).equal?(s)
35
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
40
+ append_cflags("-DSTR_UMINUS_DEDUPE_FROZEN=1")
36
41
  else
37
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
42
+ append_cflags("-DSTR_UMINUS_DEDUPE_FROZEN=0")
38
43
  end
39
44
  rescue NoMethodError
40
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
45
+ append_cflags("-DSTR_UMINUS_DEDUPE_FROZEN=0")
41
46
  end
42
47
 
43
48
  if warnflags = CONFIG['warnflags']
@@ -222,11 +222,12 @@ static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
222
222
  unpacker_arg = ID2SYM(rb_intern("from_msgpack_ext"));
223
223
  break;
224
224
  case 3:
225
- /* register_type(0x7f, Time, packer: proc-like, unapcker: proc-like) */
225
+ /* register_type(0x7f, Time, packer: proc-like, unpacker: proc-like) */
226
226
  options = argv[2];
227
227
  if(rb_type(options) != T_HASH) {
228
228
  rb_raise(rb_eArgError, "expected Hash but found %s.", rb_obj_classname(options));
229
229
  }
230
+
230
231
  packer_arg = rb_hash_aref(options, ID2SYM(rb_intern("packer")));
231
232
  unpacker_arg = rb_hash_aref(options, ID2SYM(rb_intern("unpacker")));
232
233
  break;
@@ -266,7 +267,9 @@ static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
266
267
  }
267
268
 
268
269
  if(ext_module == rb_cSymbol) {
269
- fc->has_symbol_ext_type = true;
270
+ if(NIL_P(options) || RTEST(rb_hash_aref(options, ID2SYM(rb_intern("packer"))))) {
271
+ fc->has_symbol_ext_type = true;
272
+ }
270
273
  if(RTEST(options) && RTEST(rb_hash_aref(options, ID2SYM(rb_intern("optimized_symbols_parsing"))))) {
271
274
  fc->optimized_symbol_ext_type = true;
272
275
  }
@@ -233,7 +233,12 @@ static VALUE Packer_write_extension(VALUE self, VALUE obj)
233
233
  msgpack_packer_t *pk = MessagePack_Packer_get(self);
234
234
  Check_Type(obj, T_STRUCT);
235
235
 
236
- int ext_type = FIX2INT(RSTRUCT_GET(obj, 0));
236
+ VALUE rb_ext_type = RSTRUCT_GET(obj, 0);
237
+ if(!RB_TYPE_P(rb_ext_type, T_FIXNUM)) {
238
+ rb_raise(rb_eRangeError, "integer %s too big to convert to `signed char'", RSTRING_PTR(rb_String(rb_ext_type)));
239
+ }
240
+
241
+ int ext_type = FIX2INT(rb_ext_type);
237
242
  if(ext_type < -128 || ext_type > 127) {
238
243
  rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
239
244
  }
@@ -19,11 +19,7 @@
19
19
  #include "unpacker.h"
20
20
  #include "rmem.h"
21
21
  #include "extension_value_class.h"
22
-
23
- _Static_assert(
24
- sizeof(msgpack_unpacker_stack_entry_t) * MSGPACK_UNPACKER_STACK_CAPACITY <= MSGPACK_RMEM_PAGE_SIZE,
25
- "msgpack_unpacker_stack_entry_t is too big to fit MSGPACK_UNPACKER_STACK_CAPACITY in MSGPACK_RMEM_PAGE_SIZE"
26
- );
22
+ #include <assert.h>
27
23
 
28
24
  static int RAW_TYPE_STRING = 256;
29
25
  static int RAW_TYPE_BINARY = 257;
@@ -41,6 +37,8 @@ static inline VALUE rb_hash_new_capa(long capa)
41
37
 
42
38
  void msgpack_unpacker_static_init(void)
43
39
  {
40
+ assert(sizeof(msgpack_unpacker_stack_entry_t) * MSGPACK_UNPACKER_STACK_CAPACITY <= MSGPACK_RMEM_PAGE_SIZE);
41
+
44
42
  msgpack_rmem_init(&s_stack_rmem);
45
43
 
46
44
  s_call = rb_intern("call");
@@ -1,5 +1,5 @@
1
1
  module MessagePack
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  # Note for maintainers:
4
4
  # Don't miss building/releasing the JRuby version (rake buld:java)
5
5
  # See "How to build -java rubygems" in README for more details.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-03-29 00:00:00.000000000 Z
13
+ date: 2023-05-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.4.6
211
+ rubygems_version: 3.1.2
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: MessagePack, a binary-based efficient data interchange format.