leptris 1.9.421.0-arm-linux → 1.9.423.0-arm-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: 0bc10dde1df0dc4bda566ef868c728031c302efea5ab315525a6e86133f80ace
4
- data.tar.gz: 42a5e27e7176b2247206ce06fe8e6c316ddd2c734ef93f2d6fe1d4600a7f3409
3
+ metadata.gz: 4c656a55cb79583d06041a37bce0f905401da7d5a6fd6e59700c5a81e3eb90b0
4
+ data.tar.gz: 0f9755c81a030263728a8559f5c6431161fe5afc82731928ac170145cbb31ada
5
5
  SHA512:
6
- metadata.gz: bdda1e3f6391bd7ccaa919f9815e96c195a4604218298eed1dbde046a659ad3f4ce90e1fa5a67ce60e2f0aac79d75fb7a38a82f59891934cf1d354e46a81c404
7
- data.tar.gz: a76d4b709ead39d7b688cda95cade4831ba7a9dc4feb4d4d5aa59d300a4a53f70c3a651f3f42afe2f233ce3259e3f91c6b59d1131aeb01a530027fa54ebe9e96
6
+ metadata.gz: a19705c3ffb07b18779cb4b0e6ac579833c8f75bd60ce9c8a14ba5a57a5b863cd9fb1dae0bf25c6b0029dd851977b18c5658e4e56b8236ff6150296c3112fd23
7
+ data.tar.gz: 2ac3406e7962ed1485c021920021b3316d81ea51f6cba775f39a8d462dd85f5a427bdf60ce721ce9d5a481c08b7d760ed1fc0a6da1e092aef4ae9bb327ddbba2
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # Pin for `rake compile` and the platform-gem builds. Keep in lockstep
9
9
  # with .github/workflows/build.yml (which calls `rake compile`) and the
10
10
  # CHANGELOG when libleptris releases.
11
- LIBLEPTRIS_VERSION = "1.9.421"
11
+ LIBLEPTRIS_VERSION = "1.9.423"
12
12
  # Vendored alongside libleptris for fn:normalize-unicode (TODO
13
13
  # .restructure/20): built per platform with a RELOCATABLE @rpath
14
14
  # install name, loaded by ffi.rb before libleptris so the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.421.0"
4
+ VERSION = "1.9.423.0"
5
5
  end
data/lib/libleptris.so CHANGED
Binary file
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.421
4
+ - libleptris v1.9.423
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,31 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.423] - 2026-11-15
4
+
5
+ ### Fixed
6
+
7
+ - **simd: the AVX2 canary compiles on MinGW** — the #2039 canary (1.9.422) used POSIX `sigsetjmp`/`siglongjmp` unconditionally; MinGW's GCC provides neither, and every mingw build of the engine (the leptris-py native-ops probe, mingw Ruby builds) failed with `unknown type name 'sigjmp_buf'`. The canary block and its call site are now gated on POSIX (`!_WIN32`); MinGW keeps the CPUID-only verdict — its targets run real AVX2 hardware or the MSVC baseline, not the Rosetta/QEMU emulation the canary guards against. All other platforms unchanged: the canary still fires under Rosetta (re-verified on the failing platform after the regate).
8
+
9
+
10
+ ## [1.9.422] - 2026-11-15
11
+
12
+ ### Fixed
13
+
14
+ - **xsd: the XSD 1.1 versioning namespace was wrong — every `vc`-marked schema compiled as 1.0** (moxml#556). The version probe looked for `vc:minVersion` in `http://www.w3.org/2001/XMLSchema-versioning`; the namespace per XSD 1.1 §4.3 is **`http://www.w3.org/2007/XMLSchema-versioning`**. The probe therefore missed on every schema in the wild, `version_11` stayed 0, and the whole 1.1 feature set — `xs:assert`, `xs:alternative`, simple-type `xs:assertion` — silently compiled away even though the evaluation machinery was already correct. With the namespace fixed, the exact consumer repro behaves both ways: `sum(a) > 0` passes `<a>5</a>` and fails `<a>-5</a>` with an `assertion` finding. The #1910/#1911 gate fixtures had bound their `vc` prefix to the same wrong 2001 URI; corrected to the spec URI.
15
+
16
+ ### Fixed (Rosetta/QEMU class)
17
+
18
+ - **simd: the AVX2 kernel selection now verifies executability, not CPUID claims** (leptris#2039). Rosetta 2 (and QEMU user-mode) report AVX2 in CPUID but SIGILL on the first vector op — under Rosetta, every parse through the direct-parse face crashed at `leptris_text_scan_run_pristine_avx2+0x4`. The probe now executes a one-instruction canary (`vpaddb` on a register, under a SIGILL guard, cached per process) before blessing the AVX2 level, and `leptris_text_scan_run_pristine` — the one kernel dispatched compile-time-only — rides the runtime dispatch like every other kernel (pre-Haswell x86_64 falls back to the scalar walk too). Verified on the failing platform: Rosetta reports the level as sse4.2 and parses clean.
19
+
20
+ ### Performance
21
+
22
+ - **direct-parse: `dp_add_attr_inline` takes 8 register arguments** (leptris#2032). The 10-argument form overflowed arm64's register window — `name_colon` plus a flags word spilled to the caller's frame, and gcc's prologue (six callee-saved store-pairs plus the stack-arg reload) paid on every attribute. Packing `len|hash<<32` and the two scan flags into scalars is behavior-neutral; the CI-gated attrparse row moved macos −15% to parity (0.98× vs pugixml) with x86's win held. The ubuntu-arm leg improves ~2%; the remaining delta (the caller's stack-frame pressure) is tracked on #2032 with the on-runner profile attached.
23
+
24
+ ### Tooling
25
+
26
+ - **perf-record harness on the CI arm runner** (branch `repro/2032-perf`): `perf record` + report + annotate artifacts under `perf_event_paranoid=1` with the generic linux-tools binary — the on-runner profile that localized both #2032 levers.
27
+
28
+
3
29
  ## [1.9.421] - 2026-11-15
4
30
  ### Performance
5
31
 
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.421
6
+ VERSION 1.9.423
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -4,6 +4,13 @@
4
4
  * CPUID via __cpuid — treated as SSE42 baseline for simplicity
5
5
  * (every x86_64 CPU shipping since 2008 has SSE4.2).
6
6
  * arm64: NEON is architectural baseline — constant.
7
+ *
8
+ * #2039: CPUID can claim AVX2 that the execution environment cannot
9
+ * run — Rosetta 2 reports AVX2 in CPUID and SIGILLs on the first
10
+ * vector op; QEMU user-mode carries the same gap class. A claimed
11
+ * AVX2 level is therefore verified with an execute-canary (one
12
+ * vpaddb under a SIGILL guard) before it is blessed; the verdict is
13
+ * computed once per process and rides the same cache as the level.
7
14
  */
8
15
  #include "cpu.h"
9
16
 
@@ -14,12 +21,60 @@
14
21
  # include <intrin.h>
15
22
  #endif
16
23
 
24
+ /* POSIX-only: MinGW's GCC defines the builtins but has no
25
+ * sigsetjmp/siglongjmp — the mingw py-probe build died here
26
+ * (leptris-py ride/422 CI). MinGW keeps the CPUID-only verdict. */
27
+ #if defined(LEPTRIS_X86_GCC_BUILTINS) && !defined(_WIN32)
28
+ # define LEPTRIS_CANARY_POSIX 1
29
+ # include <setjmp.h>
30
+ # include <signal.h>
31
+
32
+ static sigjmp_buf leptris_canary_env;
33
+ static volatile sig_atomic_t leptris_canary_fired = 0;
34
+
35
+ static void leptris_canary_sigill(int sig) {
36
+ (void)sig;
37
+ leptris_canary_fired = 1;
38
+ siglongjmp(leptris_canary_env, 1);
39
+ }
40
+
41
+ /* 1 = AVX2 instructions actually execute; 0 = CPUID lied. A probe
42
+ * setup failure trusts CPUID (signal() unavailable is not a case any
43
+ * supported platform hits, and the previous behavior was unconditional
44
+ * trust). */
45
+ static int leptris_avx2_executable(void) {
46
+ void (*old)(int) = signal(SIGILL, leptris_canary_sigill);
47
+ if (old == SIG_ERR) {
48
+ return 1;
49
+ }
50
+ int ok = 1;
51
+ leptris_canary_fired = 0;
52
+ if (sigsetjmp(leptris_canary_env, 1) == 0) {
53
+ /* Reads/writes only xmm0 (caller-saved, clobber-declared): no
54
+ * memory operand, no state change — a pure "can the pipeline
55
+ * retire this opcode" probe. */
56
+ __asm__ volatile("vpaddb %%xmm0, %%xmm0, %%xmm0" : : : "xmm0");
57
+ }
58
+ if (leptris_canary_fired) {
59
+ ok = 0;
60
+ }
61
+ signal(SIGILL, old);
62
+ return ok;
63
+ }
64
+ #endif
65
+
17
66
  leptris_cpu_level leptris_cpu_detect(void) {
18
67
  #if defined(LEPTRIS_ARCH_ARM)
19
68
  return LEPTRIS_CPU_NEON;
20
69
  #elif defined(LEPTRIS_X86_GCC_BUILTINS)
21
70
  __builtin_cpu_init();
22
- if (__builtin_cpu_supports("avx2")) return LEPTRIS_CPU_AVX2;
71
+ #if defined(LEPTRIS_CANARY_POSIX)
72
+ if (__builtin_cpu_supports("avx2") && leptris_avx2_executable()) {
73
+ #else
74
+ if (__builtin_cpu_supports("avx2")) {
75
+ #endif
76
+ return LEPTRIS_CPU_AVX2;
77
+ }
23
78
  if (__builtin_cpu_supports("sse4.2")) return LEPTRIS_CPU_SSE42;
24
79
  return LEPTRIS_CPU_SCALAR;
25
80
  #elif defined(_MSC_VER) && defined(_M_X64)
@@ -114,6 +114,8 @@ static void (*g_copy3_fn)(char*, const char*, size_t, char, char, char,
114
114
  static int (*g_utf8_fn)(const char*, size_t) = NULL;
115
115
  static ptrdiff_t (*g_scan_run_fn)(const char*, size_t, char, char, char,
116
116
  int*, int*) = NULL;
117
+ static ptrdiff_t (*g_pristine_fn)(const char*, size_t, char,
118
+ int*, int*) = NULL;
117
119
 
118
120
  /* #1842: one pass, three byte classes — the direct parser's text path
119
121
  * (find '<', flag '&'/CR) drops its 48-byte inline loop and up to
@@ -167,6 +169,8 @@ static void count3_high_scalar(const char* s, size_t len,
167
169
  size_t* n0, size_t* n1, size_t* n2,
168
170
  int* saw_high, size_t* amp_count,
169
171
  size_t* valws_count);
172
+ static ptrdiff_t pristine_scalar(const char* s, size_t len, char term,
173
+ int* saw_f1, int* saw_f2);
170
174
 
171
175
  #if defined(_MSC_VER)
172
176
  # pragma section(".CRT$XCU", read)
@@ -190,6 +194,7 @@ static void dispatch_init(void) {
190
194
  g_count_fn = leptris_text_count_char_avx2;
191
195
  g_count3_high_fn = leptris_text_count3_high_avx2;
192
196
  g_scan_run_fn = leptris_text_scan_run_avx2;
197
+ g_pristine_fn = leptris_text_scan_run_pristine_avx2;
193
198
  g_utf8_fn = leptris_utf8_valid_avx2;
194
199
  return;
195
200
  }
@@ -203,6 +208,7 @@ static void dispatch_init(void) {
203
208
  g_count3_high_fn = leptris_text_count3_high_neon;
204
209
  g_copy3_fn = leptris_copy_count3_neon;
205
210
  g_scan_run_fn = leptris_text_scan_run_neon;
211
+ g_pristine_fn = leptris_text_scan_run_pristine_neon;
206
212
  g_utf8_fn = leptris_utf8_valid_neon;
207
213
  return;
208
214
  }
@@ -213,6 +219,7 @@ static void dispatch_init(void) {
213
219
  g_count_fn = count_scalar;
214
220
  g_count3_high_fn = count3_high_scalar;
215
221
  g_scan_run_fn = scan_run_scalar;
222
+ g_pristine_fn = pristine_scalar;
216
223
  g_utf8_fn = leptris_utf8_valid_scalar;
217
224
  }
218
225
 
@@ -327,18 +334,9 @@ ptrdiff_t leptris_text_scan_run(const char* s, size_t len, char term,
327
334
  * flags are constant 0 by census, so the vector loop carries ONLY
328
335
  * the term compare and the no-term tail returns immediately (the
329
336
  * round-1 rescan penalty cannot occur: the census answered the
330
- * flags). Arch kernels live in their own TUs, dispatched like
331
- * text_scan_run. */
332
- ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
333
- char term,
334
- int* saw_f1, int* saw_f2) {
335
- #if defined(LEPTRIS_ARCH_ARM) && defined(__aarch64__)
336
- return leptris_text_scan_run_pristine_neon(s, len, term,
337
- saw_f1, saw_f2);
338
- #elif defined(LEPTRIS_ARCH_X86) && defined(LEPTRIS_HAS_AVX2_BUILD)
339
- return leptris_text_scan_run_pristine_avx2(s, len, term,
340
- saw_f1, saw_f2);
341
- #else
337
+ * flags). Arch kernels live in their own TUs. */
338
+ static ptrdiff_t pristine_scalar(const char* s, size_t len, char term,
339
+ int* saw_f1, int* saw_f2) {
342
340
  const char* p = s;
343
341
  const char* end = s + len;
344
342
  while (p < end) {
@@ -352,7 +350,20 @@ ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
352
350
  *saw_f1 = 0;
353
351
  *saw_f2 = 0;
354
352
  return -1;
355
- #endif
353
+ }
354
+
355
+ /* #2039: routed through the RUNTIME cpu level like every other
356
+ * kernel — the compile-time-only gate ran the AVX2 binary on CPUs
357
+ * that cannot execute it (Rosetta/QEMU report AVX2 in CPUID and
358
+ * SIGILL on first use; pre-Haswell x86_64 has none at all). The
359
+ * dispatch verdict already carries the execute-canary verdict from
360
+ * cpu.c. */
361
+ ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
362
+ char term,
363
+ int* saw_f1, int* saw_f2) {
364
+ if (!g_pristine_fn) dispatch_init();
365
+ if (!g_pristine_fn) g_pristine_fn = pristine_scalar;
366
+ return g_pristine_fn(s, len, term, saw_f1, saw_f2);
356
367
  }
357
368
 
358
369
  /* ---- Structural span scan (TODO 193 Phase 1) ---- */
@@ -587,11 +587,21 @@ static int dp_dup_seen_or_add(DParser* p, uint32_t dh) {
587
587
  * value pool_strdup entirely — direct_parse path excludes entity
588
588
  * inputs, so has_entities is always 0. */
589
589
  static inline int dp_add_attr_inline(DParser* p, LeptrisElement elem,
590
- char* name, size_t name_len,
591
- uint32_t name_hash,
592
- char* val, size_t val_len,
593
- int has_amp, int has_ws,
590
+ char* name, char* val,
591
+ uint64_t name_len_hash,
592
+ size_t val_len, uint32_t ws_amp,
594
593
  const char* name_colon) {
594
+ /* #2032 arm64 codegen: the 10-argument form overflowed the 8
595
+ * register-argument window — name_colon plus a flags word spilled
596
+ * to the caller's frame, and the entry reload dominated the
597
+ * on-runner profile (the prologue's six store-pairs plus the
598
+ * stack-arg reload were ~13% of the function's samples under
599
+ * gcc-13). Packing len|hash<<32 and the two scan flags into
600
+ * scalars keeps every argument in a register. */
601
+ size_t name_len = (size_t)(name_len_hash & 0xFFFFFFFFu);
602
+ uint32_t name_hash = (uint32_t)(name_len_hash >> 32);
603
+ int has_amp = (int)(ws_amp & 1u);
604
+ int has_ws = (int)((ws_amp >> 1) & 1u);
595
605
  /* Raw-view pointer (pre-normalization) — the #635 surface shows
596
606
  * source views; the normalized/entity-expanded replacements
597
607
  * below rebind val. */
@@ -1315,9 +1325,13 @@ static int dp_parse_attrs(DParser* p, LeptrisElement elem) {
1315
1325
 
1316
1326
  /* Regular attribute — zero-copy name/value, bulk-allocated
1317
1327
  * struct. 1 = duplicate skipped: neither surface sees it. */
1318
- int arc = dp_add_attr_inline(p, elem, name_start, name_len,
1319
- dh, val_start, val_len, has_amp,
1320
- has_ws, attr_colon);
1328
+ int arc = dp_add_attr_inline(p, elem, name_start, val_start,
1329
+ (uint64_t)name_len |
1330
+ ((uint64_t)dh << 32),
1331
+ val_len,
1332
+ (uint32_t)has_amp |
1333
+ ((uint32_t)has_ws << 1),
1334
+ attr_colon);
1321
1335
  if (arc < 0) return -1;
1322
1336
  }
1323
1337
  /* for (;;): every exit is a return inside the loop (0 = tag
@@ -2141,10 +2141,10 @@ static LeptrisXsdSchema xsd_compile_impl(const char* xsd_text,
2141
2141
  * alternatives away for every vc-marked schema. */
2142
2142
  const char* ver = leptris_element_attribute(root, "version");
2143
2143
  const char* vmin = leptris_element_attribute_ns(
2144
- root, "http://www.w3.org/2001/XMLSchema-versioning",
2144
+ root, "http://www.w3.org/2007/XMLSchema-versioning",
2145
2145
  "minVersion");
2146
2146
  const char* vmax = leptris_element_attribute_ns(
2147
- root, "http://www.w3.org/2001/XMLSchema-versioning",
2147
+ root, "http://www.w3.org/2007/XMLSchema-versioning",
2148
2148
  "maxVersion");
2149
2149
  int is11 = (ver && strcmp(ver, "1.1") == 0) ||
2150
2150
  (vmin && strcmp(vmin, "1.1") == 0);
@@ -2644,6 +2644,24 @@ TEST(XsdAssert11, ExtensionAssertionEnforces) {
2644
2644
 
2645
2645
  /* 1.0-labelled schemas ignore the construct (XSD 1.0 validators
2646
2646
  * see unknown elements) — no assertion enforcement */
2647
+ // moxml#556: the vc:minVersion spelling marks 1.1 too — the
2648
+ // versioning namespace is http://www.w3.org/2007/XMLSchema-versioning
2649
+ // (the engine probed 2001 and silently skipped every vc-marked
2650
+ // schema's asserts and alternatives)
2651
+ TEST(XsdAssert11, VcMinVersionMarksSchema11) {
2652
+ const char* x =
2653
+ "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
2654
+ " vc:minVersion=\"1.1\""
2655
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
2656
+ "<xs:element name=\"doc\"><xs:complexType>"
2657
+ "<xs:sequence><xs:element name=\"a\" type=\"xs:int\""
2658
+ " maxOccurs=\"unbounded\"/></xs:sequence>"
2659
+ "<xs:assert test=\"sum(a) &gt; 0\"/>"
2660
+ "</xs:complexType></xs:element></xs:schema>";
2661
+ EXPECT_EQ(validate_doc(x, "<doc><a>5</a></doc>"), 1);
2662
+ EXPECT_EQ(validate_doc(x, "<doc><a>-5</a></doc>"), 0);
2663
+ }
2664
+
2647
2665
  TEST(XsdAssert11, Version10IgnoresAssertions) {
2648
2666
  const char* x =
2649
2667
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
@@ -4900,7 +4918,7 @@ TEST(Xsd11Gate, CtaSelectsAlternativeType) {
4900
4918
  const char xsd[] =
4901
4919
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
4902
4920
  " vc:minVersion=\"1.1\""
4903
- " xmlns:vc=\"http://www.w3.org/2001/XMLSchema-versioning\">"
4921
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
4904
4922
  "<xs:element name=\"shape\" type=\"Shape\">"
4905
4923
  "<xs:alternative test=\"@kind='circle'\" type=\"Circle\"/>"
4906
4924
  "</xs:element>"
@@ -4934,7 +4952,7 @@ TEST(Xsd11Gate, AssertIsEvaluated) {
4934
4952
  const char xsd[] =
4935
4953
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
4936
4954
  " vc:minVersion=\"1.1\""
4937
- " xmlns:vc=\"http://www.w3.org/2001/XMLSchema-versioning\">"
4955
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
4938
4956
  "<xs:element name=\"size\">"
4939
4957
  "<xs:complexType><xs:sequence>"
4940
4958
  "<xs:element name=\"w\" type=\"xs:integer\"/>"
@@ -4972,7 +4990,7 @@ TEST(Xsd11Gate, OverrideLoadsBaseAndReplacesComponents) {
4972
4990
  "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
4973
4991
  " targetNamespace=\"urn:b\" xmlns=\"urn:b\""
4974
4992
  " elementFormDefault=\"qualified\" vc:minVersion=\"1.1\""
4975
- " xmlns:vc=\"http://www.w3.org/2001/XMLSchema-versioning\">"
4993
+ " xmlns:vc=\"http://www.w3.org/2007/XMLSchema-versioning\">"
4976
4994
  "<xs:override schemaLocation=\"ovr1913_base.xsd\">"
4977
4995
  "<xs:complexType name=\"Doc\">"
4978
4996
  "<xs:sequence><xs:element name=\"b\" type=\"xs:integer\"/>"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
3
3
  "name": "leptris",
4
- "version": "1.9.421",
4
+ "version": "1.9.423",
5
5
  "description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
6
6
  "homepage": "https://github.com/leptris/leptris",
7
7
  "license": "MIT",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.421.0
4
+ version: 1.9.423.0
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.