Skip to content

feat: onboard converter-example, document and harden the external ctx (-fno-ctx-members, issue #15) - #21

Merged
sleevetosleeve merged 1 commit into
vlm_masterfrom
vibe/ext-ctx-converter-docs-tests-d2e85d
Nov 27, 2026
Merged

sleevetosleeve merged 1 commit into
vlm_masterfrom
vibe/ext-ctx-converter-docs-tests-d2e85d

Conversation

@sleevetosleeve

Copy link
Copy Markdown
Owner

Summary

  • converter-example onboarded (the last deferred item from the design): it now decodes via asn_decode_ctx() / uper_decode_ctx() / aper_decode_ctx() with a file-scope asn_struct_external_ctx_t arena and frees via ASN_STRUCT_FREE_CTX. Since the arena takes precedence over embedded members when present, the same converter binary works with both default and -fno-ctx-members generated code — verified byte-identical BER/DER/XER/JER/UPER/APER/OER/CBOR round-trips in both modes, incl. 1-byte chunked (-b 1) reads and clean truncation failures.
  • Bug fix found by onboarding — arena frame aliasing: frames were keyed by struct address only, but an inline member at offset 0 (e.g. SEQUENCE { x [1] EXPLICIT ... } wrappers) shares the parent's base address, so parent/child frames collided and EXPLICIT-tag decoding of such wrappers failed under the arena (surfaced by check-BER-retag.sh's Nested fixture; check-CER.sh and check-issue-617.sh too). Frames are now keyed by (struct address, type specifics); asn_ext_ctx_get() / asn_get_struct_ctx() take an extra type_key argument and all 21 fetch sites pass their specs.
  • End-user docs: new README section "External decode context (-fno-ctx-members)" (what it is, size win, arena usage pattern, contract, links) and an expanded -fno-ctx-members entry in doc/man/asn1c.man.md listing all *_decode_ctx entry points.
  • New tests: tests-skeletons/check-ext-ctx.c (arena unit test: inline capacity 8, heap overflow, reset, dual-path fetch, key discrimination); tests-asn1c-smoke/check-ext-ctx.sh (converter-example in both codegen modes × all codecs, chunked reads, truncation, Wrap aliasing vector); Wrap type added to the 610 module with check-610 coverage in both modes and a regenerated -P -fno-ctx-members reference fixture.

Related issues

Type of change

  • New feature
  • Bug fix

Testing

  • Local full suite on this branch (sandbox toolchain): libasn1fix 3/3, tests-asn1c-compiler 14/14, tests-skeletons 71/71 (incl. new check-ext-ctx), tests-c-compiler 94/94 (incl. check-610 both modes with Wrap), tests-asn1c-smoke 43/43 (incl. new check-ext-ctx.sh), f1ap/ioc-v2x/ieee1609-ioc 1/1 each, tests-randomized green in the prior run and 16+/20 with 0 failures at commit time (slow bundles; default codegen path untouched by the keying change). The three smoke tests that caught the aliasing bug (check-BER-retag, check-CER, check-issue-617) pass again after the fix.
  • tests-rust-compiler cannot run fully in the sandbox (no cargo-clippy); its unit tests pass and the change does not alter default codegen output.

Checklist

  • Up to date with vlm_master
  • CI passes (once Actions is enabled)
  • Docs/ChangeLog updated if behavior changed

… (issue #15)

- converter-example.c now decodes through asn_decode_ctx()/uper_decode_ctx()/
  aper_decode_ctx() with a file-scope asn_struct_external_ctx_t arena and frees
  via ASN_STRUCT_FREE_CTX, so the generated converter works unchanged with
  both default and -fno-ctx-members code, including chunked RC_WMORE input.
- Fix arena frame aliasing: frames are now keyed by (struct address, type
  specifics) instead of the address alone. An inline member at offset 0
  (single-member SEQUENCE wrapper) shares the parent base address, which
  aliased parent/child frames and broke EXPLICIT-tag decoding of such
  wrappers (found via check-BER-retag Nested fixture).
  asn_ext_ctx_get()/asn_get_struct_ctx() take an extra type_key argument;
  all 21 decoder fetch sites pass their specs.
- Docs for end users: README section "External decode context
  (-fno-ctx-members)" and an expanded -fno-ctx-members entry in
  doc/man/asn1c.man.md listing all *_decode_ctx entry points.
- Tests: tests-skeletons/check-ext-ctx.c (arena helpers: inline capacity,
  heap overflow, reset, dual-path fetch, key discrimination);
  tests-asn1c-smoke/check-ext-ctx.sh (converter-example round-trips all
  codecs in both codegen modes, 1-byte chunked reads, truncation, Wrap
  aliasing vector); Wrap type added to the 610 module with check-610 tests
  in both modes and a regenerated -P reference fixture.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

Co-authored-by: sleevetosleeve <sleevetosleeve@users.noreply.github.com>
@sleevetosleeve
sleevetosleeve marked this pull request as ready for review November 27, 2026 13:57
@sleevetosleeve
sleevetosleeve merged commit 525c3c4 into vlm_master Nov 27, 2026
@sleevetosleeve
sleevetosleeve deleted the vibe/ext-ctx-converter-docs-tests-d2e85d branch November 27, 2026 13:57
sleevetosleeve added a commit that referenced this pull request Nov 28, 2026
…rtem

The -fno-ctx-members entry in asn1c -h printed a literal \n because the
usage string used an escaped backslash-n (\\n) instead of a newline.
Verified against a fresh build: the line now wraps correctly.

Also adds docs/issue-15-postmortem.md recording the external decode context
feature lifecycle: the arena frame-aliasing bug caught only when
converter-example was onboarded (#21) and the allocator-macro escape caught
downstream (#22), why the harnesses missed both, and what would catch them
earlier. Follows the existing docs/issue-NNN-*.md review pattern.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

Co-authored-by: sleevetosleeve <sleevetosleeve@users.noreply.github.com>
sleevetosleeve added a commit that referenced this pull request Nov 28, 2026
…rtem

The -fno-ctx-members entry in asn1c -h printed a literal \n because the
usage string used an escaped backslash-n (\\n) instead of a newline.
Verified against a fresh build: the line now wraps correctly.

Also adds docs/issue-15-postmortem.md recording the external decode context
feature lifecycle: the arena frame-aliasing bug caught only when
converter-example was onboarded (#21) and the allocator-macro escape caught
downstream (#22), why the harnesses missed both, and what would catch them
earlier. Follows the existing docs/issue-NNN-*.md review pattern.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>

Co-authored-by: sleevetosleeve <sleevetosleeve@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants