Repository navigation
feat: per-codec external-context decode entry points (-fno-ctx-members, Phases 1-4) - #18
Merged
Merged
Conversation
…#15) New opt-in codegen flag -fno-ctx-members: generated constructed structs omit the asn_struct_ctx_t _asn_ctx member and carry the ASN_CTX_OFFSET_EXTERNAL sentinel in their specifics (PCTX_DEF/OUT_CTX_OFFSET in asn1c_C.c). Default output is unchanged. Runtime: new asn_struct_external_ctx_t arena (8 inline frames + heap overflow, frames keyed by struct instance address) in constr_TYPE.h/.c, carried in asn_codec_ctx_t.ext_struct_ctx. All decoder ctx fetch sites now go through asn_get_struct_ctx() (arena when present, embedded offset otherwise, clean RC_FAIL on sentinel without arena), free paths and layout guards are sentinel-aware, and per-codec SET prepare helpers take the codec ctx. New entry points ber_decode_ctx() and asn_decode_ctx(); plain ber_decode()/asn_decode() fail cleanly on -fno-ctx-members code. New macros ASN_STRUCT_FREE_CTX/ASN_STRUCT_RESET_CTX (existing free_struct + arena reset). No asn_TYPE_operation_s change. Tests: tests-asn1c-compiler expected output for -P -fno-ctx-members (610-ext-ctx-ber); tests-c-compiler drivers check-610.c (default mode, embedded ctx chunked BER decode) and check-610.-fno-ctx-members.c (ber_decode_ctx full/1B/3B chunked, plain-decode RC_FAIL contract, RESET_CTX re-decode). ChangeLog, man page, design doc status updated. Local verification: tests-asn1c-compiler 14/14, tests-skeletons 70/70, check-610 pair PASS under ASAN/LSAN; generated NetMsg sizeof 104 -> 32. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-authored-by: sleevetosleeve <sleevetosleeve@users.noreply.github.com>
check_fixer (libasn1fix) requires every *.asn1 in tests-asn1c-compiler to carry a -OK./-NP./-SE./-SW. suffix; the new ext-ctx module now does. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-authored-by: sleevetosleeve <sleevetosleeve@users.noreply.github.com>
Add xer_decode_ctx(), jer_decode_ctx(), oer_decode_ctx(), uper_decode_ctx(), aper_decode_ctx() and cbor_decode_ctx() alongside ber_decode_ctx() and the asn_decode_ctx() dispatcher (issue #15). Each stack-copies the codec context and carries the caller-owned asn_struct_external_ctx_t arena in asn_codec_ctx_t.ext_struct_ctx; uper_decode/aper_decode were split into a static *_impl so the plain entry points keep their exact former behavior. Decoder headers declare the arena parameter as struct asn_struct_external_ctx_s * (the tag forward-declared in asn_application.h), since uper/aper_decoder.h are included from asn_internal.h before the constr_TYPE.h typedef is visible. Plain entry points of the resumable codecs (BER/CER, XER, JER, OER) fail with RC_FAIL on -fno-ctx-members output; PER/CBOR plain entry points are unaffected because those decoders never fetch the embedded context at decode time. check-610 now round-trips all seven codecs in both generation modes, including 1-byte chunked XER/JER resumes through the arena. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-authored-by: sleevetosleeve <sleevetosleeve@users.noreply.github.com>
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_ctxdecode entry points for code generated with-fno-ctx-members(issue Feature request: external decode context (-fno-ctx-members) #15):xer_decode_ctx(),jer_decode_ctx(),oer_decode_ctx(),uper_decode_ctx(),aper_decode_ctx(),cbor_decode_ctx(), alongside Phase 0'sber_decode_ctx()/asn_decode_ctx().asn_struct_external_ctx_tarena inasn_codec_ctx_t.ext_struct_ctx, so it reaches every nested decoder through the existing parameter.uper_decode()/aper_decode()were split into a static*_impltaking the arena, so the plain entry points keep their exact former behavior.struct asn_struct_external_ctx_s *(tag forward-declared inasn_application.h):uper_decoder.h/aper_decoder.hare pulled in fromasn_internal.hbefore theconstr_TYPE.htypedef is visible.RC_FAILon-fno-ctx-membersoutput; UPER/APER/CBOR plain entry points are unaffected because those decoders never fetch the embedded context at decode time (PER is single-shot; CBOR/PERctx_offsetuses are layout guards only). The_ctxvariants exist for API symmetry and are exercised for all seven codecs.check-610now round-trips all seven codecs in both generation modes (default and-fno-ctx-members), including 1-byte chunked BER/XER/JER resumes (RC_WMORE) through the arena, plus theASN_STRUCT_RESET_CTXre-decode andasn_decode_ctxdispatcher coverage.sizeof(NetMsg_t)stays 104 (default) vs 32 (-fno-ctx-members).docs/external-ctx-design.md).Related issues
-fno-ctx-members) #15 (feature request:-fno-ctx-membersexternal decode context). Stacked on feat: external decode context for BER/CER (-fno-ctx-members), Phase 0 #17 (Phase 0: BER/CER machinery, arena, flag, codegen).converter-example.c/ PDU-collection onboarding stays deferred until all decoders are onboarded — now all are, so a follow-up can switch those helpers.Type of change
Testing
tests-c-compiler: 94/94 PASS (incl.check-610.candcheck-610.-fno-ctx-members.c, built with ASan+UBSan)tests-skeletons: 70/70 PASS;tests-asn1c-compiler: 14/14 PASS;libasn1fix: 3/3 PASS (check_fixer accepts610-ext-ctx-ber-OK.asn1)asn_decode_ctxand per-codec_ctxentries; plain BER/XER/JER/OER returnRC_FAILon ext code; XER/JER 1-byte chunked resume PASS under ASan/UBSan, no leakstests-rust-compilerfails locally only becausecargo-clippyis not installed in the sandbox (unit tests themselves pass); Rust CI is green on feat: external decode context for BER/CER (-fno-ctx-members), Phase 0 #17 for the same code pathsChecklist
vlm_master(branched off feat: external decode context for BER/CER (-fno-ctx-members), Phase 0 #17, which sits on the test(rust): update C differential fixtures for by-value members #16 merge)