yeptris 0.6.33.1-aarch64-linux → 0.6.33.2-aarch64-linux

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: aa8d3b78ec99584df719ea52b83de134ccec4b1c5c00dabbfd54e2850c2789c5
4
- data.tar.gz: f259f9122e64be66be515aa9e41a8bf8d74bec2aeaf4f6a6f9855ed416c899b4
3
+ metadata.gz: 4f539306a31099d38b0040d34986abe9aecaf7f4f7950f78fbd828002d0d186d
4
+ data.tar.gz: a325b02fec0989a9d21ee8615c7993d05e9a9b2f7062a64560656a4699160109
5
5
  SHA512:
6
- metadata.gz: 5bf5c78083f143525812c7d41ec69b515a9836f0f061e6a621c1b4f7a63a6d89e54eccf11cdda6c9cbc35943637d946cf39a2f06126d19e97acbe6495a1fe6fc
7
- data.tar.gz: 2ff20e717f4351f3b74305464ceb7deab18442090748d5d79504574639df0ef9ee42149b426e813ca683daf2bec620472f3791b194820e8888ad004209da0709
6
+ metadata.gz: 0ac10a304643b6fa2dd77979974b0809c6032c8918a9c9a9e192667e479338f0b037a45f1c240e20dccb110f354d46854c3cde5414d14a861a9577b353baba83
7
+ data.tar.gz: 1ba4bb2d25f6c2cbca95360336b8a8827533dace201394f8f92c2cea6395743bee00613963aa650ea2e9cafdc4ff647e7a5db4b251b25086a85491bfee6c6349
data/README.adoc CHANGED
@@ -5,6 +5,15 @@ https://github.com/leptris/yeptris[libyeptris] — the YAML counterpart
5
5
  of libleptris. Psych-compatible semantics, one shared library, zero
6
6
  compilation at install.
7
7
 
8
+ Part of the yeptris program: *the best (multiple dimensions)
9
+ YAML/JSON parser/builder ever* — conformance, performance,
10
+ safety/hardening, API surfaces, transport correctness, and trust,
11
+ held simultaneously, in C, Ruby, Rust, and JS. This binding is the
12
+ most complete surface: the Psych drop-in namespace, JSON.parse
13
+ parity with the strict duplicate-key contract, CBOR, and ValueML,
14
+ tracking every libyeptris release in lockstep. The achievement
15
+ program lives in the engine's PLAN.md ("The best-ever program").
16
+
8
17
  == Install (development)
9
18
 
10
19
  The gem loads a shared `libyeptris` — from `YEPTRIS_LIB_PATH`, a
@@ -173,9 +173,19 @@ static VALUE jr_object(jr* j) {
173
173
  }
174
174
 
175
175
  static VALUE jr_object_body(jr* j, VALUE h_pre) {
176
+ /* The pairs staging buffer MUST live in GC-scanned memory: pairs
177
+ * beyond the current one exist only there once the key/val locals
178
+ * are reused, so a malloc'd buffer makes them invisible to the
179
+ * collector — it can free them mid-parse and recycle their slots,
180
+ * and rb_hash_bulk_insert then inserts garbage (yeptris-ruby#279:
181
+ * the arm64-darwin SIGSEGV whose fault address was document text).
182
+ * The stack array IS scanned, so the bulk fast path is bounded at
183
+ * 31 pairs; beyond that the buffered pairs flush with one
184
+ * bulk_insert and the rest of the object rides rb_hash_aset. */
176
185
  VALUE pairs[64];
177
186
  VALUE* pv = pairs;
178
187
  size_t pcap = 64, pn = 0, heap_cap = 0;
188
+ int aset_rest = 0;
179
189
  for (;;) {
180
190
  jr_ws(j);
181
191
  if (j->i >= j->len || j->p[j->i] != '"') { j->err = -2; goto out; }
@@ -186,7 +196,7 @@ static VALUE jr_object_body(jr* j, VALUE h_pre) {
186
196
  j->i++;
187
197
  VALUE val = jr_value(j);
188
198
  if (j->err) goto out;
189
- if (yep_ins_mode == YEP_INS_ASET || j->strict_dup) {
199
+ if (yep_ins_mode == YEP_INS_ASET || j->strict_dup || aset_rest) {
190
200
  VALUE h = h_pre == Qundef ? (h_pre = HASH_NEW_CAPA(8)) : h_pre;
191
201
  if (j->strict_dup && !NIL_P(rb_hash_aref(h, key))) {
192
202
  j->err = -3;
@@ -196,15 +206,21 @@ static VALUE jr_object_body(jr* j, VALUE h_pre) {
196
206
  rb_hash_aset(h, key, val);
197
207
  } else {
198
208
  if (pn + 2 > pcap) {
199
- size_t ncap = pcap * 2;
200
- VALUE* nv = malloc(ncap * sizeof(VALUE));
201
- if (!nv) { j->err = -1; goto out; }
202
- memcpy(nv, pv, pn * sizeof(VALUE));
203
- if (pv != pairs) { free(pv); heap_cap = 1; }
204
- pv = nv; pcap = ncap;
209
+ /* buffer full: flush what is staged (no heap staging —
210
+ * see the #279 note above); THIS pair and the rest of
211
+ * the object ride aset — no continue here, the
212
+ * delimiter scan below must still run */
213
+ VALUE h = (h_pre == Qundef) ? (h_pre = HASH_NEW_CAPA((long)(pn / 2) + 8)) : h_pre;
214
+ rb_hash_bulk_insert((long)pn, (const VALUE*)pv, h);
215
+ pn = 0;
216
+ aset_rest = 1;
217
+ }
218
+ if (aset_rest) {
219
+ rb_hash_aset(h_pre, key, val);
220
+ } else {
221
+ pv[pn++] = key;
222
+ pv[pn++] = val;
205
223
  }
206
- pv[pn++] = key;
207
- pv[pn++] = val;
208
224
  }
209
225
  jr_ws(j);
210
226
  if (j->i >= j->len) { j->err = -2; goto out; }
@@ -351,7 +367,17 @@ double yep_rb_scan_time(const char* p, size_t len, int n) {
351
367
  VALUE yep_rb_parse_json(const char* p, size_t len, int strict_dup) {
352
368
  jr j;
353
369
  memset(&j, 0, sizeof(j));
354
- j.p = p; j.len = len; j.enc = rb_utf8_encoding();
370
+ /* The parse holds j.p across unbounded allocations, and the GC
371
+ * strategy knobs leave collection ENABLED during the window
372
+ * (arm64's default is none). A compaction moving the source
373
+ * string would dangle every j->p read after the move
374
+ * (yeptris-ruby#279's heap-layout-dependent SIGSEGV class), so
375
+ * the parse runs on a private copy: one memcpy of the input,
376
+ * then no Ruby object backs the cursor. */
377
+ char* own = malloc(len ? len : 1);
378
+ if (own == NULL) rb_raise(rb_eNoMemError, "yeptris native json");
379
+ memcpy(own, p, len);
380
+ j.p = own; j.len = len; j.enc = rb_utf8_encoding();
355
381
  j.strict_dup = strict_dup;
356
382
  VALUE already = Qtrue;
357
383
  if (yep_gc_mode != YEP_GC_NONE) already = rb_gc_disable();
@@ -359,6 +385,7 @@ VALUE yep_rb_parse_json(const char* p, size_t len, int strict_dup) {
359
385
  jr_ws(&j);
360
386
  if (j.i != len && j.err == 0) j.err = -2;
361
387
  free(j.scratch);
388
+ free(own);
362
389
  if (already == Qfalse) rb_gc_enable();
363
390
  if (yep_gc_mode == YEP_GC_START && j.err == 0) rb_gc_start();
364
391
  if (j.err == -1) rb_raise(rb_eNoMemError, "yeptris native json");
@@ -366,6 +393,11 @@ VALUE yep_rb_parse_json(const char* p, size_t len, int strict_dup) {
366
393
  rb_raise(rb_path2class("Yeptris::ParseError"), "duplicate key \"%s\" in JSON object",
367
394
  RSTRING_PTR(j.dup_key));
368
395
  }
369
- if (j.err != 0) rb_raise(rb_path2class("Yeptris::ParseError"), "native json parse failed");
396
+ if (j.err != 0) {
397
+ /* the tape engine's wording ("not strict JSON at byte N") so
398
+ * consumers can pin one error shape across both routes
399
+ * (yeptris-ruby#279's adjacent note) */
400
+ rb_raise(rb_path2class("Yeptris::ParseError"), "not strict JSON at byte %zu", j.i);
401
+ }
370
402
  return v;
371
403
  }
Binary file
Binary file
Binary file
data/lib/yeptris/ffi.rb CHANGED
@@ -228,12 +228,17 @@ module Yeptris
228
228
  %i[pointer size_t int int pointer pointer], :int
229
229
  attach_function :yeptris_marshal_node,
230
230
  %i[yeptris_node pointer pointer], :int
231
+ attach_function :yeptris_marshal_node_ex,
232
+ %i[yeptris_node uint32 pointer pointer], :int
231
233
  attach_function :yeptris_marshal_free, [:pointer], :void
232
234
  # The bulk child drain (#168's quadratic): O(n) iteration for
233
235
  # #each/#each_pair. Engines without it fall back to the per-index
234
236
  # walk (correct, quadratic).
235
237
  CHILDREN_DRAIN = !(@missing ||= []).include?(:yeptris_node_children)
236
238
  MARSHAL = !(@missing ||= []).include?(:yeptris_marshal_node)
239
+ # the strict-dup marshal entry (engine 0.6.34+, yeptris-ruby#278):
240
+ # gates the JSON fallback's C route in STRICT mode
241
+ MARSHAL_STRICT_DUP = !(@missing ||= []).include?(:yeptris_marshal_node_ex)
237
242
 
238
243
  # bulk build (TODO.impl/15 phase D): one call raises a document
239
244
  BUILD_SCALAR = 1
data/lib/yeptris/json.rb CHANGED
@@ -9,10 +9,13 @@ module Yeptris
9
9
  # keeps the Psych contract for every input (JSON-shaped included),
10
10
  # so the two never drift into each other's semantics.
11
11
  #
12
- # Engines, fastest first (both exact — the parity spec runs against
12
+ # Engines, fastest first (all exact — the parity spec runs against
13
13
  # whichever is loaded):
14
14
  # 1. the native materializer (fused C scan → VALUE; opt-in build)
15
- # 2. the record drain + strict conversion walk (always available)
15
+ # 2. the marshal engine (#278): strict-JSON parse + Marshal 4.8
16
+ # emission + ONE core Marshal.load — all C, no per-value Ruby
17
+ # (engine 0.6.34+; the strict flag follows the resolved json gem)
18
+ # 3. the record drain + strict conversion walk (always available)
16
19
  module JSON
17
20
  class Error < ::Yeptris::Error; end
18
21
  class ParseError < Error; end
@@ -39,9 +42,46 @@ module Yeptris
39
42
  raise ParseError, e.message
40
43
  end
41
44
  end
45
+ # yeptris-ruby#278: with no Ruby-version-matched native build the
46
+ # pure-Ruby walk measured 0.11x vs JSON.parse on real documents —
47
+ # the marshal engine keeps the fallback C-side end to end.
48
+ return marshal_engine(source, 0) if ::Yeptris::FFI::MARSHAL_STRICT_DUP
42
49
  tape_engine(source)
43
50
  end
44
51
 
52
+ # The marshal engine (#278): yeptris_parse_json gates the strict
53
+ # grammar, yeptris_marshal_node_ex writes the Ruby Marshal 4.8
54
+ # stream (STRICT_DUP_KEYS raising on json 3's default contract),
55
+ # and ONE core Marshal.load materializes the graph. Returns nil
56
+ # when the engine cannot serve the route (caller keeps walking);
57
+ # every parse/dup failure raises ParseError.
58
+ def marshal_engine(source, flags)
59
+ begin
60
+ gate = ::Yeptris::Document.parse_json(source)
61
+ rescue ::Yeptris::ParseError => e
62
+ raise ParseError, e.message
63
+ end
64
+ begin
65
+ out_p = ::FFI::MemoryPointer.new(:pointer)
66
+ olen_p = ::FFI::MemoryPointer.new(:size_t)
67
+ st = ::Yeptris::FFI.yeptris_marshal_node_ex(
68
+ ::Yeptris::FFI.yeptris_document_root(gate.c_ptr, 0), flags, out_p, olen_p
69
+ )
70
+ if st != ::Yeptris::FFI::OK
71
+ raise ParseError, ::Yeptris::FFI.last_error_message if st == ::Yeptris::FFI::ERROR_PARSE
72
+
73
+ return nil # UNSUPPORTED: merge keys et al. cannot occur in JSON
74
+ end
75
+ buf = out_p.read_pointer
76
+ data = buf.read_bytes(::Yeptris::FFI.read_c_size_t(olen_p))
77
+ data.force_encoding(Encoding::ASCII_8BIT)
78
+ ::Yeptris::FFI.yeptris_marshal_free(buf)
79
+ Marshal.load(data)
80
+ ensure
81
+ gate.free
82
+ end
83
+ end
84
+
45
85
  # The tape engine (issue #81): ONE call validates and materializes
46
86
  # the record stream; the walk reads four bulk columns and slices
47
87
  # strings straight out of the caller's source — no gate document,
@@ -212,6 +252,12 @@ module Yeptris
212
252
  raise ParseError, e.message
213
253
  end
214
254
  begin
255
+ if ::Yeptris::FFI::MARSHAL_STRICT_DUP
256
+ routed = marshal_engine(
257
+ source, STRICT_DUPLICATE_KEYS ? ::Yeptris::FFI::MARSHAL_STRICT_DUP_KEYS : 0
258
+ )
259
+ return routed unless routed.nil?
260
+ end
215
261
  cols = ::Yeptris::FFI::ValueColumns.new
216
262
  st = ::Yeptris::FFI.yeptris_value_drain_columns(
217
263
  source, source.bytesize, ::Yeptris::FFI::SCHEMA_12_CORE, cols
data/lib/yeptris.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Yeptris
4
4
  # The gem's version lives in the parent namespace's file — the last
5
5
  # internal require (yeptris/version) retired with it.
6
- VERSION = "0.6.33.1".freeze
6
+ VERSION = "0.6.33.2".freeze
7
7
 
8
8
  # Informational notices are OPT-IN (yeptris-ruby#217): consumers
9
9
  # embed yeptris inside CLIs that assert clean stderr, and a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.33.1
4
+ version: 0.6.33.2
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-19 00:00:00.000000000 Z
11
+ date: 2026-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi