leptris 1.9.406.1-aarch64-linux → 1.9.408.0-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 +4 -4
- data/Rakefile +1 -1
- data/ext/leptris/native/native.c +37 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/descriptor.rb +21 -2
- data/lib/leptris/xml/native.so +0 -0
- data/lib/leptris/xml/native_3_3.so +0 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +23 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/leptris/descriptor/plan.c +79 -13
- data/vendor-src/libleptris/src/leptris/memory/arena.c +137 -9
- data/vendor-src/libleptris/src/leptris/memory/arena.h +10 -0
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +41 -1
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +92 -1
- data/vendor-src/libleptris/test/abi/test_descriptor.cpp +211 -0
- data/vendor-src/libleptris/test/memory/test_arena.cpp +109 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/attgD019-set/attgD019.xsd +23 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/attgD019-set/attgD019a.xsd +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE050.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE050.xsd +7 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE055.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE055.xsd +7 -0
- data/vendor-src/libleptris/test/xsd/test_i1957_1958.cpp +35 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +26 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d8b3ee2fc6bc365dce4df991b9aa35a5d6f29f3ae4fa2fea26276def72bedcab
|
|
4
|
+
data.tar.gz: 0d08c6a8c9303a5838767c28ee11ada658800f0c4cbef3b17f6ff50680f972cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6264a2f59c94f2bcddb291e3dbf02a2dddb2b723adbe2e339ac332940350a29a0fabcfe979e6577a5ab809a2cd3d9bc55cfe867a84f3555a41fc71a69662a85e
|
|
7
|
+
data.tar.gz: a014c75b36535e71bc33401908a8baf9b9c36e0be4cca86d897b24156a8a2769b91fc5f0e1b13536a6dbcc1efc43c65b093a1746e7216edb91ad7e74dd179778
|
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.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.408"
|
|
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
|
data/ext/leptris/native/native.c
CHANGED
|
@@ -2840,6 +2840,41 @@ static VALUE nf_walk_addresses(VALUE self, VALUE root)
|
|
|
2840
2840
|
return rb_ary_new3(3, names, addrs, depths);
|
|
2841
2841
|
}
|
|
2842
2842
|
|
|
2843
|
+
/* ---- Raw child addresses (leptris-ruby#587 shadow lane) ----------
|
|
2844
|
+
* The per-node counterpart of walk_addresses: ONE crossing returns
|
|
2845
|
+
* the parent's direct children as raw addresses + node kinds — no
|
|
2846
|
+
* wrapper mint, no identity-cache writes; kinds are the f_children_ex
|
|
2847
|
+
* ints (0 = element). Accepts a NativeNode handle or a raw address
|
|
2848
|
+
* Integer. Read-only consumers pair it with the address-keyed read
|
|
2849
|
+
* faces; a mutable, identity-backed handle mints through the normal
|
|
2850
|
+
* wrap path on first write. */
|
|
2851
|
+
static VALUE nf_children_addrs(VALUE self, VALUE parent)
|
|
2852
|
+
{
|
|
2853
|
+
void **buf;
|
|
2854
|
+
int *kinds;
|
|
2855
|
+
void *ptr;
|
|
2856
|
+
int count, i;
|
|
2857
|
+
VALUE addrs, kind_vals;
|
|
2858
|
+
(void)self;
|
|
2859
|
+
if (RB_INTEGER_TYPE_P(parent)) {
|
|
2860
|
+
ptr = (void *)(uintptr_t)NUM2ULL(parent);
|
|
2861
|
+
} else {
|
|
2862
|
+
struct native_node *n;
|
|
2863
|
+
TypedData_Get_Struct(parent, struct native_node, &nn_type, n);
|
|
2864
|
+
ptr = n->ptr;
|
|
2865
|
+
}
|
|
2866
|
+
count = fetch_children_two_call(ptr, &buf, &kinds);
|
|
2867
|
+
addrs = rb_ary_new2(count > 0 ? count : 0);
|
|
2868
|
+
kind_vals = rb_ary_new2(count > 0 ? count : 0);
|
|
2869
|
+
for (i = 0; i < count; i++) {
|
|
2870
|
+
rb_ary_push(addrs, ULL2NUM((uint64_t)(uintptr_t)buf[i]));
|
|
2871
|
+
rb_ary_push(kind_vals, INT2NUM(kinds[i]));
|
|
2872
|
+
}
|
|
2873
|
+
ruby_xfree(buf);
|
|
2874
|
+
ruby_xfree(kinds);
|
|
2875
|
+
return rb_ary_new3(2, addrs, kind_vals);
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2843
2878
|
/* ---- Struct plan executor (moxml "miles faster" round) ------------
|
|
2844
2879
|
* The consumer's shape compiles to spec: name (interned String) ->
|
|
2845
2880
|
* [Struct class, attrs Hash (name -> slot Symbol), text slot Symbol
|
|
@@ -4283,6 +4318,8 @@ static void leptris_native_setup(void)
|
|
|
4283
4318
|
nf_walk_columnar, 1);
|
|
4284
4319
|
rb_define_module_function(m_native, "walk_addresses",
|
|
4285
4320
|
nf_walk_addresses, 1);
|
|
4321
|
+
rb_define_module_function(m_native, "children_addrs",
|
|
4322
|
+
nf_children_addrs, 1);
|
|
4286
4323
|
rb_define_module_function(m_native, "attribute_pairs",
|
|
4287
4324
|
nf_attribute_pairs, 2);
|
|
4288
4325
|
rb_define_module_function(m_native, "plan_structs",
|
data/lib/leptris/version.rb
CHANGED
|
@@ -166,7 +166,14 @@ class Leptris::XML::Descriptor
|
|
|
166
166
|
tree_index = plans.size - 1
|
|
167
167
|
memo[key] = tree_index
|
|
168
168
|
duped[:children] = (duped[:children] || []).map do |row|
|
|
169
|
-
|
|
169
|
+
# leptris#1966: :ordered_deferred rows carry child :plan trees
|
|
170
|
+
# exactly like :nested rows (lutaml's emission_rows_for
|
|
171
|
+
# materializes the deferred subtree) — skipping them here
|
|
172
|
+
# left deferred subtrees WITHOUT descriptor slots, so the
|
|
173
|
+
# slot numbering diverged from the emission graph at the
|
|
174
|
+
# first deferred row and the ops' plan_index pointed at the
|
|
175
|
+
# wrong plan (engine status=-5 on the theme/styles shapes).
|
|
176
|
+
if row[:kind] == :nested || row[:kind] == :ordered_deferred
|
|
170
177
|
row.merge(child_plan_index: flatten_plan(row.fetch(:plan), plans,
|
|
171
178
|
memo))
|
|
172
179
|
else
|
|
@@ -426,8 +433,20 @@ class Leptris::XML::Descriptor
|
|
|
426
433
|
raw = Leptris::XML::FFI.leptris_plan_result_build(
|
|
427
434
|
@handle, memory, ops.size, status)
|
|
428
435
|
if raw.null?
|
|
436
|
+
# leptris#1966 ask 2: the bare "status=-5" sent three consumers
|
|
437
|
+
# hunting an ABI bug that did not exist. Carry the op-stream
|
|
438
|
+
# shape — op count, plan count, and the ops at the highest
|
|
439
|
+
# plan_index — so an out-of-range reference is visible at a
|
|
440
|
+
# glance.
|
|
441
|
+
max_pi = ops.filter_map { |o| o[:plan_index] }.max
|
|
442
|
+
at_max = ops.each_index
|
|
443
|
+
.select { |i| ops[i][:plan_index] == max_pi }
|
|
444
|
+
.first(3)
|
|
429
445
|
raise Leptris::XML::Error,
|
|
430
|
-
"plan result build failed (status=#{status.read_int}
|
|
446
|
+
"plan result build failed (status=#{status.read_int}; " \
|
|
447
|
+
"ops=#{ops.size} plans=#{@plans.size} " \
|
|
448
|
+
"max_plan_index=#{max_pi.inspect} " \
|
|
449
|
+
"ops_at_max=#{at_max.map { |i| [i, ops[i][:kind], ops[i][:row_index]] }.inspect})"
|
|
431
450
|
end
|
|
432
451
|
Leptris::XML::PlanValue.new(ResultHandle.new(raw),
|
|
433
452
|
owner: true, plans: @plans, plan: @plans[0])
|
data/lib/leptris/xml/native.so
CHANGED
|
Binary file
|
|
Binary file
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.408] - 2026-11-05
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- emit default-xmlns declarations for prefix-less EXACT rows (#1969) (descriptor)
|
|
8
|
+
- the union value-space fix + default-xmlns emission (leptris-rs#45, leptris#1969) (engine)
|
|
9
|
+
- union-typed fixed constraints compare in the value space (leptris-rs#45) (xsd)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [1.9.407] - 2026-11-05
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- deep-copy attr and element ns_prefix past the spec buffers (descriptor)
|
|
18
|
+
- keep sys/mman.h off the Windows include path (memory)
|
|
19
|
+
|
|
20
|
+
### Performance
|
|
21
|
+
|
|
22
|
+
- oversized arena spans return to the OS on drop (#1947) (memory)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
3
26
|
## [1.9.406] - 2026-11-03
|
|
4
27
|
|
|
5
28
|
### Added
|
|
@@ -370,6 +370,7 @@ static void dp_plan_free(LeptrisPlan p) {
|
|
|
370
370
|
for (uint32_t a = 0; a < d->attribute_count; a++) {
|
|
371
371
|
free((char *)d->attribute_plans[a].wire_name);
|
|
372
372
|
free((char *)d->attribute_plans[a].ns_uri);
|
|
373
|
+
free((char *)d->attribute_plans[a].ns_prefix);
|
|
373
374
|
for (uint16_t pi = 0;
|
|
374
375
|
pi < d->attribute_plans[a].predicate_count; pi++) {
|
|
375
376
|
free((char*)d->attribute_plans[a]
|
|
@@ -449,9 +450,12 @@ LEPTRIS_API LeptrisPlan leptris_plan_build(const leptris_plan_spec* spec,
|
|
|
449
450
|
if (s->ns_uri) {
|
|
450
451
|
d->ns_uri = dp_strdup(s->ns_uri);
|
|
451
452
|
if (!d->ns_uri) goto oom;
|
|
453
|
+
}
|
|
454
|
+
/* #1967: the prefix must copy OUTSIDE the ns_uri branch — a
|
|
455
|
+
* plan carrying a prefix with no URI otherwise keeps the
|
|
456
|
+
* caller's anchor pointer. */
|
|
452
457
|
d->ns_prefix = s->ns_prefix ? dp_strdup(s->ns_prefix) : NULL;
|
|
453
458
|
if (s->ns_prefix && !d->ns_prefix) goto oom;
|
|
454
|
-
}
|
|
455
459
|
d->flags = s->flags;
|
|
456
460
|
|
|
457
461
|
if (s->attribute_count) {
|
|
@@ -508,6 +512,17 @@ LEPTRIS_API LeptrisPlan leptris_plan_build(const leptris_plan_spec* spec,
|
|
|
508
512
|
dp_strdup(s->attribute_plans[a].wire_name);
|
|
509
513
|
if (!d->attribute_plans[a].wire_name) goto oom;
|
|
510
514
|
}
|
|
515
|
+
/* #1967: attr ns_prefix rode the struct copy — a
|
|
516
|
+
* dangling pointer into the caller's build buffers
|
|
517
|
+
* once the bindings GC their anchors (the #1585
|
|
518
|
+
* lesson; child rows already retain). */
|
|
519
|
+
d->attribute_plans[a].ns_prefix =
|
|
520
|
+
s->attribute_plans[a].ns_prefix
|
|
521
|
+
? dp_strdup(s->attribute_plans[a].ns_prefix)
|
|
522
|
+
: NULL;
|
|
523
|
+
if (s->attribute_plans[a].ns_prefix &&
|
|
524
|
+
!d->attribute_plans[a].ns_prefix)
|
|
525
|
+
goto oom;
|
|
511
526
|
uint16_t pc = s->attribute_plans[a].predicate_count;
|
|
512
527
|
if (pc) {
|
|
513
528
|
if (!s->attribute_plans[a].predicates) goto oom;
|
|
@@ -1510,7 +1525,8 @@ static char* dp_wrapper_name(const struct leptris_plan_result* v) {
|
|
|
1510
1525
|
|
|
1511
1526
|
static int dp_emit_element_open(const struct leptris_plan_result* v,
|
|
1512
1527
|
const char* name, dp_sb* b,
|
|
1513
|
-
const dp_decls* decls, int is_root
|
|
1528
|
+
const dp_decls* decls, int is_root,
|
|
1529
|
+
const char* default_claim) {
|
|
1514
1530
|
if (!dp_sb_putn(b, "<", 1) || !dp_sb_puts(b, name)) return 0;
|
|
1515
1531
|
if (is_root && decls) {
|
|
1516
1532
|
for (size_t i = 0; i < decls->n; i++) {
|
|
@@ -1520,6 +1536,17 @@ static int dp_emit_element_open(const struct leptris_plan_result* v,
|
|
|
1520
1536
|
return 0;
|
|
1521
1537
|
}
|
|
1522
1538
|
}
|
|
1539
|
+
/* leptris#1969: a prefix-less EXACT binding is the DEFAULT
|
|
1540
|
+
* namespace — emit the bare local name and declare xmlns="uri"
|
|
1541
|
+
* when the claim differs from the in-scope default (the root
|
|
1542
|
+
* hoists it once; deeper same-uri nodes inherit). Attribute
|
|
1543
|
+
* rows never take this form (W3C: attributes cannot
|
|
1544
|
+
* default-bind). */
|
|
1545
|
+
if (default_claim) {
|
|
1546
|
+
if (!dp_sb_puts(b, " xmlns=\"") ||
|
|
1547
|
+
!dp_sb_puts(b, default_claim) || !dp_sb_putn(b, "\"", 1))
|
|
1548
|
+
return 0;
|
|
1549
|
+
}
|
|
1523
1550
|
for (size_t a = 0; a < v->attr_count; a++) {
|
|
1524
1551
|
/* leptris#1941: a row with an emission binding spells
|
|
1525
1552
|
* "prefix:local" (dp_wrapper_name's element contract);
|
|
@@ -1569,14 +1596,17 @@ static int dp_sb_indent_newline(dp_sb* b, const dp_fmt* fmt, int depth) {
|
|
|
1569
1596
|
static int dp_emit_value(const struct leptris_plan_result* v,
|
|
1570
1597
|
const dp_plan* container, const LeptrisPlan pool,
|
|
1571
1598
|
dp_sb* b, const dp_decls* decls, int is_root,
|
|
1572
|
-
const dp_fmt* fmt, int depth
|
|
1599
|
+
const dp_fmt* fmt, int depth,
|
|
1600
|
+
const char* cur_default);
|
|
1573
1601
|
|
|
1574
1602
|
static int dp_emit_element(const struct leptris_plan_result* v,
|
|
1575
1603
|
const char* name, const LeptrisPlan pool,
|
|
1576
1604
|
const dp_plan* kids_container, dp_sb* b,
|
|
1577
1605
|
const dp_decls* decls, int is_root,
|
|
1578
|
-
const dp_fmt* fmt, int depth
|
|
1579
|
-
|
|
1606
|
+
const dp_fmt* fmt, int depth,
|
|
1607
|
+
const char* cur_default) {
|
|
1608
|
+
if (!dp_emit_element_open(v, name, b, decls, is_root, cur_default))
|
|
1609
|
+
return 0;
|
|
1580
1610
|
const struct leptris_plan_result** kids = NULL;
|
|
1581
1611
|
size_t nk = 0, cap = 0;
|
|
1582
1612
|
if (!dp_flatten_kids(v, &kids, &nk, &cap)) {
|
|
@@ -1601,6 +1631,10 @@ static int dp_emit_element(const struct leptris_plan_result* v,
|
|
|
1601
1631
|
* parent), so a nested member resolved its kids' rows against
|
|
1602
1632
|
* the parent's rows and a CONTENT row serialized as an
|
|
1603
1633
|
* empty-named wrapper. */
|
|
1634
|
+
/* leptris#1969: this element's own claim sets the kids'
|
|
1635
|
+
* in-scope default (a default-xmlns re-declaration nests). */
|
|
1636
|
+
const char* kid_default = cur_default;
|
|
1637
|
+
if (v->ns_uri && !v->ns_prefix) kid_default = v->ns_uri;
|
|
1604
1638
|
int ok = 1;
|
|
1605
1639
|
for (size_t i = 0; i < nk && ok; i++) {
|
|
1606
1640
|
if (indent_kids && !dp_sb_indent_newline(b, fmt, depth + 1)) {
|
|
@@ -1608,7 +1642,8 @@ static int dp_emit_element(const struct leptris_plan_result* v,
|
|
|
1608
1642
|
break;
|
|
1609
1643
|
}
|
|
1610
1644
|
ok = dp_emit_value(kids[i], kids_container, pool, b, NULL, 0,
|
|
1611
|
-
fmt, indent_kids ? depth + 1 : depth
|
|
1645
|
+
fmt, indent_kids ? depth + 1 : depth,
|
|
1646
|
+
kid_default);
|
|
1612
1647
|
}
|
|
1613
1648
|
free((void*)kids);
|
|
1614
1649
|
if (!ok) return 0;
|
|
@@ -1623,7 +1658,8 @@ static int dp_emit_element(const struct leptris_plan_result* v,
|
|
|
1623
1658
|
static int dp_emit_value(const struct leptris_plan_result* v,
|
|
1624
1659
|
const dp_plan* container, const LeptrisPlan pool,
|
|
1625
1660
|
dp_sb* b, const dp_decls* decls, int is_root,
|
|
1626
|
-
const dp_fmt* fmt, int depth
|
|
1661
|
+
const dp_fmt* fmt, int depth,
|
|
1662
|
+
const char* cur_default) {
|
|
1627
1663
|
if (v->kind == LEPTRIS_PLAN_VALUE_RAW)
|
|
1628
1664
|
return dp_sb_puts(b, v->str ? v->str : "");
|
|
1629
1665
|
if (v->kind == LEPTRIS_PLAN_VALUE_ELEMENT) {
|
|
@@ -1673,8 +1709,17 @@ static int dp_emit_value(const struct leptris_plan_result* v,
|
|
|
1673
1709
|
kids_container =
|
|
1674
1710
|
&poolp->plans[cap->child_plan_index];
|
|
1675
1711
|
}
|
|
1712
|
+
/* leptris#1969: this node's default-xmlns claim (a ns_uri
|
|
1713
|
+
* without a prefix). Emitted only when it differs from the
|
|
1714
|
+
* in-scope default; the kids inherit the claim. */
|
|
1715
|
+
const char* claim =
|
|
1716
|
+
(v->ns_uri && !v->ns_prefix) ? v->ns_uri : NULL;
|
|
1717
|
+
const char* open_claim =
|
|
1718
|
+
(claim && (!cur_default || strcmp(claim, cur_default) != 0))
|
|
1719
|
+
? claim
|
|
1720
|
+
: NULL;
|
|
1676
1721
|
int ok = dp_emit_element(v, name, pool, kids_container, b,
|
|
1677
|
-
decls, is_root, fmt, depth);
|
|
1722
|
+
decls, is_root, fmt, depth, open_claim);
|
|
1678
1723
|
free(name);
|
|
1679
1724
|
return ok;
|
|
1680
1725
|
}
|
|
@@ -1688,7 +1733,16 @@ static int dp_emit_value(const struct leptris_plan_result* v,
|
|
|
1688
1733
|
/* The row is the wrapper element around this text. */
|
|
1689
1734
|
char* name = dp_wrapper_name(v);
|
|
1690
1735
|
if (!name) return 0;
|
|
1736
|
+
/* leptris#1969: the wrapper's own default-xmlns claim. */
|
|
1737
|
+
const char* wclaim =
|
|
1738
|
+
(v->ns_uri && !v->ns_prefix &&
|
|
1739
|
+
(!cur_default || strcmp(v->ns_uri, cur_default) != 0))
|
|
1740
|
+
? v->ns_uri
|
|
1741
|
+
: NULL;
|
|
1691
1742
|
int ok = dp_sb_putn(b, "<", 1) && dp_sb_puts(b, name) &&
|
|
1743
|
+
(wclaim ? dp_sb_puts(b, " xmlns=\"") &&
|
|
1744
|
+
dp_sb_puts(b, wclaim) && dp_sb_putn(b, "\"", 1)
|
|
1745
|
+
: 1) &&
|
|
1692
1746
|
dp_sb_putn(b, ">", 1) && dp_sb_escape(b, text, 0) &&
|
|
1693
1747
|
dp_sb_puts(b, "</") && dp_sb_puts(b, name) &&
|
|
1694
1748
|
dp_sb_putn(b, ">", 1);
|
|
@@ -1717,7 +1771,7 @@ static char* dp_serialize_impl(LeptrisPlan plan,
|
|
|
1717
1771
|
}
|
|
1718
1772
|
dp_sb b = {0};
|
|
1719
1773
|
int ok = dp_emit_value(rv, NULL, (const LeptrisPlan)plan, &b,
|
|
1720
|
-
&decls, 1, fmt, 0);
|
|
1774
|
+
&decls, 1, fmt, 0, NULL);
|
|
1721
1775
|
dp_decls_free(&decls);
|
|
1722
1776
|
if (!ok) {
|
|
1723
1777
|
free(b.s);
|
|
@@ -1982,18 +2036,23 @@ static struct leptris_plan_result* plan_result_build_windowed(
|
|
|
1982
2036
|
} else if (cr->child_plan_index >= 0 &&
|
|
1983
2037
|
cr->child_plan_index <
|
|
1984
2038
|
(int32_t)pool->plan_count &&
|
|
1985
|
-
pool->plans[cr->child_plan_index].
|
|
2039
|
+
pool->plans[cr->child_plan_index].ns_uri &&
|
|
1986
2040
|
pool->plans[cr->child_plan_index].ns_form ==
|
|
1987
2041
|
LEPTRIS_PLAN_NS_EXACT) {
|
|
1988
2042
|
ns_src = &pool->plans[cr->child_plan_index];
|
|
1989
|
-
} else if (cp->
|
|
2043
|
+
} else if (cp->ns_uri &&
|
|
1990
2044
|
cp->ns_form == LEPTRIS_PLAN_NS_EXACT) {
|
|
1991
2045
|
ns_src = cp;
|
|
1992
2046
|
}
|
|
1993
2047
|
if (ns_src) {
|
|
1994
|
-
|
|
2048
|
+
/* leptris#1969: ns_prefix NULL + ns_uri set is
|
|
2049
|
+
* the DEFAULT-xmlns claim (bare local name,
|
|
2050
|
+
* xmlns="uri" hoisted on the emitting root). */
|
|
2051
|
+
v->ns_prefix = ns_src->ns_prefix
|
|
2052
|
+
? dp_strdup(ns_src->ns_prefix)
|
|
2053
|
+
: NULL;
|
|
1995
2054
|
v->ns_uri = dp_strdup(ns_src->ns_uri);
|
|
1996
|
-
if (!v->
|
|
2055
|
+
if (!v->ns_uri) goto oom;
|
|
1997
2056
|
}
|
|
1998
2057
|
} else if (cp->ns_prefix &&
|
|
1999
2058
|
cp->ns_form == LEPTRIS_PLAN_NS_EXACT) {
|
|
@@ -2002,6 +2061,13 @@ static struct leptris_plan_result* plan_result_build_windowed(
|
|
|
2002
2061
|
v->ns_prefix = dp_strdup(cp->ns_prefix);
|
|
2003
2062
|
v->ns_uri = dp_strdup(cp->ns_uri);
|
|
2004
2063
|
if (!v->ns_prefix || !v->ns_uri) goto oom;
|
|
2064
|
+
} else if (cp->ns_uri &&
|
|
2065
|
+
cp->ns_form == LEPTRIS_PLAN_NS_EXACT) {
|
|
2066
|
+
/* leptris#1969: the root op binds the plan's own
|
|
2067
|
+
* DEFAULT namespace (prefix-less EXACT) —
|
|
2068
|
+
* xmlns="uri" hoists on the output root. */
|
|
2069
|
+
v->ns_uri = dp_strdup(cp->ns_uri);
|
|
2070
|
+
if (!v->ns_uri) goto oom;
|
|
2005
2071
|
}
|
|
2006
2072
|
if (sp == 0) {
|
|
2007
2073
|
if (root) {
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
/* lib/src/memory/arena.c — Contiguous per-document arena (TODO 183)
|
|
2
2
|
* Copyright (c) 2024, Ribose Inc.
|
|
3
3
|
*/
|
|
4
|
+
/* glibc hides MAP_ANONYMOUS under -std=c99 (__STRICT_ANSI__); the
|
|
5
|
+
* feature-test macros must precede every include of this TU. The
|
|
6
|
+
* build adds _POSIX_C_SOURCE=200809L publicly, which puts Apple's
|
|
7
|
+
* headers in strict mode — _DARWIN_C_SOURCE restores the BSD names
|
|
8
|
+
* (MAP_ANON/MAP_ANONYMOUS) there. */
|
|
9
|
+
#if defined(__linux__) && !defined(_DEFAULT_SOURCE)
|
|
10
|
+
#define _DEFAULT_SOURCE 1
|
|
11
|
+
#endif
|
|
12
|
+
#if defined(__APPLE__) && !defined(_DARWIN_C_SOURCE)
|
|
13
|
+
#define _DARWIN_C_SOURCE 1
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
/* ---- #1947 lever 2: direct (anonymous-mmap) spans ---------------------
|
|
17
|
+
*
|
|
18
|
+
* A span above the retain budget can never be parked (retain_give
|
|
19
|
+
* frees it unconditionally), so acquiring it through malloc buys
|
|
20
|
+
* nothing and the freed pages linger in allocator magazines — the
|
|
21
|
+
* ~2 GB post-drop residency the XMI/CityGML pipeline reports. Oversized
|
|
22
|
+
* spans are taken mmap-direct and returned with munmap on destroy, so
|
|
23
|
+
* the drop face collapses RSS deterministically.
|
|
24
|
+
*
|
|
25
|
+
* Stands down under ASAN (the malloc path keeps use-after-free visible
|
|
26
|
+
* to the shadow) and under custom allocators (hooked accounting must
|
|
27
|
+
* see every byte the library takes). Within-budget spans keep the
|
|
28
|
+
* park-and-reuse lane — the repeated-parse fault fix depends on it. */
|
|
29
|
+
#if defined(_WIN32)
|
|
30
|
+
#define LEPTRIS_HAS_DIRECT_SPANS 1
|
|
31
|
+
#elif !defined(__wasm__) && !defined(__EMSCRIPTEN__) && \
|
|
32
|
+
(defined(__unix__) || defined(__APPLE__) || defined(__MACH__))
|
|
33
|
+
#define LEPTRIS_HAS_DIRECT_SPANS 1
|
|
34
|
+
#endif
|
|
35
|
+
|
|
4
36
|
#include "arena.h"
|
|
5
37
|
|
|
6
38
|
#include "../common/port.h" /* LEPTRIS_THREAD_LOCAL */
|
|
@@ -8,8 +40,19 @@
|
|
|
8
40
|
#include <stdlib.h>
|
|
9
41
|
#include <stdio.h>
|
|
10
42
|
#include <string.h>
|
|
11
|
-
#if defined(__linux__)
|
|
12
|
-
|
|
43
|
+
#if defined(__linux__) || \
|
|
44
|
+
(defined(LEPTRIS_HAS_DIRECT_SPANS) && !defined(_WIN32))
|
|
45
|
+
#include <sys/mman.h> /* madvise(MADV_HUGEPAGE), mmap/munmap */
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
#if defined(_WIN32)
|
|
49
|
+
#include <windows.h>
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
/* BSD headers name it MAP_ANON; the POSIX spelling may be absent. */
|
|
53
|
+
#if defined(LEPTRIS_HAS_DIRECT_SPANS) && !defined(MAP_ANONYMOUS) && \
|
|
54
|
+
defined(MAP_ANON)
|
|
55
|
+
#define MAP_ANONYMOUS MAP_ANON
|
|
13
56
|
#endif
|
|
14
57
|
|
|
15
58
|
/* Allocation hooks (core.c): honoring the public
|
|
@@ -296,6 +339,66 @@ char* leptris_arena_buffer_alloc(size_t size) {
|
|
|
296
339
|
return base ? base : (char*)leptris_alloc_hook(size);
|
|
297
340
|
}
|
|
298
341
|
|
|
342
|
+
/* ---- Direct-span transport (#1947) ----------------------------------- */
|
|
343
|
+
|
|
344
|
+
static size_t g_span_direct_taken;
|
|
345
|
+
static size_t g_span_direct_released;
|
|
346
|
+
|
|
347
|
+
int leptris_arena_has_direct_spans(void) {
|
|
348
|
+
#if defined(LEPTRIS_HAS_DIRECT_SPANS)
|
|
349
|
+
return 1;
|
|
350
|
+
#else
|
|
351
|
+
return 0;
|
|
352
|
+
#endif
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
void leptris_arena_span_stats(size_t* direct_taken, size_t* direct_released) {
|
|
356
|
+
if (direct_taken) *direct_taken = g_span_direct_taken;
|
|
357
|
+
if (direct_released) *direct_released = g_span_direct_released;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
#if defined(_WIN32)
|
|
361
|
+
|
|
362
|
+
static int span_direct_acquire(char** out, size_t size) {
|
|
363
|
+
void* p = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT,
|
|
364
|
+
PAGE_READWRITE);
|
|
365
|
+
if (!p) return 0;
|
|
366
|
+
*out = (char*)p;
|
|
367
|
+
return 1;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
static void span_direct_release(char* base, size_t size) {
|
|
371
|
+
(void)size;
|
|
372
|
+
VirtualFree(base, 0, MEM_RELEASE);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
#elif defined(LEPTRIS_HAS_DIRECT_SPANS)
|
|
376
|
+
|
|
377
|
+
static int span_direct_acquire(char** out, size_t size) {
|
|
378
|
+
void* p = mmap(NULL, size, PROT_READ | PROT_WRITE,
|
|
379
|
+
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
|
380
|
+
if (p == MAP_FAILED) return 0;
|
|
381
|
+
*out = (char*)p;
|
|
382
|
+
return 1;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
static void span_direct_release(char* base, size_t size) {
|
|
386
|
+
munmap(base, size);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
#else
|
|
390
|
+
|
|
391
|
+
static int span_direct_acquire(char** out, size_t size) {
|
|
392
|
+
(void)out; (void)size;
|
|
393
|
+
return 0;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
static void span_direct_release(char* base, size_t size) {
|
|
397
|
+
(void)base; (void)size;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
#endif
|
|
401
|
+
|
|
299
402
|
void leptris_arena_buffer_release(void* p, size_t size) {
|
|
300
403
|
if (!p) return;
|
|
301
404
|
retain_give((char*)p, size);
|
|
@@ -335,13 +438,30 @@ LeptrisArena* leptris_arena_create(size_t size) {
|
|
|
335
438
|
return NULL;
|
|
336
439
|
size_t want = size + hdr;
|
|
337
440
|
size_t capacity = want;
|
|
338
|
-
char* span =
|
|
339
|
-
|
|
340
|
-
|
|
441
|
+
char* span = NULL;
|
|
442
|
+
int direct = 0;
|
|
443
|
+
#ifndef ARENA_RETAIN_ASAN
|
|
444
|
+
/* #1947: above the retain budget the span can never be parked, so
|
|
445
|
+
* the libc lane only adds magazine residency. Take it direct. */
|
|
446
|
+
if (want > ARENA_RETAIN_MAX_BYTES && !leptris_custom_allocator_active() &&
|
|
447
|
+
span_direct_acquire(&span, want)) {
|
|
341
448
|
capacity = want;
|
|
342
|
-
|
|
449
|
+
direct = 1;
|
|
450
|
+
retain_lock();
|
|
451
|
+
g_span_direct_taken++;
|
|
452
|
+
retain_unlock();
|
|
343
453
|
arena_advise_hugepages(span, capacity);
|
|
344
454
|
}
|
|
455
|
+
#endif
|
|
456
|
+
if (!span) {
|
|
457
|
+
span = retain_take(want, &capacity);
|
|
458
|
+
if (!span) {
|
|
459
|
+
span = (char*)leptris_alloc_hook(want);
|
|
460
|
+
capacity = want;
|
|
461
|
+
if (!span) return NULL;
|
|
462
|
+
arena_advise_hugepages(span, capacity);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
345
465
|
LeptrisArena* arena = (LeptrisArena*)span;
|
|
346
466
|
arena->span = span;
|
|
347
467
|
arena->base = span + hdr;
|
|
@@ -351,6 +471,7 @@ LeptrisArena* leptris_arena_create(size_t size) {
|
|
|
351
471
|
arena->size = capacity - hdr;
|
|
352
472
|
arena->used = 0;
|
|
353
473
|
arena->failed = 0;
|
|
474
|
+
arena->direct = direct;
|
|
354
475
|
return arena;
|
|
355
476
|
}
|
|
356
477
|
|
|
@@ -364,9 +485,16 @@ void leptris_arena_destroy(LeptrisArena* arena) {
|
|
|
364
485
|
if (!arena) return;
|
|
365
486
|
/* The header lives inside the span — releasing the block
|
|
366
487
|
* releases everything. */
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
488
|
+
const size_t hdr = (sizeof(LeptrisArena) + ARENA_ALIGNMENT - 1) &
|
|
489
|
+
~(ARENA_ALIGNMENT - 1);
|
|
490
|
+
if (arena->direct) {
|
|
491
|
+
span_direct_release(arena->span, arena->size + hdr);
|
|
492
|
+
retain_lock();
|
|
493
|
+
g_span_direct_released++;
|
|
494
|
+
retain_unlock();
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
retain_give(arena->span, arena->size + hdr);
|
|
370
498
|
}
|
|
371
499
|
|
|
372
500
|
void* leptris_arena_alloc(LeptrisArena* arena, size_t size) {
|
|
@@ -39,6 +39,8 @@ typedef struct leptris_arena {
|
|
|
39
39
|
size_t size; /* Bump-region capacity (span capacity minus header) */
|
|
40
40
|
size_t used; /* Bump pointer — bytes handed out so far */
|
|
41
41
|
size_t failed; /* 1 once any request has been refused (sticky) */
|
|
42
|
+
int direct; /* 1 when the span is an anonymous mmap owned by the
|
|
43
|
+
* arena — destroy must munmap, not park or free */
|
|
42
44
|
} LeptrisArena;
|
|
43
45
|
|
|
44
46
|
/* Create an arena of `size` bytes (one malloc). Returns NULL on
|
|
@@ -59,6 +61,14 @@ void leptris_arena_destroy(LeptrisArena* arena);
|
|
|
59
61
|
/* Release retained arena blocks (leptris_thread_cleanup drain). */
|
|
60
62
|
void leptris_arena_retain_drain(void);
|
|
61
63
|
|
|
64
|
+
/* #1947 lever 2: spans above the retain budget never park, so they
|
|
65
|
+
* bypass the libc allocator — anonymous mmap on acquire, munmap on
|
|
66
|
+
* destroy — and a dropped document's pages return to the OS
|
|
67
|
+
* deterministically instead of lingering in allocator magazines.
|
|
68
|
+
* Internal observability for specs; not part of the public ABI. */
|
|
69
|
+
int leptris_arena_has_direct_spans(void);
|
|
70
|
+
void leptris_arena_span_stats(size_t* direct_taken, size_t* direct_released);
|
|
71
|
+
|
|
62
72
|
/* Bump-allocate `size` bytes, 8-byte aligned. NOT zeroed.
|
|
63
73
|
* Returns NULL when the request does not fit in remaining space —
|
|
64
74
|
* no fallback allocation, ever (see the contract above). */
|
|
@@ -126,6 +126,8 @@ static XsdAssert* xsd_capture_assert(struct leptris_xsd_schema* s,
|
|
|
126
126
|
static XsdCm* xsd_capture_any(LeptrisElement any_child);
|
|
127
127
|
static char* xsd_capture_unit_tns(LeptrisElement e);
|
|
128
128
|
static char* xsd_capture_any_attr_ns(LeptrisElement container);
|
|
129
|
+
static char* xsd_capture_any_attr_ns_deep(
|
|
130
|
+
struct leptris_xsd_schema* s, LeptrisElement container, int depth);
|
|
129
131
|
static char* xsd_capture_any_attr_not_qname(LeptrisElement container);
|
|
130
132
|
|
|
131
133
|
/* #1626: prefixed QName refs (type="w:CT_Border") resolve by local
|
|
@@ -3293,7 +3295,8 @@ static XsdCm* xsd_capture_complex_model(struct leptris_xsd_schema* s,
|
|
|
3293
3295
|
if (!attrs) attrs = xsd_capture_attr_rows(s, ct, 0);
|
|
3294
3296
|
if (!any_attr_unit_ns)
|
|
3295
3297
|
any_attr_unit_ns = xsd_capture_unit_tns(ct);
|
|
3296
|
-
if (!any_attr_ns)
|
|
3298
|
+
if (!any_attr_ns)
|
|
3299
|
+
any_attr_ns = xsd_capture_any_attr_ns_deep(s, ct, 0);
|
|
3297
3300
|
if (!any_attr_not_qname)
|
|
3298
3301
|
any_attr_not_qname = xsd_capture_any_attr_not_qname(ct);
|
|
3299
3302
|
}
|
|
@@ -3623,6 +3626,43 @@ static char* xsd_capture_unit_tns(LeptrisElement e) {
|
|
|
3623
3626
|
return NULL;
|
|
3624
3627
|
}
|
|
3625
3628
|
|
|
3629
|
+
/* leptris#1964: the anyAttribute grammar rides attributeGroup
|
|
3630
|
+
* refs too — attgD019's wildcard lives inside the referenced
|
|
3631
|
+
* group, not the complexType's direct children. Follows refs
|
|
3632
|
+
* (depth-bounded); the group's OWN element is the walk root. */
|
|
3633
|
+
static char* xsd_capture_any_attr_ns_deep(
|
|
3634
|
+
struct leptris_xsd_schema* s, LeptrisElement container,
|
|
3635
|
+
int depth) {
|
|
3636
|
+
if (depth > 8) return NULL;
|
|
3637
|
+
for (LeptrisNodeRef ac = leptris_node_first_child(
|
|
3638
|
+
leptris_element_as_node(container));
|
|
3639
|
+
ac; ac = leptris_node_next_sibling(ac)) {
|
|
3640
|
+
if (leptris_node_get_type(ac) != LEPTRIS_NODE_TYPE_ELEMENT)
|
|
3641
|
+
continue;
|
|
3642
|
+
LeptrisElement ae = (LeptrisElement)ac;
|
|
3643
|
+
const char* al = NULL, *au = NULL;
|
|
3644
|
+
leptris_element_expanded_name(ae, &al, NULL, &au);
|
|
3645
|
+
if (!al || (au && strcmp(au, XSD_NS) != 0)) continue;
|
|
3646
|
+
if (strcmp(al, "anyAttribute") == 0)
|
|
3647
|
+
return xsd_strdup(
|
|
3648
|
+
leptris_element_attribute(ae, "namespace"));
|
|
3649
|
+
if (strcmp(al, "attributeGroup") == 0) {
|
|
3650
|
+
const char* ref = xsd_local_name(
|
|
3651
|
+
leptris_element_attribute(ae, "ref"));
|
|
3652
|
+
if (!ref) continue;
|
|
3653
|
+
XsdAttrGroupDef* g = s->attr_groups;
|
|
3654
|
+
for (; g; g = g->next)
|
|
3655
|
+
if (strcmp(g->name, ref) == 0) break;
|
|
3656
|
+
if (g && g->elem) {
|
|
3657
|
+
char* r = xsd_capture_any_attr_ns_deep(s, g->elem,
|
|
3658
|
+
depth + 1);
|
|
3659
|
+
if (r) return r;
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
return NULL;
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3626
3666
|
static char* xsd_capture_any_attr_ns(LeptrisElement container) {
|
|
3627
3667
|
for (LeptrisNodeRef ac = leptris_node_first_child(
|
|
3628
3668
|
leptris_element_as_node(container));
|
|
@@ -301,6 +301,88 @@ static int text_valid(struct xsd_validator* v,
|
|
|
301
301
|
static void validate_element(struct xsd_validator* v,
|
|
302
302
|
struct leptris_xsd_schema* s,
|
|
303
303
|
LeptrisElement elem, int depth);
|
|
304
|
+
static void xsd_member_canon(const char* mname, char* out, size_t cap) {
|
|
305
|
+
const char* local = mname ? strchr(mname, ':') : NULL;
|
|
306
|
+
local = local ? local + 1 : mname;
|
|
307
|
+
snprintf(out, cap, "xs:%s", local ? local : "");
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* Value-space equality within one union member: numerics compare
|
|
311
|
+
* numerically ("1.0" == "1.000"), booleans identify across the
|
|
312
|
+
* {true,1}/{false,0} spellings, everything else is exact text. */
|
|
313
|
+
static int xsd_value_equal(const char* canon_type, const char* a,
|
|
314
|
+
const char* b) {
|
|
315
|
+
if (strcmp(a, b) == 0) return 1;
|
|
316
|
+
if (strcmp(canon_type, "xs:boolean") == 0) {
|
|
317
|
+
int av = strcmp(a, "true") == 0 || strcmp(a, "1") == 0;
|
|
318
|
+
int bv = strcmp(b, "true") == 0 || strcmp(b, "1") == 0;
|
|
319
|
+
return av == bv;
|
|
320
|
+
}
|
|
321
|
+
if (strcmp(canon_type, "xs:float") == 0 ||
|
|
322
|
+
strcmp(canon_type, "xs:double") == 0)
|
|
323
|
+
return strtod(a, NULL) == strtod(b, NULL);
|
|
324
|
+
if (strstr(canon_type, "int") || strstr(canon_type, "decimal") ||
|
|
325
|
+
strstr(canon_type, "long") || strstr(canon_type, "short") ||
|
|
326
|
+
strstr(canon_type, "byte") ||
|
|
327
|
+
strstr(canon_type, "Negative") || strstr(canon_type, "positive"))
|
|
328
|
+
return strtod(a, NULL) == strtod(b, NULL);
|
|
329
|
+
return 0;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* leptris-rs#45 (stE050/stE055): union-typed fixed constraints
|
|
333
|
+
* compare in the VALUE SPACE of the first union member that
|
|
334
|
+
* validates each lexical form — fixed "1" and instance "true"
|
|
335
|
+
* both validate as xs:boolean (its lexical space accepts "1");
|
|
336
|
+
* "1.0" and "1.000" both as xs:float. Raw strcmp wrongly
|
|
337
|
+
* rejected value-equal forms. Returns 1 when a single member
|
|
338
|
+
* type validates both the fixed value and the instance text. */
|
|
339
|
+
static int xsd_union_fixed_match(struct leptris_xsd_schema* s,
|
|
340
|
+
const XsdSimple* ut, const char* ns,
|
|
341
|
+
const char* fixed, const char* text) {
|
|
342
|
+
if (!ut || ut->deriv != XSD_SIMPLE_UNION) return 0;
|
|
343
|
+
size_t n = ut->member_count > ut->member_def_count
|
|
344
|
+
? ut->member_count
|
|
345
|
+
: ut->member_def_count;
|
|
346
|
+
int fixed_member = -1;
|
|
347
|
+
for (size_t i = 0; i < n && fixed_member < 0; i++) {
|
|
348
|
+
const XsdSimple* def =
|
|
349
|
+
i < ut->member_def_count ? ut->member_defs[i] : NULL;
|
|
350
|
+
const char* mname = i < ut->member_count ? ut->members[i] : NULL;
|
|
351
|
+
int ok;
|
|
352
|
+
char canon[128];
|
|
353
|
+
if (mname) xsd_member_canon(mname, canon, sizeof(canon));
|
|
354
|
+
if (def) {
|
|
355
|
+
ok = xsd_simple_valid_chain(s, def, fixed);
|
|
356
|
+
} else if (mname && strncmp(canon, "xs:", 3) == 0) {
|
|
357
|
+
ok = xsd_builtin_valid(canon, fixed);
|
|
358
|
+
} else if (mname) {
|
|
359
|
+
const XsdSimple* m = xsd_find_simple_ns_pub(s, canon, ns);
|
|
360
|
+
ok = m && xsd_simple_valid_chain(s, m, fixed);
|
|
361
|
+
} else {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (ok) fixed_member = (int)i;
|
|
365
|
+
}
|
|
366
|
+
if (fixed_member < 0) return 0;
|
|
367
|
+
const XsdSimple* def =
|
|
368
|
+
(size_t)fixed_member < ut->member_def_count
|
|
369
|
+
? ut->member_defs[fixed_member]
|
|
370
|
+
: NULL;
|
|
371
|
+
if (def) return xsd_simple_valid_chain(s, def, text) &&
|
|
372
|
+
xsd_value_equal("xs:string", fixed, text);
|
|
373
|
+
const char* mname = (size_t)fixed_member < ut->member_count
|
|
374
|
+
? ut->members[fixed_member]
|
|
375
|
+
: NULL;
|
|
376
|
+
if (!mname) return 0;
|
|
377
|
+
char canon[128];
|
|
378
|
+
xsd_member_canon(mname, canon, sizeof(canon));
|
|
379
|
+
if (strncmp(canon, "xs:", 3) == 0)
|
|
380
|
+
return xsd_builtin_valid(canon, text) &&
|
|
381
|
+
xsd_value_equal(canon, fixed, text);
|
|
382
|
+
const XsdSimple* m = xsd_find_simple_ns_pub(s, canon, ns);
|
|
383
|
+
return m && xsd_simple_valid_chain(s, m, text);
|
|
384
|
+
}
|
|
385
|
+
|
|
304
386
|
static void validate_element_decl(struct xsd_validator* v,
|
|
305
387
|
struct leptris_xsd_schema* s,
|
|
306
388
|
LeptrisElement elem, int depth,
|
|
@@ -913,7 +995,16 @@ static void validate_element_decl(struct xsd_validator* v,
|
|
|
913
995
|
break;
|
|
914
996
|
}
|
|
915
997
|
if (d->fixed) {
|
|
916
|
-
|
|
998
|
+
int match = !has_content || strcmp(text, d->fixed) == 0;
|
|
999
|
+
if (!match) {
|
|
1000
|
+
const XsdSimple* ut =
|
|
1001
|
+
d->type ? xsd_find_simple_ns_pub(s, d->type, d->ns)
|
|
1002
|
+
: NULL;
|
|
1003
|
+
if (ut)
|
|
1004
|
+
match = xsd_union_fixed_match(s, ut, d->ns, d->fixed,
|
|
1005
|
+
text);
|
|
1006
|
+
}
|
|
1007
|
+
if (!match)
|
|
917
1008
|
verrfk(v, "content-model", "element", local,
|
|
918
1009
|
"content does not match the fixed value");
|
|
919
1010
|
if (!has_content)
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include <leptris.h>
|
|
9
9
|
#include <leptris/descriptor.h>
|
|
10
10
|
#include <cstring>
|
|
11
|
+
#include <cstdio>
|
|
11
12
|
#include <string>
|
|
12
13
|
|
|
13
14
|
namespace {
|
|
@@ -785,6 +786,117 @@ TEST(PlanBuild, CopiesTheSpecStrings) {
|
|
|
785
786
|
leptris_document_free(doc);
|
|
786
787
|
}
|
|
787
788
|
|
|
789
|
+
/* #1967: every spec string the plan carries must be retained past
|
|
790
|
+
* build — the bindings anchor ns_prefix in FFI buffers that die with
|
|
791
|
+
* the build call, so a struct-copied pointer reads freed heap bytes
|
|
792
|
+
* at serialize time. The attr row's ns_prefix missed the dp_strdup
|
|
793
|
+
* the element plans (#1551) and child rows (#1585) already had, and
|
|
794
|
+
* the element plan's copy sat inside the ns_uri branch (a prefix
|
|
795
|
+
* with no URI never copied). Mirrors CopiesTheSpecStrings: the spec
|
|
796
|
+
* buffers are freed right after build, then the plan serializes. */
|
|
797
|
+
TEST(PlanBuild, CopiesAttrAndElementNsPrefixesPastSpecFree) {
|
|
798
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
799
|
+
|
|
800
|
+
/* Heap-anchored like the bindings' FFI::MemoryPointer strings:
|
|
801
|
+
* freed the moment build returns, so a retained pointer reads
|
|
802
|
+
* freed heap bytes. (Stack buffers would survive the whole test
|
|
803
|
+
* and hide the defect.) */
|
|
804
|
+
char* root_prefix_buf = strdup("w");
|
|
805
|
+
char* attr_name_buf = strdup("val");
|
|
806
|
+
char* attr_prefix_buf = strdup("w");
|
|
807
|
+
|
|
808
|
+
leptris_attr_plan* attrs =
|
|
809
|
+
(leptris_attr_plan*)calloc(1, sizeof(leptris_attr_plan));
|
|
810
|
+
attrs[0].wire_name = attr_name_buf;
|
|
811
|
+
attrs[0].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
812
|
+
attrs[0].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
813
|
+
attrs[0].ns_uri = "urn:w";
|
|
814
|
+
attrs[0].ns_prefix = attr_prefix_buf;
|
|
815
|
+
|
|
816
|
+
/* Element plan: prefix WITHOUT a uri — the un-nesting defect. */
|
|
817
|
+
leptris_element_plan* plans =
|
|
818
|
+
(leptris_element_plan*)calloc(1, sizeof(leptris_element_plan));
|
|
819
|
+
plans[0].element_name = "updateFields";
|
|
820
|
+
plans[0].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
821
|
+
plans[0].ns_uri = "urn:w";
|
|
822
|
+
plans[0].ns_prefix = root_prefix_buf;
|
|
823
|
+
plans[0].attribute_count = 1;
|
|
824
|
+
plans[0].attribute_plans = attrs;
|
|
825
|
+
|
|
826
|
+
leptris_plan_spec spec = {};
|
|
827
|
+
spec.abi_version = leptris_plan_abi_version();
|
|
828
|
+
spec.plan_count = 1;
|
|
829
|
+
spec.plans = plans;
|
|
830
|
+
|
|
831
|
+
LeptrisPlan plan = leptris_plan_build(&spec, &st);
|
|
832
|
+
ASSERT_NE(plan, nullptr);
|
|
833
|
+
/* Anchor drop: the bindings free their buffers as soon as build
|
|
834
|
+
* returns. */
|
|
835
|
+
free(attrs);
|
|
836
|
+
free(plans);
|
|
837
|
+
free(root_prefix_buf);
|
|
838
|
+
free(attr_name_buf);
|
|
839
|
+
free(attr_prefix_buf);
|
|
840
|
+
|
|
841
|
+
leptris_plan_row_op ops[3] = {};
|
|
842
|
+
ops[0].kind = LEPTRIS_PLAN_OP_ELEMENT;
|
|
843
|
+
ops[0].row_index = 0xFFFFFFFFu;
|
|
844
|
+
ops[1].kind = LEPTRIS_PLAN_OP_ATTR;
|
|
845
|
+
ops[1].row_index = 0;
|
|
846
|
+
ops[1].name = "val";
|
|
847
|
+
ops[1].value = "0";
|
|
848
|
+
ops[1].value_len = 1;
|
|
849
|
+
ops[2].kind = LEPTRIS_PLAN_OP_END;
|
|
850
|
+
|
|
851
|
+
/* Two serializations: the first may still read live bytes; the
|
|
852
|
+
* second runs after churn has had a chance to reuse the freed
|
|
853
|
+
* buffers' memory. */
|
|
854
|
+
for (int round = 0; round < 2; round++) {
|
|
855
|
+
if (round == 1) {
|
|
856
|
+
/* Churn through the plan-build allocation paths
|
|
857
|
+
* themselves (the repro that surfaced #1967): build and
|
|
858
|
+
* drop descriptors so their internal dp_strdup traffic
|
|
859
|
+
* consumes and rewrites the freed anchor chunks. Plain
|
|
860
|
+
* strdup cycles do not reliably reuse them under
|
|
861
|
+
* macOS's nano allocator. */
|
|
862
|
+
for (int i = 0; i < 50; i++) {
|
|
863
|
+
leptris_element_plan churn_plans[8] = {};
|
|
864
|
+
leptris_child_plan churn_kids[8][1] = {};
|
|
865
|
+
for (int j = 0; j < 8; j++) {
|
|
866
|
+
churn_plans[j].element_name = "elem";
|
|
867
|
+
churn_plans[j].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
868
|
+
churn_plans[j].ns_uri = "urn:w";
|
|
869
|
+
churn_plans[j].ns_prefix = "wx";
|
|
870
|
+
churn_plans[j].child_count = 1;
|
|
871
|
+
churn_plans[j].child_plans = churn_kids[j];
|
|
872
|
+
churn_kids[j][0].wire_name = "CT_RPr";
|
|
873
|
+
churn_kids[j][0].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
874
|
+
churn_kids[j][0].child_plan_index = -1;
|
|
875
|
+
}
|
|
876
|
+
leptris_plan_spec churn_spec = {};
|
|
877
|
+
churn_spec.abi_version = leptris_plan_abi_version();
|
|
878
|
+
churn_spec.plan_count = 8;
|
|
879
|
+
churn_spec.plans = churn_plans;
|
|
880
|
+
LeptrisPlan churned = leptris_plan_build(&churn_spec, &st);
|
|
881
|
+
ASSERT_NE(churned, nullptr);
|
|
882
|
+
leptris_plan_free(churned);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
LeptrisPlanResult r =
|
|
886
|
+
leptris_plan_result_build(plan, ops, 3, &st);
|
|
887
|
+
ASSERT_NE(r, nullptr);
|
|
888
|
+
char* out = leptris_plan_serialize(plan, r, &st);
|
|
889
|
+
ASSERT_NE(out, nullptr);
|
|
890
|
+
EXPECT_STREQ(out,
|
|
891
|
+
"<w:updateFields xmlns:w=\"urn:w\" w:val=\"0\"/>")
|
|
892
|
+
<< "round " << round;
|
|
893
|
+
leptris_free_string(out);
|
|
894
|
+
leptris_plan_result_free(r);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
leptris_plan_free(plan);
|
|
898
|
+
}
|
|
899
|
+
|
|
788
900
|
TEST(PlanAccessors, NullTolerant) {
|
|
789
901
|
EXPECT_EQ(leptris_plan_value_kind(nullptr), LEPTRIS_PLAN_VALUE_ELEMENT);
|
|
790
902
|
EXPECT_EQ(leptris_plan_value_name(nullptr), nullptr);
|
|
@@ -2674,6 +2786,105 @@ TEST(Plan1941, ResultBuildExplicitRowBindingBeatsInheritance) {
|
|
|
2674
2786
|
leptris_plan_free(plan);
|
|
2675
2787
|
}
|
|
2676
2788
|
|
|
2789
|
+
// ---- leptris#1969: prefix-less EXACT rows are the DEFAULT xmlns --
|
|
2790
|
+
// ns_form EXACT with ns_uri but NO ns_prefix binds the default
|
|
2791
|
+
// namespace: the element emits a bare local name and hoists
|
|
2792
|
+
// xmlns="uri". The declaration appears once on the output root;
|
|
2793
|
+
// same-uri descendants inherit it (no re-declare); a deeper
|
|
2794
|
+
// different default re-declares. Attribute rows never default-bind
|
|
2795
|
+
// (pinned by the Plan1486 cases — the attr row's ns_prefix gate).
|
|
2796
|
+
|
|
2797
|
+
TEST(Plan1969, ResultBuildEmitsDefaultXmlnsOnRoot) {
|
|
2798
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2799
|
+
leptris_child_plan kids[1] = {};
|
|
2800
|
+
kids[0].wire_name = "p";
|
|
2801
|
+
kids[0].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
2802
|
+
kids[0].child_plan_index = -1;
|
|
2803
|
+
kids[0].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
2804
|
+
kids[0].ns_uri = "urn:w";
|
|
2805
|
+
|
|
2806
|
+
leptris_element_plan plans[1] = {};
|
|
2807
|
+
plans[0].element_name = "document";
|
|
2808
|
+
plans[0].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
2809
|
+
plans[0].ns_uri = "urn:w";
|
|
2810
|
+
plans[0].child_count = 1;
|
|
2811
|
+
plans[0].child_plans = kids;
|
|
2812
|
+
|
|
2813
|
+
leptris_plan_spec spec = {};
|
|
2814
|
+
spec.abi_version = leptris_plan_abi_version();
|
|
2815
|
+
spec.plan_count = 1;
|
|
2816
|
+
spec.plans = plans;
|
|
2817
|
+
LeptrisPlan plan = leptris_plan_build(&spec, &st);
|
|
2818
|
+
ASSERT_NE(plan, nullptr);
|
|
2819
|
+
|
|
2820
|
+
leptris_plan_row_op ops[] = {
|
|
2821
|
+
{LEPTRIS_PLAN_OP_ELEMENT, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2822
|
+
{LEPTRIS_PLAN_OP_SCALAR, 0, 0, NULL, "x", 1},
|
|
2823
|
+
{LEPTRIS_PLAN_OP_END, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2824
|
+
};
|
|
2825
|
+
LeptrisPlanResult r = leptris_plan_result_build(plan, ops, 3, &st);
|
|
2826
|
+
ASSERT_NE(r, nullptr);
|
|
2827
|
+
char* out = leptris_plan_serialize(plan, r, &st);
|
|
2828
|
+
ASSERT_NE(out, nullptr);
|
|
2829
|
+
EXPECT_STREQ(out, "<document xmlns=\"urn:w\"><p>x</p></document>");
|
|
2830
|
+
leptris_free_string(out);
|
|
2831
|
+
leptris_plan_result_free(r);
|
|
2832
|
+
leptris_plan_free(plan);
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
TEST(Plan1969, ResultBuildNestedDefaultRedeclaresDifferentUri) {
|
|
2836
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
2837
|
+
leptris_child_plan a_kids[1] = {};
|
|
2838
|
+
a_kids[0].wire_name = "b";
|
|
2839
|
+
a_kids[0].kind = LEPTRIS_PLAN_KIND_NESTED;
|
|
2840
|
+
a_kids[0].child_plan_index = 1;
|
|
2841
|
+
|
|
2842
|
+
leptris_child_plan b_kids[1] = {};
|
|
2843
|
+
b_kids[0].wire_name = "c";
|
|
2844
|
+
b_kids[0].kind = LEPTRIS_PLAN_KIND_SCALAR;
|
|
2845
|
+
b_kids[0].child_plan_index = -1;
|
|
2846
|
+
|
|
2847
|
+
leptris_element_plan plans[2] = {};
|
|
2848
|
+
plans[0].element_name = "a";
|
|
2849
|
+
plans[0].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
2850
|
+
plans[0].ns_uri = "urn:1";
|
|
2851
|
+
plans[0].child_count = 1;
|
|
2852
|
+
plans[0].child_plans = a_kids;
|
|
2853
|
+
plans[1].element_name = "b";
|
|
2854
|
+
plans[1].ns_form = LEPTRIS_PLAN_NS_EXACT;
|
|
2855
|
+
plans[1].ns_uri = "urn:2";
|
|
2856
|
+
plans[1].child_count = 1;
|
|
2857
|
+
plans[1].child_plans = b_kids;
|
|
2858
|
+
|
|
2859
|
+
leptris_plan_spec spec = {};
|
|
2860
|
+
spec.abi_version = leptris_plan_abi_version();
|
|
2861
|
+
spec.plan_count = 2;
|
|
2862
|
+
spec.plans = plans;
|
|
2863
|
+
LeptrisPlan plan = leptris_plan_build(&spec, &st);
|
|
2864
|
+
ASSERT_NE(plan, nullptr);
|
|
2865
|
+
|
|
2866
|
+
leptris_plan_row_op ops[] = {
|
|
2867
|
+
{LEPTRIS_PLAN_OP_ELEMENT, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2868
|
+
{LEPTRIS_PLAN_OP_ELEMENT, 0, 0, NULL, NULL, 0},
|
|
2869
|
+
{LEPTRIS_PLAN_OP_SCALAR, 1, 0, NULL, "x", 1},
|
|
2870
|
+
{LEPTRIS_PLAN_OP_END, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2871
|
+
{LEPTRIS_PLAN_OP_END, 0, UINT32_MAX, NULL, NULL, 0},
|
|
2872
|
+
};
|
|
2873
|
+
LeptrisPlanResult r = leptris_plan_result_build(plan, ops, 5, &st);
|
|
2874
|
+
ASSERT_NE(r, nullptr);
|
|
2875
|
+
char* out = leptris_plan_serialize(plan, r, &st);
|
|
2876
|
+
ASSERT_NE(out, nullptr);
|
|
2877
|
+
/* b's nested row inherits its child plan's DEFAULT binding —
|
|
2878
|
+
* urn:2 differs from the in-scope urn:1, so b re-declares; c
|
|
2879
|
+
* inherits urn:2 and spells bare. */
|
|
2880
|
+
EXPECT_STREQ(out,
|
|
2881
|
+
"<a xmlns=\"urn:1\"><b xmlns=\"urn:2\">"
|
|
2882
|
+
"<c>x</c></b></a>");
|
|
2883
|
+
leptris_free_string(out);
|
|
2884
|
+
leptris_plan_result_free(r);
|
|
2885
|
+
leptris_plan_free(plan);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2677
2888
|
TEST(Plan408, ResultBuildRejectsBadPrograms) {
|
|
2678
2889
|
LeptrisStatus st = LEPTRIS_OK;
|
|
2679
2890
|
leptris_element_plan plans[1] = {};
|
|
@@ -415,3 +415,112 @@ TEST(LeptrisArena, SameSizeReuseSurvivesMixedSizeTraffic) {
|
|
|
415
415
|
leptris_arena_destroy(h);
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
+
|
|
419
|
+
// ---- #1947 lever 2: oversized spans bypass the libc allocator ------
|
|
420
|
+
// A span above the retain budget can never be parked (retain_give
|
|
421
|
+
// frees it unconditionally), so acquiring it through malloc buys
|
|
422
|
+
// nothing and the freed pages linger in allocator magazines — the
|
|
423
|
+
// ~2 GB post-drop residency the CityGML pipeline reports. Spans over
|
|
424
|
+
// ARENA_RETAIN_MAX_BYTES are taken mmap-direct and returned with
|
|
425
|
+
// munmap on destroy, so the drop face collapses RSS deterministically.
|
|
426
|
+
//
|
|
427
|
+
// The stats hook counts direct spans; it is internal (arena.h) — the
|
|
428
|
+
// public ABI surface is untouched.
|
|
429
|
+
TEST(ArenaDirectSpans, OversizedCreateGoesDirectNotMalloc) {
|
|
430
|
+
#if defined(ARENA_TESTS_ASAN)
|
|
431
|
+
GTEST_SKIP() << "direct spans disabled under ASAN (malloc path keeps UAF visible)";
|
|
432
|
+
#endif
|
|
433
|
+
if (!leptris_arena_has_direct_spans())
|
|
434
|
+
GTEST_SKIP() << "platform has no anonymous-mmap span path";
|
|
435
|
+
leptris_arena_retain_drain();
|
|
436
|
+
size_t taken0 = 0, released0 = 0;
|
|
437
|
+
leptris_arena_span_stats(&taken0, &released0);
|
|
438
|
+
|
|
439
|
+
const size_t kBig = 128u * 1024u * 1024u; /* > ARENA_RETAIN_MAX_BYTES */
|
|
440
|
+
LeptrisArena* a = leptris_arena_create(kBig);
|
|
441
|
+
ASSERT_NE(a, nullptr);
|
|
442
|
+
/* The bump region must still offer the full budget — direct
|
|
443
|
+
* acquisition is a transport swap, not a capacity change. */
|
|
444
|
+
EXPECT_EQ(leptris_arena_remaining(a), kBig);
|
|
445
|
+
|
|
446
|
+
size_t taken1 = 0, released1 = 0;
|
|
447
|
+
leptris_arena_span_stats(&taken1, &released1);
|
|
448
|
+
EXPECT_EQ(taken1, taken0 + 1) << "oversized span was not taken direct";
|
|
449
|
+
EXPECT_EQ(released1, released0);
|
|
450
|
+
leptris_arena_destroy(a);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
TEST(ArenaDirectSpans, OversizedDestroyMunmapsInsteadOfParking) {
|
|
454
|
+
#if defined(ARENA_TESTS_ASAN)
|
|
455
|
+
GTEST_SKIP() << "direct spans disabled under ASAN (malloc path keeps UAF visible)";
|
|
456
|
+
#endif
|
|
457
|
+
if (!leptris_arena_has_direct_spans())
|
|
458
|
+
GTEST_SKIP() << "platform has no anonymous-mmap span path";
|
|
459
|
+
leptris_arena_retain_drain();
|
|
460
|
+
size_t taken0 = 0, released0 = 0;
|
|
461
|
+
leptris_arena_span_stats(&taken0, &released0);
|
|
462
|
+
|
|
463
|
+
const size_t kBig = 128u * 1024u * 1024u;
|
|
464
|
+
LeptrisArena* a = leptris_arena_create(kBig);
|
|
465
|
+
ASSERT_NE(a, nullptr);
|
|
466
|
+
leptris_arena_destroy(a);
|
|
467
|
+
|
|
468
|
+
size_t taken1 = 0, released1 = 0;
|
|
469
|
+
leptris_arena_span_stats(&taken1, &released1);
|
|
470
|
+
EXPECT_EQ(taken1, taken0 + 1);
|
|
471
|
+
EXPECT_EQ(released1, released0 + 1)
|
|
472
|
+
<< "oversized span was parked or freed via libc instead of munmap";
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
TEST(ArenaDirectSpans, StandDownUnderCustomAllocator) {
|
|
476
|
+
#if defined(ARENA_TESTS_ASAN)
|
|
477
|
+
GTEST_SKIP() << "direct spans disabled under ASAN";
|
|
478
|
+
#endif
|
|
479
|
+
if (!leptris_arena_has_direct_spans())
|
|
480
|
+
GTEST_SKIP() << "platform has no anonymous-mmap span path";
|
|
481
|
+
leptris_arena_retain_drain();
|
|
482
|
+
leptris_set_memory_management_functions(
|
|
483
|
+
recycle_counting_alloc, recycle_counting_free);
|
|
484
|
+
g_recycle_allocs = 0;
|
|
485
|
+
g_recycle_frees = 0;
|
|
486
|
+
size_t taken0 = 0, released0 = 0;
|
|
487
|
+
leptris_arena_span_stats(&taken0, &released0);
|
|
488
|
+
|
|
489
|
+
LeptrisArena* a = leptris_arena_create(128u * 1024u * 1024u);
|
|
490
|
+
ASSERT_NE(a, nullptr);
|
|
491
|
+
leptris_arena_destroy(a);
|
|
492
|
+
|
|
493
|
+
size_t taken1 = 0, released1 = 0;
|
|
494
|
+
leptris_arena_span_stats(&taken1, &released1);
|
|
495
|
+
/* Hooked accounting must see the whole cycle — no direct lane. */
|
|
496
|
+
EXPECT_EQ(taken1, taken0);
|
|
497
|
+
EXPECT_EQ(released1, released0);
|
|
498
|
+
EXPECT_EQ(g_recycle_allocs, 1);
|
|
499
|
+
EXPECT_EQ(g_recycle_frees, 1);
|
|
500
|
+
|
|
501
|
+
leptris_arena_retain_drain();
|
|
502
|
+
leptris_set_memory_management_functions(NULL, NULL);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
TEST(ArenaDirectSpans, WithinBudgetSpanNeverGoesDirect) {
|
|
506
|
+
#if defined(ARENA_TESTS_ASAN)
|
|
507
|
+
GTEST_SKIP() << "retain cache disabled under ASAN";
|
|
508
|
+
#endif
|
|
509
|
+
if (!leptris_arena_has_direct_spans())
|
|
510
|
+
GTEST_SKIP() << "platform has no anonymous-mmap span path";
|
|
511
|
+
leptris_arena_retain_drain();
|
|
512
|
+
size_t taken0 = 0, released0 = 0;
|
|
513
|
+
leptris_arena_span_stats(&taken0, &released0);
|
|
514
|
+
|
|
515
|
+
LeptrisArena* a = leptris_arena_create(1u * 1024u * 1024u);
|
|
516
|
+
ASSERT_NE(a, nullptr);
|
|
517
|
+
leptris_arena_destroy(a);
|
|
518
|
+
|
|
519
|
+
size_t taken1 = 0, released1 = 0;
|
|
520
|
+
leptris_arena_span_stats(&taken1, &released1);
|
|
521
|
+
/* Retain-budget spans keep the park-and-reuse lane: the repeated
|
|
522
|
+
* parse fault fix depends on it. */
|
|
523
|
+
EXPECT_EQ(taken1, taken0);
|
|
524
|
+
EXPECT_EQ(released1, released0);
|
|
525
|
+
leptris_arena_retain_drain();
|
|
526
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified">
|
|
3
|
+
<xsd:attribute name="foo" type="xsd:string"/>
|
|
4
|
+
<xsd:attribute name="bar" type="xsd:string"/>
|
|
5
|
+
<xsd:attributeGroup name="attG" id="abc" xmlns:foo="foo" foo:anyattribute="foo">
|
|
6
|
+
<xsd:attribute name="att1" type="xsd:int"/>
|
|
7
|
+
<xsd:anyAttribute namespace="##any" id="anyAtt">
|
|
8
|
+
<xsd:annotation>
|
|
9
|
+
<xsd:documentation> testing </xsd:documentation>
|
|
10
|
+
</xsd:annotation>
|
|
11
|
+
</xsd:anyAttribute>
|
|
12
|
+
</xsd:attributeGroup>
|
|
13
|
+
<xsd:complexType name="attgRef">
|
|
14
|
+
<xsd:attributeGroup ref="attG"/>
|
|
15
|
+
</xsd:complexType>
|
|
16
|
+
<xsd:element name="doc">
|
|
17
|
+
<xsd:complexType>
|
|
18
|
+
<xsd:choice maxOccurs="10">
|
|
19
|
+
<xsd:element name="elem" type="attgRef"/>
|
|
20
|
+
</xsd:choice>
|
|
21
|
+
</xsd:complexType>
|
|
22
|
+
</xsd:element>
|
|
23
|
+
</xsd:schema>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<root>true</root>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<root>1.000</root>
|
|
@@ -88,3 +88,38 @@ TEST(I1958, RedefinedSimpleTypeFacetEnforced) {
|
|
|
88
88
|
leptris_document_free(d);
|
|
89
89
|
leptris_xsd_free(s);
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
// ---- leptris-rs#45: union-typed fixed constraints compare in the
|
|
94
|
+
// union's VALUE SPACE — the first member type validating the fixed
|
|
95
|
+
// lexical must also validate the instance lexical (stE050: "1" and
|
|
96
|
+
// "true" both xs:boolean; stE055: "1.0"/"1.000" both xs:float).
|
|
97
|
+
// Raw strcmp wrongly rejected value-equal forms. Real W3C fixtures
|
|
98
|
+
// (msData/simpleType, vendored under libxml2-cases/stE-union-fixed).
|
|
99
|
+
TEST(XsdUnionFixed, StE050BooleanMemberAcceptsBoth) {
|
|
100
|
+
EXPECT_EQ(validate_case(cases_path("stE-union-fixed/stE050.xsd"),
|
|
101
|
+
cases_path("stE-union-fixed/stE050.xml")),
|
|
102
|
+
1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
TEST(XsdUnionFixed, StE055FloatMemberAcceptsBothSpellings) {
|
|
106
|
+
EXPECT_EQ(validate_case(cases_path("stE-union-fixed/stE055.xsd"),
|
|
107
|
+
cases_path("stE-union-fixed/stE055.xml")),
|
|
108
|
+
1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
TEST(XsdUnionFixed, NonMemberValueStillRejects) {
|
|
112
|
+
/* "2.0" validates through the union (float) but differs from the
|
|
113
|
+
* fixed 1.0 in the value space — the fixed constraint holds. */
|
|
114
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
115
|
+
LeptrisXsdSchema s = leptris_xsd_compile_file(
|
|
116
|
+
cases_path("stE-union-fixed/stE055.xsd").c_str(), &st);
|
|
117
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0);
|
|
118
|
+
const char other[] = "<root>2.000</root>";
|
|
119
|
+
LeptrisDocument d = leptris_parse_string(other, strlen(other), &st);
|
|
120
|
+
ASSERT_NE(d, nullptr);
|
|
121
|
+
EXPECT_EQ(leptris_xsd_validate(s, d), 0)
|
|
122
|
+
<< "fixed 1.0 accepted the value 2.0";
|
|
123
|
+
leptris_document_free(d);
|
|
124
|
+
leptris_xsd_free(s);
|
|
125
|
+
}
|
|
@@ -1230,6 +1230,32 @@ int validate_doc(const char* schema, const char* xml) {
|
|
|
1230
1230
|
return r;
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
1233
|
+
// leptris#1964: the anyAttribute grammar rides attributeGroup
|
|
1234
|
+
// REFS too — attgD019's ##any wildcard lives inside the referenced
|
|
1235
|
+
// group, not the referencing complexType's direct children, so the
|
|
1236
|
+
// type's grammar captured empty and strict admission rejected
|
|
1237
|
+
// attributes the wildcard admits. compile-set variant: the head
|
|
1238
|
+
// (no tns) + the foo-tns member; W3C attgD019 expects VALID.
|
|
1239
|
+
TEST(XsdCompile, StrictAnyAttrGrammarRidesAttributeGroupRefs) {
|
|
1240
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
1241
|
+
const char* paths[] = {
|
|
1242
|
+
LEPTRIS_XSD_CASES_DIR "/attgD019-set/attgD019.xsd",
|
|
1243
|
+
LEPTRIS_XSD_CASES_DIR "/attgD019-set/attgD019a.xsd",
|
|
1244
|
+
};
|
|
1245
|
+
LeptrisXsdSchema s = leptris_xsd_compile_set(paths, 2, &st);
|
|
1246
|
+
ASSERT_NE(s, (LeptrisXsdSchema)0) << "status " << (int)st;
|
|
1247
|
+
const char inst[] =
|
|
1248
|
+
"<doc xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
|
|
1249
|
+
" xmlns:x=\"foo\">"
|
|
1250
|
+
"<elem att1=\"123\" x:foo=\"foo\"/></doc>";
|
|
1251
|
+
LeptrisDocument d = leptris_parse_string(inst, strlen(inst), &st);
|
|
1252
|
+
ASSERT_NE(d, nullptr);
|
|
1253
|
+
EXPECT_EQ(leptris_xsd_validate(s, d), 1)
|
|
1254
|
+
<< leptris_xsd_error_at(s, 0);
|
|
1255
|
+
leptris_document_free(d);
|
|
1256
|
+
leptris_xsd_free(s);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1233
1259
|
TEST(XsdValidate, ValidDocumentPasses) {
|
|
1234
1260
|
EXPECT_EQ(validate_doc(k_v_schema,
|
|
1235
1261
|
"<rows version=\"2\" status=\"ok\">"
|
|
@@ -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.
|
|
4
|
+
"version": "1.9.408",
|
|
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,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: leptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.408.0
|
|
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-11-
|
|
11
|
+
date: 2026-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -1264,6 +1264,8 @@ files:
|
|
|
1264
1264
|
- vendor-src/libleptris/test/xsd/libxml2-cases/anyAttr.importB.1_0.xsd
|
|
1265
1265
|
- vendor-src/libleptris/test/xsd/libxml2-cases/anyAttr1_0.xml
|
|
1266
1266
|
- vendor-src/libleptris/test/xsd/libxml2-cases/anyAttr1_0.xsd
|
|
1267
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/attgD019-set/attgD019.xsd
|
|
1268
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/attgD019-set/attgD019a.xsd
|
|
1267
1269
|
- vendor-src/libleptris/test/xsd/libxml2-cases/attr0_0.xml
|
|
1268
1270
|
- vendor-src/libleptris/test/xsd/libxml2-cases/attr0_0.xsd
|
|
1269
1271
|
- vendor-src/libleptris/test/xsd/libxml2-cases/attruse_0_0.xml
|
|
@@ -1569,6 +1571,10 @@ files:
|
|
|
1569
1571
|
- vendor-src/libleptris/test/xsd/libxml2-cases/src-element2-2_0.xsd
|
|
1570
1572
|
- vendor-src/libleptris/test/xsd/libxml2-cases/src-element3_0.xml
|
|
1571
1573
|
- vendor-src/libleptris/test/xsd/libxml2-cases/src-element3_0.xsd
|
|
1574
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE050.xml
|
|
1575
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE050.xsd
|
|
1576
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE055.xml
|
|
1577
|
+
- vendor-src/libleptris/test/xsd/libxml2-cases/stE-union-fixed/stE055.xsd
|
|
1572
1578
|
- vendor-src/libleptris/test/xsd/libxml2-cases/subst-group-1_0.xsd
|
|
1573
1579
|
- vendor-src/libleptris/test/xsd/libxml2-cases/subst-group-1_1.xml
|
|
1574
1580
|
- vendor-src/libleptris/test/xsd/libxml2-cases/union2_1.xml
|