Repository navigation
Read information objects, check values against their types, and add CHARACTER STRING - #25
Merged
Merged
Conversation
…UNIQUE and DEFAULT ObjectClassField gains class_name, optional, unique and default, last in its fields, for the object and object-set fields of X.681 9 and the keywords the parser reads and throws away. The parser does not set them yet. A compiled specification never has them, so .asni files are as they were, and .asnst files are of version 1.2. The tables of kinds, the syntax tree of asnkitrt.syntax and the documentation have the fields, and the .asnst fixtures, the examples and the golden cases are made again. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…kinds of their fields A field of a class is now a type field, a value field, an object field or an object-set field, and the parser keeps its class, OPTIONAL, UNIQUE and DEFAULT. Whether the name after a field is a class or a type is told once all modules are parsed, by looking it up across imports, so a class may be imported or defined later. A field whose type is another field and a value-set field are refused with an error that says so. Objects are read again with their class, in the syntax of the class or with its fields, by the kind of each field rather than by the case of its name: a type setting may be Module.Type, an object setting is a name or an object in place, and an object-set setting is an ObjectSet with names, objects in place and an extension marker. An object that cannot be read stays as it was. Objects in objects count towards the limit on depth, and one is read once however often a syntax tries it. The compiler leaves object and object-set fields out of the classes, which no type can use, so .asni files are as they were. A type that names one is told so. The tests, the fuzz seeds, the golden cases, the .asnst fixtures and the documentation follow. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
asnkit-compiler gains information_objects() and the module information: the classes, the objects and the object sets of a specification with the work of reading them done. Each object has a setting for each field, with the defaults of its class; a type setting tells a plain reference to a type assignment, past imports, from anything else; a value setting is read again with the type of its field, with value references followed; an object set is flattened, the sets in it opened and each object once. What could not be resolved is told for each object and set, with a reason and a place. It is not yet stable, for the RPC packages to build on. The names objects and sets have of one another are followed once each, in an order in which each comes after those it names, and an object or a set that is in itself, however far, is an error. So are two objects of a set with the same value of a UNIQUE field. Objects that are wrong are warned of, as RecursiveType is: a class, a type or an object that does not exist, an object that does not follow the syntax of its class, a setting of the wrong kind or not of its type, and a mandatory field with no setting. What the compiler cannot read is not warned of. EXCEPT, ALL EXCEPT, ^ and INTERSECTION in object sets are read as an UnsupportedValue, where EXCEPT was a syntax error and ^ a union. The text of a value setting is kept, out of the tree, to read it again. Every specification of the tests and the examples that compiled still does, to the same .asni bytes. The tests, the fuzz seeds, the changelog and the documentation follow. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…hat they mean The view of the information objects held each object and set by value, and copied it wherever it was named, so an object that named another twice, a set that had another twice and the defaults of classes that named one another doubled with each level: a file of 24 lines took all the memory. Every compile built it. Each name was looked up by scanning all the assignments, and a long chain of objects by name ran out of stack. Now each object and set is held once, in objects and object_sets of InformationObjects, and is named by an ObjectId or an ObjectSetId in a setting, a set or a default. Objects, sets and the defaults of object fields are resolved once each, in an order in which each comes after what it names, without recursion through names. An object or a set tells in one line of its own that one in it is not resolved, rather than copying what is not. Objects in objects are followed 64 levels deep, by name as in place, and the sets of a specification have 2^20 objects in all at most, and objects with the same value of a UNIQUE field are compared for 2^20 steps: what is beyond is not resolved, and not told of. The check of UNIQUE compared values as written, without the modules their names are in, and called two objects the same by the text of the types written in them. Values are now told with the names in them looked up where they are written, OBJECT IDENTIFIERs by their arcs, and types written in place with the modules of their names. Two objects are surely the same, surely different, or not known: one object of a set only when surely the same, and an error only when the values are surely the same and the objects surely different. The error tells the value as it is written. Names are looked up in maps, by lookup.rs, which the reading of objects and the view share; the compiler keeps its own for its messages. The parser told a name assigned twice by comparing it with all those before it, which was most of the time of a large module. capitalize, is_identifier, the list of string types and DEPTH are one each. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…out their places ObjectClassField had a field private to the crate, and ObjectSetAssignment another, so no code outside the crate could make them, and nothing made them otherwise; RawValue had its offset public, and ObjectField its text private. Each took part in PartialEq, so the same class, object or set read in two places of a text was unequal. What the parser keeps of where it found a node, to read it again once all modules are parsed, is now a Source, public and opaque, with Source::default() for a node made by hand, in a field source of ObjectClassField, ObjectClassAssignment, ObjectAssignment, ObjectSetAssignment, RawValue and ObjectField. Two Sources are always equal. The changelog lists each change of the syntax tree of the crate, and tells that members of a type written in an object given with the syntax of its class now have their location in .asnst. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…hing of them
The parser read the dummy parameters of a class, an object or an object
set and threw them away, so the view resolved a parameterized object as
if its dummy parameters were names of the module: the default T of a
parameterized class was the type T of the module, and q {INTEGER: x, T}
was warned of for x and T, which name nothing.
The parser now tells in the Source of a class, an object and an object
set that it has dummy parameters, and of an object that its class is
given with actual parameters. Such a class, object or set, and an
object of a parameterized class, is not resolved, with a reason that
says so, and is not followed for the names in it, which may be dummy
parameters; what has one in it says that it is not resolved. Nothing of
them is warned of, as the README and the changelog said.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…nnot read An object whose settings the reader does not read, as information from objects (e2.&Param, e1.&code, X.681 15), INSTANCE OF, EMBEDDED PDV, a selection type or a type nested deeper than the parser goes, did not match the syntax of its class, and was warned of as ObjectNotOfSyntax. So was one with a setting of the wrong kind, as TYPE 5, which made SettingOfWrongKind, the example of the README, unreachable through the syntax of a class. TIME, OID-IRI and RELATIVE-OID-IRI were types not found. A field given twice was read as given once, and a number or a text for an OCTET STRING, a BIT STRING or a SEQUENCE passed as checked. An object that does not match is now read again: a setting of another kind is kept as it is, and one that can not be read is skipped up to what may come after it, a word of the syntax, a comma or the end, and is an UnsupportedValue. An object that matches so has its settings told of, of the wrong kind or not read, and only one that still does not match is ObjectNotOfSyntax. One too deep to read is not read, and not told of. The built-in types of X.680 the compiler does not support are built-in types of the view. A field given twice is ObjectNotOfSyntax, and the object not resolved. Of the values of the types the view does not convert, the form is checked, and the documentation says that what is in braces is not. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The syntax tree had a value setting of an object, and the value DEFAULT of a field of a class, as it looks without a type: TRUE was the text "TRUE", as "TRUE" was, an OBJECT IDENTIFIER was an UnsupportedValue, and CODE 1.5 was the integer 1, as the conversion of numbers dropped the fraction of a real number wherever it was used: in a value assignment, a DEFAULT of a member and a constraint too. The view read the text of each value again to work around it. Once the class of an object is known, a value setting is now read with the type of its field, through the conversion a value assignment of that type goes through, object identifiers with the built-in type they are; so is the value DEFAULT of a field once the fields are told. A real number stays one everywhere: in a setting it is a ValueNotOfType, and as the bound of a constraint an error, where it was taken for an integer. The view reads the values from the tree, and the text kept for it, ObjectField.source and value_data, are gone; ObjectField is as it was before the object fields. No .asnst or .asni of the tests and the examples changes. The Python reader documents the shapes a setting has, and is tested with each. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…ings they give Each object of the view held a copy of every default of its class, so N objects of a class of K defaults made N times K settings: 2000 objects of a class of 2000 defaults, 156 KB of text, took all the memory. Two objects were compared by looking each field of the class up by name in both, with a String made for each, for one step of the budget, and the reading of objects looked each field up by name among those of the class; a set of 200 objects of a class of 1000 fields took 89 seconds, and an object of 40 000 settings 12. A name found through a chain of imports compared each module passed with those before it. An object now holds the settings it gives, in Object.settings, each with the place of its field, and InformationObjects::setting() gives the setting of a field or the default the object takes; settings() gives all of them and takes_default() tells which. What the defaults of a class tell its objects, how deep and whether resolved, is worked out once for the class. Two objects are compared setting by setting in the order of the fields of their class, by index, and the budget is spent for each pair, each setting, each type looked at and each reference followed, so that it bounds the time; it is 2^24 steps, as each now costs little. The UNIQUE check compares only objects whose values are surely the same. The reader of objects and the view find a field by name in a map made once for each class, a field given twice with a set, and a place in a long line without counting the characters before it. A name imported through a chain of modules is followed in a step for each. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…heir end When the view of the information objects met one of its limits it left what was beyond not resolved and told nothing: a set past the budget of comparisons, past 2^20 objects in all sets, or with objects in objects more than 64 levels deep had a real duplicate accepted, with no warning and exit code 0. Some cuts left no mark even in the view: two types compared for more than 4096 steps, a comparison during which the budget ran out, a type nested deeper than the parser reads, which a cached failure of the parser made look like a setting it does not read. A fourth limit, nowhere documented, followed 32 references at most: past it the type of a field was not known, and "text" passed for a value of an INTEGER (0..5), in silence. Each limit met is now a warning of its own kind, LimitReached, that names the limit, its value, the object or the set and its place, and says what is therefore not checked; the view marks it not resolved, with that reason, also where a comparison is cut short. Of the warnings of one limit the first five are told, and then how many more there are. The limit of steps in a comparison of two types is gone: the budget of the UNIQUE check bounds it. References to values and types are followed to their end, without a limit; a value defined by itself is a ValueNotOfType. A type the parser failed to read for its depth fails so each time it is tried again. The limits are documented, with their values, in the module, the README of the package, the README and the changelog. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…s not read
A type setting with a tag, as [1] INTEGER, was not read at all: the
reader of a setting did not take a tag, which a type assignment, a
member and a SEQUENCE OF take before the type. In the syntax of a
class the object was then read again and the setting skipped up to the
first word of the syntax, so that TYPE [1] SEQUENCE OF INTEGER OF 2
stopped at the first OF and was warned of as not following its syntax.
A tagged DEFAULT of a type field, and an object with a tag in place in
an object set, were syntax errors. The second read skipped anything it
could not read, so { &id 1 junk junk } and { &id TRUE FALSE }, which
were warned of before it, passed in silence; a REAL value, a string
over two lines and an object of a class given with actual parameters
that its class does not read were not read either, the last taken for
a value.
A type setting now takes a tag as any type does, and a tagged reference
is a ReferenceWith. The second read skips only a setting that begins a
form the reader knows it does not read: information from objects,
INSTANCE OF, EMBEDDED PDV, a selection type, and a name given actual
parameters; what else does not match is ObjectNotOfSyntax. A setting
skipped is tried to end before each word of the syntax after it, 16
places at most, until the rest matches, and an object that needs more
meets a limit, which is told. A real number of a REAL field is a value
of it, and a string spans lines in an object and a default (X.680
12.14). An object of a class given with actual parameters is an
object, not resolved, and named in a setting it is not warned of.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…tree
A parameterized object, set or class was in .asnst as if plain: in
po{C:x} C ::= { ID 1 O x } and PSet{C:x} C ::= { x | ... } the x was a
name, and nothing told that it is a dummy parameter. Only the hidden
Source of the crate knew, and as two Sources are always equal, po{C:x}
was equal to po. An object set of a class given with actual
parameters was a syntax error.
ObjectClassAssignment, ObjectAssignment and ObjectSetAssignment now
have parameters = null, last in their fields, a list of Parameter
nodes as a type has, and the last two actual_parameters = null after
it, the actual parameters of their class as a ReferencedType has them.
RawValue has both too. Source keeps the offsets only. A compiled class
never has parameters, so .asni files do not change. The five tables of
kinds, the Python reader and the documentation have the fields; .asnst
stays at version 1.2. No fixture, example or golden case changes; a
test of the Python reader adds one fixture.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…ther type
SET { a INTEGER, b BOOLEAN } and SET { b BOOLEAN, a INTEGER } were
surely different types to the check of UNIQUE values, so two objects
with them and the same value of a UNIQUE field were an error, although
where tags are not automatic they are the same type. The members of a
SET or a CHOICE with the same names in another order are now not told
apart, and members of other names still are.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…zers with the new shapes
A member of an object set given actual parameters, as Set{o}, or that
is objects of objects, as o.&Errors (X.681 15), was a syntax error,
although both are valid ASN.1 that the compiler only does not resolve.
Each is now an UnsupportedValue, as EXCEPT is, and the view tells that
the set is not resolved, without a warning.
The corpus of the fuzzers has tagged type settings, settings that are
skipped and may end at a word of the syntax, strings over lines, real
numbers, parameterized classes, objects and sets, classes given actual
parameters, members of a SET in another order, and a class of many
defaults with many objects that take them; the dictionary has the new
words. Two cases in tests/fuzzed.rs hold a skipped setting with 10 000
words of the syntax in it, in nested objects, to a few tries, and
parameters given in each place to be read and not told of.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The entry of information_objects() still said the settings of each object came with the defaults of its class, and listed the limits with one "and" too many. It now says that a default is held once, names comparison_steps(), and lists the five limits in one sentence. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…et --quiet leave it out What is valid ASN.1 that the compiler does not read in an information object, an object set or a class, as a parameterized object, EXCEPT in a set, a class of X.681 Annex A, a name imported from a module that is not given, information from objects or an integer too large, was not resolved in the view and told nothing when compiling. Staying silent hid what was not checked. Each is now a warning of its own kind, NotRead, apart from those that say the specification is wrong and from LimitReached: it tells what is not read, where, in what form, and what is therefore not checked, as the UNIQUE fields of a set. It is told once for each assignment, with how many more there are in it, and once for each module not given that names are imported from; what has such an object or a set in it is not told of again, as the first warning says that what has it is not checked for it. asnkit_compiler::NOT_READ is its kind. asnkitcc takes --quiet with compile, generate and schema, which leaves out the warnings of NotRead and prints the others and the errors; the library still gives them all. Of the specifications of the repository, only tests/files/ietf/rfc3447.asn has one, for six names imported from NIST-SHA2, which is not given. The tests that held these forms to be told nothing now hold each to its warning, and .asni files are as they were. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
What the defaults of a class tell its objects, worked out once for the class, resolved each default of it. An object in a default of an object field of the same class, nested deeper than the parser reads, so asked for the default being resolved, which asked again, until the stack ran out: h_deepdefault_70 of the first review overflowed, where d34527c compiled it. A default being resolved is now left out of what is worked out for the objects in it, which give that field or would be in themselves, and what is so worked out is not kept. The input meets the limits of the depth read and of objects followed, which are told. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A value that was not of its type compiled: a DEFAULT of a member, a
value assignment, a number of a named number, a named bit or an item
given by reference, and a single value of a constraint were truncated,
passed through to the .asni file as written, or dropped. Since d34527c
stopped truncating real numbers, x INTEGER ::= 1.5, and x as the number
of an item, of a bit or of a named number, went into the .asni file as
1.5, which the runtimes for Python and Rust could not load or use. A
setting of an information object that was not of the type of its
field was a warning, ValueNotOfType, of a check of its own, which took
a value by reference for one of the type of the field: &n vsix, where
vsix T ::= six and T ::= INTEGER { six(6) }, was told as no value.
The check is now one, values.rs, which the compiler and the view of
the information objects share. A value is judged by the type it is
written for, followed through references, tags and constraints, and a
value by reference by the type of the value it names, and then by the
type it is written for. A real number is never an INTEGER, even 2.0,
and an integer is a REAL. A value outside a constraint is refused only
where the constraint is told in full: single values, ranges and SIZE of
a root that is not extensible, on the type and the types it refers to.
Also refused: two named bits with the same number, two items given the
same number by reference, two named numbers, bits or items of one name,
and a constraint of a form its type can not have, as IA5String (5) or
BOOLEAN (SIZE (1)). What the compiler can not follow is not judged: a
dummy parameter, a type given actual parameters, a value it does not
read; in an object it is not resolved and told as a NotRead. A setting
that is surely not of its type is an error, as any such value is, and
ValueNotOfType is no more.
A value assignment keeps its type as written in its Source, which the
tree has the name of only, and one in braces of a type that is not a
class keeps its name. TRUE and FALSE written for an INTEGER are the
booleans they are in the tree, where they were texts, so that they are
told as written. Every specification of the tests and the examples
that compiled before still does, with the same .asni file, but for the
two left out here: SIZE of an INTEGER, which tests/files/all_types.asn
has, and two named numbers of one number, which a test of the fuzzer
has, for the owner of the repository to decide.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…hem take --quiet asnkitcc convert, and asnkitcc schema without --any-defined-by, compile the ASN.1 files they are given with compile_to_asni(), which left out the warnings of the compiler: what compile tells of a specification was told nothing of by them. They now compile with the warnings and print them as compile does, on standard error, and convert takes --quiet, as schema did already, which leaves out the warnings of NotRead only. The tests of schema read the error of a command after the warnings it tells first. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
An object given as an actual parameter of a parameterized type, as
P { { ID 2 TYPE INSTANCE OF X } }, or in a set given as one, that the
parser could not read with its class was left as its text, an
UnresolvedObject, and nothing was told: what the type was made of it
was not checked, in silence.
The view of the information objects now looks at the actual parameters
of the types of each type assignment, of its members and of its
elements, and tells each such parameter as a NotRead, once for each
type assignment, with how many more there are in it, as the others are.
An object the parser reads is not told of.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…ects
A string may span lines (X.680 12.14), and is then without the line
breaks and the spaces before and after each. The parser read one so in
an information object and in a default of a field of a class, but a
value assignment and a DEFAULT of a member were syntax errors, and in
a value in braces, as { a "ab<line break> cd" }, in an object too, the
line break and the spaces were kept in the string.
A value assignment and a DEFAULT now read it as an object does, and the
text of a value in braces is read with the same rule. Every .asni and
.asnst file of the tests and the examples is as it was.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A value of an information object is read with the built-in type its field is, which the parser found by following the references from the type of the field, for each value read, and with each step compared with all those before it, to tell a type defined by itself. Fields of a type behind a long way of references took time that grew with their number and with the square of the length of the way: 200 fields behind 8000 references took 34 seconds, and 800 behind 1000 fourteen times as long as 50. The name of the built-in type is now kept for each type on a way the first time it is followed, in the parser and in the view, and a type passed is told by a set. The same input takes 0.6 seconds, and the test of the cost holds sixteen times the fields to less than four times the time. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The two checks of 5cbfd96 that were left out, as a specification of the
tests had each, are now in. SIZE is refused in a constraint of any type
that is not a bit string, an octet string, a character string, a
SEQUENCE OF or a SET OF (X.680 51.5.1): of an INTEGER, as the others it
was refused of already, and of DATE, TIME-OF-DAY, DATE-TIME, DURATION,
TIME, EXTERNAL and EMBEDDED PDV. UTCTime, GeneralizedTime,
ObjectDescriptor and CHARACTER STRING are character strings and take
it. Two named numbers of an INTEGER with the same number are refused
(X.680 19.4), as two named bits are.
Zero written with a minus, as -0 or -00, as the number of a named
number or of an item of an enumeration, is not a SignedNumber (X.680
19) and was taken for 0. It is a parse error that says so.
tests/files/all_types.asn had INTEGER ((1..2 UNION 4..5) ^ SIZE (4)),
which is now INTEGER ((1..2 UNION 4..5) ^ (1..5)): the same union in an
intersection, with the same compiled types. Its golden case has the new
tree of Integer4 and the new SHA-256, and its fixture is made again,
with the same nodes and the header of the new source. The test of the
fuzzer that held INTEGER { m(-0), n(-00) } to compile holds it to an
error, and no panic.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The parser numbered the items of an ENUMERATED that have no number
before the values given by reference were known, and without them:
ENUMERATED { a(zero), b } with zero INTEGER ::= 0 had two items of 0.
After the extension marker, an item without a number took the next
number after the root, and the specification was refused if an item of
the root had it, as ENUMERATED { a, b(2), ..., c, d }; and an item
written with a number not greater than one before it there, as
ENUMERATED { a, ..., c(5), d(3) }, was taken.
The items are numbered by one function, as X.680 20.3 and 20.6 say: in
the root, the smallest numbers from 0 that no item of the root is
written with; after the marker, the smallest that no item of the root
has and that is greater than those before it there. The parser numbers
an enumeration with no number by reference at once, and one with such a
number without it, and once all is parsed it is numbered again with
the values known, followed through imports and values that name
others, in the types, the value assignments, the classes and the
objects. A reference to a dummy parameter is not followed. Two items
with the same number, written or by reference, and an item after the
marker with a number not greater than one before it there, are errors
(X.680 20.2, 20.4, 20.5).
The compiler resolved a number given by reference one step only, so
b(r) with r INTEGER ::= s was compiled as the name s, which no runtime
could load. It follows the way to its end.
No specification of the tests and the examples has an enumeration whose
numbers change: every .asni and .asnst file and every fixture is as it
was. The encodings of the types that do change.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…of constraint of X.680 51
The check of values refused valid ASN.1, crashed on one-line inputs and
could take all the memory with a kilobyte, as a review found:
- An OBJECT IDENTIFIER of two components, the first a name, in another
value, as { algorithm { id-a 3 } }, is read as { name value } of a
SEQUENCE, and was refused. It is read as the components it is.
- A range of a time type, as DATE ("2000-01-01".."2020-12-31"), was
refused, though X.680 51.11 to 51.13 make it a duration range, a time
point range or a recurrence range. The forms of constraint each type
may have are now those of Tables 11 and 12 of X.680 51.1, form by form
and type by type, which a test holds the compiler to: UTCTime (SIZE
(11)), a range in the FROM of a TeletexString and a contained subtype
of EXTERNAL are refused by them too. A single value of a CHOICE in a
constraint, C (a : 1), was a syntax error, and is read.
- A value in itself, as c INTEGER { k(c) } ::= k or a S ::= { a },
overflowed the stack: each followed the values passed on its own way
alone. One set of the values being resolved covers the resolution of
a value, in braces, by reference and through named numbers, and a
value met again is defined by itself, which is an error.
- Values that each name the next in a constraint of their type, as
v0 INTEGER (0..v1), were followed one in another, which overflowed
the stack at 3000. An integer of a constraint or a named number is
read with the kind of the type of each value on the way, and not its
constraints, without going deeper.
- 40 constraints of two ranges each made 2^40 ranges. A set of ranges
is kept in order and merged, no larger than the bounds written.
- A way of 20 000 values took 48 seconds, and 100 000 named numbers
34: each value was resolved again on each way through it, and names
and numbers were compared in pairs. Each value assignment is resolved
once and kept, and names and numbers are found in maps.
- A message quoted the whole value, 1.5 MB, or 30 000 names of a cycle.
It quotes about 120 characters, and five names, and tells how many
more there are.
No input may overflow the stack: values in braces are read 64 levels
deep, as types and constraints are, and deeper is an error that names
the limit; values in values are checked 256 levels deep, and deeper is
a LimitReached, told five times and then counted; ways of references
are followed without going deeper. The compiler works on a thread of
its own of 64 MiB, so that a caller needs no more than 2 MiB, and the
tests of limits and depth run on threads of 2 MiB, where they ran on 8
or 64. The README of asnkit-compiler tells every limit.
Every .asni of the tests, the examples and 157 sets of published
modules is as it was.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…iven
A dummy value in a DEFAULT of a parameterized type, as R {INTEGER:dflt}
::= SEQUENCE { a INTEGER DEFAULT dflt }, was left as it was when the
type was given its actual parameters: R {5} was compiled with the name
dflt as its default, which the runtime for Rust refused the file for.
The types and the defaults of the members of an extension addition
group were not given the actual parameters either.
A default that is a dummy value, or has one in its braces, is the
actual value given, as a value of a default is: TRUE, FALSE and NULL,
which are read as types, are the values they are, and a value by
reference is the boolean, the number or the text it names. A dummy
value is told by its name being in lower case (X.683 8.3). The .asni
files of such types change, and none of the tests, the examples or 157
sets of published modules has one.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…n a default
The defaults of the members of a parameterized type are made what they
name before the type is given its actual parameters, as those of any
type are: a default that names a value is that value, of the module.
A dummy value of the name of a value of the module, as v in
P {INTEGER: v} ::= SEQUENCE { a INTEGER DEFAULT v } with v BOOLEAN ::=
TRUE, was taken for that value, and P {5} was compiled with TRUE as
its default; a dummy type of the name of a type of the module was
taken for that type to read the default with.
A default that is a dummy parameter, or of a member whose type is one,
is left as written until the type is given its actual parameters,
which it is then. No .asni of the tests, the examples or the published
modules changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A value of a type given actual parameters is checked as the type is with them, with the place of the instantiation. NULL for an INTEGER and an OBJECT IDENTIFIER whose components are not numbers of arcs, or that has none, are judged as written, and the names of an OBJECT IDENTIFIER are looked up (X.680 32.3 to 32.7). A character string in braces is looked into (41.8, 41.11 to 41.14). The components of a REAL in braces name values, and a REAL outside a range told in full is refused. A bound by reference of an INTEGER or a SIZE is an INTEGER. A value of a SEQUENCE or a SET gives each member once, and of a SEQUENCE in order (25.20, 27.9); the syntax tree keeps each element of a SEQUENCE OF given by name. A named bit beyond 2^64 - 1 and an item outside -2^63 to 2^63 - 1 are errors that name the limit. UNIQUE values of an OBJECT IDENTIFIER are compared with arcs of any size. A value that can not be checked, outside objects too, is told as a NotRead. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The members of a SEQUENCE or a SET have distinct names, with those of COMPONENTS OF, of groups and after the extension marker (X.680 25.14, which 27.4 takes for a SET), and so have the alternatives of a CHOICE (29.10). Two of one name compiled, and a value took one of them. They are an error that names the second, in a type assignment, in the types in it and in the type of a field of a class. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A number has no zero before its other digits unless it is a single digit (X.680 12.8), and nor has the integer part of a real number (12.9). 007 was taken for 7, wherever it was written: in a tag, a named number, an object identifier, a value or a constraint. The text without comments is looked through before it is parsed, past strings, bit and hexadecimal strings, names, fractions and exponents, and the first such number is a parse error with its place. The test of the fuzzer that held such numbers to compile as the numbers they are holds them to this error, with no panic. -00 is told as such a number before it is told as zero written with a minus. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
X.680 25.5: "Type in the COMPONENTS OF Type notation shall be a sequence type", and 27.2 "a set type" for a SET. COMPONENTS OF an INTEGER, a CHOICE or a SET into a SEQUENCE, or a SEQUENCE into a SET, compiled in silence, also as the type given for a dummy parameter. Each COMPONENTS OF now knows what it takes in, which is held with what is taken in of each type, and anything but a type of the kind of the type it is in is an error that tells what it takes in and the clause. Three tests of mine took a SEQUENCE into a SET; they take a set type. And 25.5: "Only the RootComponentTypeList of the Type in the COMPONENTS OF Type is included". The root of a type is what is before its first extension marker and after its second (25.1, ComponentTypeLists), and what was after the second was not taken in; it is. No compiled file of the corpus or of the 265 sets of published modules changes, and none of them is refused. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
X.680 31.2.7 makes a tag explicit or implicit by "the value of TagDefault for the module", the module the tag is written in; 13.2 takes an empty one as EXPLICIT TAGS. 25.3 selects automatic tagging for a ComponentTypeLists when "none of the occurrences of NamedType in any of the first three alternatives for ComponentType is a textually tagged type", and 25.4 decides it "prior to the COMPONENTS OF transformation": "the application of automatic tags is suppressed by tags textually present in the ComponentTypeLists, but not by tags present in the Type following COMPONENTS OF" (25.4 NOTE). 25.8 applies it after 25.5, and "each occurrence of ComponentType in it is duplicated by the application of 25.5 prior to the possible application of automatic tagging to the referencing sequence type" (25.10 NOTE 3). "Automatic tagging is always implicit tagging unless the Type is a choice type or an open type notation, or a DummyReference" (25.10 NOTE 1, 31.2.7 c). The compiler took in what COMPONENTS OF names as the type was at that time, so that a member from another module had the tags that module had given it, or none, as the modules were worked on in the order of the files: a member a [5] BOOLEAN of a module of IMPLICIT TAGS taken into one of EXPLICIT TAGS was tagged by the default of the taking module, explicitly (base the same); and of a module of AUTOMATIC TAGS taking in a type of another such module, the automatic tags given in that type, if its module came first, were taken for tags written in the list, so that its members were given none. A member taken in is marked so, and loses the tag automatic tagging gave it in its own type, which is marked so too: it is the member as it is written, whatever was done of its type before. A written tag of a member taken in from another module, and the types in it, are tagged by the tagging of that module. Automatic tagging is selected by the tags written in the list alone; it replaces the tag of a member taken in with a tag of its own by one of the same mode, which is what implicit tagging of a tagged type comes to, and gives the others an implicit tag but of a choice type, an open type or a dummy type. So COMPONENTS OF a dummy parameter in a module of AUTOMATIC TAGS, which was refused in every case as the tags of what it takes in could not be told from those written, compiles: the members written of a dummy type are marked as such, and the list is tagged once the type is given its actual parameters, as if what it takes in were written out. The error is no longer needed, nor its advice (B5). tests/tagging.rs has the DER of each, worked out of the standards, in both orders of the modules; each case failed before. No compiled file of the corpus, of the 265 sets of published modules or of the fixtures changes. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A dummy parameter that COMPONENTS OF takes in, given a type written in
place, as P{SEQUENCE { a INTEGER }}, was looked up by the name of its
kind, and was a false error, "Type 'SEQUENCE' not found"; given a type
of another kind, as P{INTEGER}, "Type 'INTEGER' not found". A type
written in place is taken in as it is: the members of its root, or, of
another kind, the error of what COMPONENTS OF may take in (X.680 25.5,
27.2). COMPONENTS OF P0{T} with the dummy T as the actual parameter
compiles already.
The error of COMPONENTS OF SEQUENCE { ... } written in place, which a
syntax tree can not hold as it names the type, said "of which a syntax
tree names the type". It says that asnkit does not read the form, a
limit of asnkit, and to write the type in an assignment of its own and
take that in. No format changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A type given actual parameters was worked out with its actual
parameters in the module of the parameterized type, so that a type
given for a dummy parameter in another module was looked up there once
it was put in the place of the dummy: PT{T} ::= Q{T} of M2 given A in
M1, with Q{U} ::= SEQUENCE { COMPONENTS OF U, y NULL }, took in the A of
M2, or "Type 'A' not found in module 'M2'" without one; the same of a
member m U, wrong at base too. And a member given actual parameters
taken in by COMPONENTS OF from another module, p P{L} of M2, had its
parameterized type and its actual parameters looked up in the module
that takes it in: that module's P and L in silence, or an error.
One rule: a name is looked up in the module where it is written. A type
given actual parameters is worked out in the module it names, which a
member taken in from another module has (of_module()), with its actual
parameters there; and a type given for a dummy parameter in another
module than that of the parameterized type has the names in it marked
with the module it is given in, wherever it is put, also through a
parameterized type that gives it to another. D ::= P{L} across modules
and a value given as an actual parameter from another module were right
already, and are held by the test too.
tests/parameters.rs holds the DER of each, in both orders of the
modules; it failed before. No compiled file of the corpus or of the 265
sets of published modules changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The last commit said its test holds D ::= P{L} across modules and a
value given as an actual parameter from another module, which were
right already; it did not. This test does, in both orders of the
modules: t of D is the L where D is written, and a default given the
value v is the v of that module.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
One value of 4 194 303 integers given once for a dummy value, under the limit of 4 194 304 parts put in defaults, took 1796 MB and 8 s, about 430 bytes an integer. Counted by the allocator, the compiler held at once, of a value of a million integers, 226 MB: the copy the type was given its actual parameters in (the type cloned with its actual parameters, which were cloned again, and the type with them cloned into its place), and, in the writing of the defaults as their values, the types of the module cloned and the default copied as it was read. The actual parameters are taken out of the type rather than cloned, the members of the type with them are moved into its place, the types are worked on one at a time out of their place, which keeps a copy without its defaults for the names that find it, and a default is moved and not copied as it is read: 161 MB of a million, and 1284 MB, not 1796, of the 4 194 303. What is left is the parser's: a value in braces given as an actual parameter is read as an object, which is let go of, and again by its governor, five copies' worth for a moment. Holding one value once until it is written would take a node of the syntax tree shared between the places it is put in, which every reader and writer of values would have to know; that is not done here. So the limit is lowered as the review allows when that cannot be done: 2 097 152 parts of values put in defaults, met at 660 MB at most, and so is the budget of the parts of defaults written as their values. tests/memory.rs counts the heap held at most per integer of one value of 200 000, 195 bytes (237 before); the test of the limit has its new value. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A default the compiler can not resolve, as a name imported from a module that is not given, is written as an UnsupportedValue. The runtimes for Rust, Python and the JVM took it as no default at all, so the member was mandatory: PER, UPER and OER lost its presence bit (X.691 19.2, X.696 16.2), and an encoding that left it out was refused, as DER 3000 of RSASSA-PSS-params was. The only notice was a NotRead, which --quiet hides. Such a member is now a DEFAULT member of which the runtime does not know the value. It keeps its presence bit, every codec takes an encoding that leaves it out, and a value decoded from one does not have it, as with an absent OPTIONAL member. A value given for it is always written, as it is not known to be the default. A default of a NULL is NULL whatever it is written as, in every runtime, as it has no other value. The runtime for Python also refused to load a file with such a default of a BIT STRING or an OCTET STRING, as malformed. tests/files/defaults.asn and defaults.json hold worked encodings, from the standards, that Rust, Python and the JVM are each tested against. The message of the NotRead, the table of defaults in docs/file_formats.md, the README and the changelog say what the runtimes do with such a default. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A default with a value of an open type in it, T : v (X.681 14.6), as hashAlgorithm DEFAULT sha1, maskGenAlgorithm DEFAULT mgf1SHA1 and pSourceAlgorithm DEFAULT pSpecifiedEmpty of RFC 3447 have, was compiled as a default of a value not known. DER 3000, the usual parameters of RSASSA-PSS, decoded without them, and a value equal to one was always written. The compiler writes such a value as a NamedValue with the type T, in a field added to NamedValue, and v resolved as a value of T. The .asni format is at version 2.1, and a file is written with that minor version only if it has such a value, so that no other file changes. The tables of kinds, examples/asni.asn and its golden case have the field. The runtimes for Rust, Python and the JVM make the value of the open type, once the types are lowered, the bytes of the encoding of v in their codec, as a value of an open type is decoded: the encoding in BER and DER (X.690 8.15), the complete encoding in PER and UPER, one octet 0 where it is empty (X.691 11.2.1, 11.1), and the encoding in OER (X.696 30). As an encoding may leave out a member equal to another such default, they are made again until none changes. JER, XER and GSER have no bytes for an open type (X.697 41, X.693 8.5), and there such a default stays one of a value not known. The runtime for Python also took a member of the type of a field of a class, as ALGORITHM.&id, for one of another type when it read a default, and kept an OBJECT IDENTIFIER in one as a list of its arcs. tests/files/defaults.asn has defaults of open types with their encodings worked out by hand, which the three runtimes are tested against, and the tests of the compiler and of Python decode DER 3000 of RSASSA-PSS-params. The golden case of RFC 3447 changes for its three defaults. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…value
A default of a BIT STRING written as a bstring or an hstring was
compiled to other bits, in silence, and every runtime used them:
'1100'B was 0011, shifted by its trailing zeros, 'C'H the two bits 11,
'A'H the three bits 101, and '00'H no bits at all, against a SIZE (8).
DEFAULT v1, with v1 BIT STRING ::= '1100'B, was made 0011 too.
A bstring is the bits as written, an hstring four bits for each digit
(X.680 22.16, 22.17), and names in braces are ones at their numbers
(22.15). Of a type with named bits the trailing zero bits are no part
of the value (22.18, 22.7): '1100'B of one is the two bits 11, and
'110'B is 11, where it was 011. The runtime for Python read a default of
a specification dictionary in the same wrong way, and is fixed too.
tests/files/defaults.asn has BIT STRING defaults written each way, with
their encodings worked out by hand. The golden case of all_types.asn,
three fixtures of the Python tests and the vectors of D and P of the
tests of BER, DER and UPER held '00'B of a type with named bits as two
zero bits, and '110'B as 011; they now hold no bits and 11. Those tests
are changed to the value that default is. The vectors are recorded
again, which also adds those of tests/test_defaults.py.
A default of a SEQUENCE or a SET that leaves out members with defaults,
as in In DEFAULT { x 1 } with In ::= SEQUENCE { x INTEGER DEFAULT 1,
y BOOLEAN DEFAULT TRUE }, was compared with a value as it was written,
and the runtimes did not agree. Rust wrote in in DER for { x 1 },
{ x 1, y TRUE } and {}, which are all that default (X.680 25.12, X.690
11.5), Python left out only { x 1 }, and a member left out decoded to
{ x 1 }, where its encoding decodes to { x 1, y TRUE }.
The compiler writes such a default with the defaults of its members
filled in, at any depth. A default met again in itself, as
s S DEFAULT { a 1 } in S, is not filled in again, and stays the size
it is written. For that, a type keeps its defaults where it is written
while its own are resolved.
The runtimes for Rust, Python and the JVM compare a value with a default
as the same abstract value: a member left out of one is its default,
two left out are the same, the order of the members and of the items of
a SET OF does not count (X.680 27.6, 28), a BIT STRING of named bits is
compared without its trailing zeros at any depth (22.7), NOT-A-NUMBER is
the same as itself, and the zeros of two signs are two values (21.3).
So the three leave out the same values in DER, PER, UPER and OER, and
decode a member left out to the same complete value. The runtime for
Python also wrote in OER a BIT STRING of named bits equal to its default
with more trailing zeros, which it left out in DER and Rust left out in
both.
tests/files/defaults.asn has such defaults with their encodings worked
out by hand. The vectors are recorded again, which adds those of the new
cases and changes none.
Defaults that are valid ASN.1 were written in a form no runtime used, or
that the runtimes did not read as the value they are, in silence. Each
kind of type and each way X.680 lets its value be written was checked
against what Rust and Python decode, in every codec:
- A REAL in braces, { mantissa 3, base 2, exponent -1 }, was a
SequenceValue, which Rust took for no default and Python decoded as a
dict, so that PER, UPER and OER of the two differed. It is the double
nearest M x B^E (X.680 21.3), also by reference, which the writer of
defaults did not follow as the type of a value assignment names REAL.
One beyond what a double holds is a LimitReached, and one held with
fewer digits than written is told as one, as a real number is.
- DEFAULT {} of a SEQUENCE or a SET was an empty list, which Rust took
for no default and Python decoded as []. It is the value of which
every member is its default (X.680 25.19, 25.12).
- REAL DEFAULT -0 was plus zero; it is minus zero (21.6 NOTE, 21.8), and
the parser keeps the sign of -0, which is still the integer 0.
- NOT-A-NUMBER was no default in Rust and the JVM, and Python held
PLUS-INFINITY, MINUS-INFINITY and NOT-A-NUMBER as the text of their
names and an integer as an integer: each is the float decoded.
- A default of UTCTime, GeneralizedTime, DATE, TIME-OF-DAY and DATE-TIME
was its text in every runtime, where such a value decodes to a date or
a time, so that a value equal to it was always written. It is the
value its text tells, as JER reads it.
- Python kept the object identifier of an EXTERNAL in a default as a
list of its arcs.
- CONTAINING v of an OCTET STRING or a BIT STRING was written as the text
CONTAINING, and a default of an ANY, or of an open type not given with
its type, as the value written, where the runtimes hold one as the
bytes of an encoding. Each is now a default of a value not known, told
as a NotRead.
tests/files/defaults.asn has these forms, with their encodings worked
out by hand, for the three runtimes. Three tests of the compiler that
held a REAL of no double and a default 5 of ANY and of an open type
compiling in silence now hold that each is told. The vectors are
recorded again, which adds those of the new cases and changes none.
Filling in the defaults of the members of a SEQUENCE or a SET default
wrote all of its members in the order of the type, so that a default
that was already whole, as { y TRUE, x 1 } of a SET, was written in
another order, and its .asni file changed where it was not wrong. The
members written keep their order, and those filled in follow.
The vectors have a member left out with DEFAULT NOT-A-NUMBER, which
decodes to a NaN, and GSER has no notation for one (RFC 3641 3.19): the
test that encodes again every value GSER decodes expects that error
where a value has a NaN. The code that asnkit-gen-rust-codec makes holds
a default of a SEQUENCE or of an open type as no default, and writes a
value equal to it, which its test of the vectors now lists as a
difference on purpose for Nested and Open of tests/files/defaults.asn.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
X.680 25.10 NOTE 3 has T ::= SEQUENCE { a Ta, b SEQUENCE { ... }, c Tc }
and W ::= SEQUENCE { x Wx, COMPONENTS OF T, y Wy }, and says "the tags
of a, b, and c within T need not be the same as the tags of a, b, and c
within W if W has been defined in an automatic tagging environment": the
condition is on W, the type that takes the members in. NOTE 2: "Once
25.8 is satisfied, the tags of the components are completely
determined". 25.8 performs automatic tagging of an occurrence of
ComponentTypeLists "only if 25.3 determines that it shall apply to that
occurrence", replacing "the Type originally in the NamedType" by a
TaggedType. So the members of a type of a module of AUTOMATIC TAGS carry
the tags its list gave them, and keep them in a list that is not tagged
automatically; only a list that is tagged automatically gives them
others.
Since 78bc491, a member taken in lost the tag automatic tagging had
given it, so that taken into a module of EXPLICIT or IMPLICIT TAGS, or
into a list with a tag written in it, it was untagged: in in/tg10 of
review 7, a and b of W lost [0] and [1], and T ::= SEQUENCE { a INTEGER
OPTIONAL, b INTEGER } taken in so had two members of one tag, and DER
of a value without a did not decode. 2.0.0-rc9 kept them only when the
module of the type came first in the files.
The root members taken in are given the automatic tags of the list they
are taken from, if 25.3 selects it, whatever was done of that list
before, so the result does not depend on the order of the files. A
member whose type was a dummy is marked so when the type is given its
actual parameters, so that its automatic tag there is explicit (31.2.7
c); in a list that takes it in, where its type is the one given, it is
not.
No .asni file of the corpus, of tests/valid, nor of 265 published sets
changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
write_all_effective() cloned every type, worked out its effective constraints in the clone, and kept all the clones until the last was done, so that every type was held twice at once. And once types given actual parameters were what they are with them, resolve() cloned all the modules, which were held to the end, for the check of the values in those types. What COMPONENTS OF copies, which may be most of what a specification holds, so took twice the memory, or four times: review 7's ctopc_3000_100_10 peaked at 1454 MB, of which 806 MB was there before the effective constraints were worked out, and vcomp_200_100000 at 2.5 GB, half of it the copy of the modules. The effective constraints are worked out of the constraints as they are written, which write_effective() does not change: each type is put back in its place as soon as it is done. The values of the instances are checked by a callback that resolve_checking() calls where the copy was made, in the modules themselves, with the types of the value assignments given actual parameters put in while it runs; its result, and that of the check of the values as written, which it needs first, are told after the errors of the resolver and of ANY DEFINED BY, as before. ctopc_3000_100_10 peaks at 900 MB and vcomp_200_100000 at 1.29 GB. A test counts the heap of 200 types of COMPONENTS OF a type of a hundred members, with one type given actual parameters: 2930 bytes a member before, 1386 now. No .asni file, warning or error message changes, of the corpus, of tests/valid or of 265 published sets. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The limit of what COMPONENTS OF copies counted parts of members, a
member, each constraint of its type and its default, up to 1 048 576,
each priced at what the costliest takes, about 1.5 KB. A member
INTEGER (0..255) DEFAULT 0 was three parts, so that review 7's
ctopd_3500_100, 3500 types of COMPONENTS OF a type of a hundred of
them, which 2.0.0-rc9 compiled in 1725 MB, was refused, and so were
ctopc_1000_100_10, ctopc_3500_100_2, ctopc_300_1000_10 and
ctopc_3000_100_10 (A3). And a default was one part whatever its size,
so that vcomp_200_100000, 200 types of COMPONENTS OF W with
W ::= P{{0, 1, ..., 99999}} and P{L:v} ::= SEQUENCE { a L DEFAULT v },
met no limit and aborted at 1.9 GB (A4).
What is copied is weighed in bytes (weight.rs): each block of the heap
it takes, a string, the buffer of a list, a box, rounded as glibc's
allocator rounds it, with what is in it, defaults whole; and what the
compiler makes of a member (384 bytes), of an item of a list of names
(128) and of a component of WITH COMPONENTS (256) once copied, which
were fitted to the memory measured. Over members of every kind measured
(constraints, small and large defaults, enumerations, named numbers,
strings, WITH COMPONENTS, SEQUENCE OF, types in types), the peak of a
specification grows by 0.92 to 1.11 MiB for each million bytes so
weighed. The limit is 1 342 177 280 bytes. The most 2.0.0-rc9 compiled
in 2 GiB of these shapes, 4100 types of COMPONENTS OF a type of a
hundred members of ten constraints each (2024 MB there), weighs about
1 237 000 000 and compiles in 1201 MB; ctopd_3500_100 compiles in 498 MB,
vcomp_200_100000 in 1267 MB, and what is past the limit stops at it at
about 1.1 GB, with an error that names it.
The README and the changelog say so, where they said that all that
2.0.0-rc9 compiled in 2 GiB compiled, which was not so.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A value in braces of values in braces given for a dummy value, as
review 7's vnest: P{L:v} ::= SEQUENCE { m L DEFAULT v } and
X ::= P{{ { a 0, b 0 }, ... }}, took about 1.2 KB a part, so that one
of 690 000 such values, 2 070 000 parts under the limit of 2 097 152,
aborted at 1.9 GB, where 2.0.0-rc9, which did not put the value in the
default, compiled it in 181 MB (A5). Two things took it:
- compiled_compact() made the readable form of each type assignment, a
map with its kind and its fields by name for each value in braces and
each named value in it, and then its compact form, with both held. Of
vnest_300000_1, 660 MB of the 1087 MB at the most. While the compiled
specification is written, a value, but a number, a boolean, a string
and an empty list, is written in the compact form at once, as a node
that to_compact() takes as it is (Value::to_compact(),
compact_node(), with the table of kinds, and the defaults of fields
as is_default() tells them). The existing test that compares
compiled_compact() with to_compact() of the readable form, over every
file of tests/files, holds them the same.
- default_values() cloned every actual parameter, to make TRUE, FALSE,
NULL and values by reference the values they are in a default. It
holds only those it makes something else of, and the actual parameter
itself is used for the others.
vnest_300000_1 peaks at 548 MB, vnest_690000_1 compiles in 1282 MB, and
vnest_699000_1, at the limit, in 1298 MB, 620 bytes a part; a value of
2 097 000 integers takes 532 MB, where it took 659 MB. A test of the
memory counts the heap of a value of 100 000 values in braces: 930
bytes a part before, 363 now. The README gives these numbers, where it
said 330 bytes a part and 660 MB in all. No .asni file, warning or
error of the corpus, of tests/valid or of 265 published sets changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
of_module() gives a member taken in by COMPONENTS OF from another module
that module, on the type of the member, and parameterization_step_1_type()
read the module of each type it gives actual parameters from that type
alone, as it went down the types with the module of the type assignment.
So a type given actual parameters deeper than the type of the member,
as l SEQUENCE OF P{BOOLEAN} or m SEQUENCE { n P{INTEGER} } of review 7's
in/impq.asn, was looked up in the module that takes the member in: the
P of that module, in silence, or "Type 'P' not found in module 'M1'"
(review 6a's impp.asn), 2.0.0-rc9 the same (A8). And of_module_named()
gave a type given as an actual parameter its module only if it was a
reference, so that v of P{INTEGER (0..v)} given in M1 was the v of the
module of P, or an error that there is none there.
What is in a SEQUENCE, a SET, a CHOICE, a SEQUENCE OF or a SET OF that
has a module is written in that module, and the types in it are given
actual parameters there (X.680 25.5 copies the component types, whose
names are those of the module they are written in, 13). A type given as
an actual parameter that is not a reference has the module it is given
in if a name is in it, a value in its constraints or a type given actual
parameters, so that its constraints are resolved there.
No .asni file of the corpus, of tests/valid or of 265 published sets
changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
…defined
pre_process_tags_members() gave automatic tags in the order the members
are written, so that a root member after the second extension marker was
numbered after the additions: in review 7's in/tg7.asn, SEQUENCE { a
INTEGER, ..., b BOOLEAN, ..., c NULL }, b was [1] and c [2] (A10).
X.680 25.10 c: "the ClassNumber in the replacement TaggedType is tag
value zero for the first ComponentType in the RootComponentTypeList,
one for the second, and so on, proceeding with increasing tag numbers";
d: that "of the first ComponentType in the ExtensionAdditionList is
zero if the RootComponentTypeList is missing, else it is one greater
than the largest ClassNumber in the RootComponentTypeList". The root
members, those after the second marker too, are numbered first, and the
additions after them: c is [1] and b [2]. What COMPONENTS OF takes in of
such a type was numbered so already (tag_root_as_in_its_list()).
The .asni files of tests/files/x691_a4.asn (the example of X.691 A.4)
and tests/files/x680.asn (A-G-1-4-4 of X.680 G.1.4.4) change, the tags
of their second root lists and their additions alone, and so do their
golden cases, four files of tests/fixtures, and the BER vectors of F and
G of tests/test_ber.py, taken from asn1tools, which had the old
numbering and now have the tags of 25.10. No other .asni of the corpus,
of tests/valid or of 265 published sets changes.
The runtimes wrote and read the members of a SEQUENCE in BER and DER as
the root, then the additions, so that a root member after the second
extension marker came before the additions: of SEQUENCE { a BOOLEAN,
..., b BOOLEAN, ..., c BOOLEAN }, c before b. X.690 8.9.2: "The contents
octets shall consist of the complete encoding of one data value from
each of the types listed in the ASN.1 definition of the sequence type,
in the order of their appearance in the definition, unless the type was
referenced with the keyword OPTIONAL or the keyword DEFAULT." (A10 of
review 7 asked to check it.) And a reader of a version that does not
know an addition met it where it looked for the root member after it.
The runtimes for Rust, Python and the JVM, and the codecs that
asnkit-gen-rust-codec writes, write the root members before the
additions, the additions, and then the root members after them, and
read them so; additions of a later version that are not known are
skipped up to the first root member after them, of which the tags are
distinct from theirs (X.680 25.7: "all ComponentTypes in extension
additions shall have tags which are distinct from the tags of the
textually following ComponentTypes up to and including the first such
ComponentType that is not marked OPTIONAL or DEFAULT in the trailing
RootComponentTypeList"). The runtimes for C and WebAssembly are that of
Rust.
The BER vectors of F and G of tests/test_ber.py are in the order they
are defined in, and a test of a type with a root after the additions,
and of one without them that reads it, adds vectors and two fixtures.
The GSER tests of asnkitrt-rs read the specification of those vectors by
its new name, as recording them again renamed it.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
pre_process_tags_type() went down the members and the element of a type,
and not its actual parameters, so that a type written in place as one,
as P{SEQUENCE { e INTEGER }} of review 7's in/tg5.asn, in a module of
AUTOMATIC TAGS, was not tagged automatically, and a tag written in it
was given the mode of no module (A11; 2.0.0-rc9 the same). X.680 25.3:
"When the ComponentTypeLists production occurs within the definition of
a module for which automatic tagging is selected (see 13.3), and none of
the occurrences of NamedType in any of the first three alternatives for
ComponentType is a textually tagged type (see 25.2), then the automatic
tagging transformation is selected for the entire ComponentTypeLists".
A type given as an actual parameter is tagged as the module it is
written in tags, with the dummy parameters of the type it is in, so that
it is so wherever the parameterized type puts it: e is [0] of
P{SEQUENCE { e INTEGER }}, P{SEQUENCE OF SEQUENCE { e INTEGER }} and
P{CHOICE { e INTEGER, f NULL }} in a module of AUTOMATIC TAGS, and is
untagged when given in a module of EXPLICIT TAGS to a P of AUTOMATIC
TAGS, in either order of the files.
No .asni file of the corpus, of tests/valid or of 265 published sets,
nor any fixture, changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
pre_process_extensibility_implied() ran for each module after what
COMPONENTS OF takes in of it, in the order of the files, so that in
review 7's in/ext1.asn and in/ext1r.asn the inner SEQUENCE of a type of
a module of EXTENSIBILITY IMPLIED, taken in by a module that came before
it, was not extensible, and was in the other order; and it put markers
in SEQUENCE, SET and CHOICE alone, and not in the element of a SEQUENCE
OF or a SET OF, a type given in place as an actual parameter, or the
type of a field of a class (A9; 2.0.0-rc9 the same).
X.680 13.4: "The EXTENSIBILITY IMPLIED option is equivalent to the
textual insertion of an extension marker ("...") in the definition of
each type in the module for which it is permitted. The location of the
implied extension marker is the last position in the type where an
explicitly specified extension marker is allowed." ENUMERATED is one for
which it is permitted: "Enumerations ::= RootEnumeration | RootEnumeration
"," "..." ExceptionSpec | ..." (20.1). And "EXTENSIBILITY IMPLIED affects
only types. It has no effect on object sets and subtype constraints"
(13.4 NOTE).
The markers are put in every module of the option before anything is
taken in, at the end of the members or the items of each of those types,
at any depth. The UPER of M1.A of in/ext1.asn is 58 in both orders, and
an ENUMERATED { a, b } is extensible.
The .asni files of tests/files/sketch.asn, of which the CHOICE of runs,
in a SEQUENCE OF, becomes extensible, and of tests/files/zforce.asn, of
which an ENUMERATED does, change, with their golden cases and two files
of tests/fixtures; the vectors keep their values, and two of their
specifications their names. No other .asni of the corpus, of
tests/valid or of 265 published sets changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
actual_parameter() tried a type only where the parameter starts with a
capital letter, so that P{[2] INTEGER} of review 7's in/tg6.asn was a
syntax error (A12; 2.0.0-rc9 the same). X.683 9.1: "ActualParameter ::=
Type | Value | ValueSet | DefinedObjectClass | Object | ObjectSet", and
[2] INTEGER is a Type (X.680 31.1, TaggedType). It is read as a tag and
a type, as a member's type is, and its tag is given the mode of the
module it is written in (31.2.7), as a type given as an actual parameter
is tagged there.
Given for a dummy parameter that has a tag where it is used, written as
m [1] T or given by automatic tagging, the type would have two tags,
[1] EXPLICIT [2] INTEGER, of which a Type here holds one: the tag of the
dummy was lost in silence. That is an error that names the limit, as
[1] [2] INTEGER written so is one, and says to give the tagged type a
type assignment of its own, through which two tags are read.
No .asni file of the corpus, of tests/valid or of 265 published sets,
nor any fixture, changes.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A type written as the setting of a type field of an object, or as the
default of a type field of a class, was read into the information
objects and no further: review 7's in/obj2.asn to obj8, dup6 and dup7,
as &T SEQUENCE { b INTEGER DEFAULT TRUE }, &T INTEGER (0..TRUE), &T
SEQUENCE { a INTEGER, a BOOLEAN } and &T SEQUENCE { b Q }, compiled in
silence (A13; 2.0.0-rc9 the same), where the README says that a value
not of its type is an error "wherever it is written", and the same type
in a type assignment is an error.
setting() of the builder of information objects, which reads every type
setting and type-field default of both forms of objects, checks it as
the type of a type assignment is checked: the values in it, by
Values::check_type(), and the names of the members of each list in it
(X.680 25.14, 27.4, 29.10), by check_type_setting(); each name of a type
in it, of its members, its element, what COMPONENTS OF in it names and
its actual parameters, that is not defined or imported is an
UnknownType, as the name of the setting itself is; and once every name
in it is found and none is given actual parameters, a copy of it is
resolved with its effective constraints by the compiler, as a type
assignment is (resolve_setting_type()), so that INTEGER (0..TRUE) is the
error it is there. What is otherwise not found is told as before.
No .asni file, warning or error of the corpus, of tests/valid or of 265
published sets changes, nor any fixture.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
A value given for a dummy value that a constraint uses had no limit, and aborted (A6 of review 7: vcon_1_100000_300, base the same). Measured again, the branch was worse than 2.0.0-rc9: vcon_1_100000_150, one value of 100 000 integers by reference in the constraints of 150 members, which 2.0.0-rc9 compiled in 1845 MB, aborted, and so did vconi with the value written in braces from 100 members, which 2.0.0-rc9 compiled in 228 MB. Two copies took it: - resolve_type() resolved restricted_to, so that a value by reference was copied into the constraint of each member that names it, and write_all_effective() then cloned each type with them; and the effective constraints replace restricted_to of every type with constraints written but a REAL, whose value constraints are kept as resolved here. It is still resolved, for the errors it tells, which the golden cases hold, and kept only where it is used. - dummy_to_actual_type() copied a value in braces given for a dummy value into each constraint it is in. Such a value is held once in a value assignment of the parameterized type's module, of a name with spaces, which no ASN.1 can write, and the constraints name it (shared_value(), added to the modules once types are given actual parameters, and left out of the compiled specification with the other values). Defaults are written with the value as before. vcon and vconi of 1000 members compile in 40 MB. A test of the memory counts the heap of a value of 20 000 integers in the constraints of 50 members, by reference and in braces: 3544 bytes an integer before, 230 now. No limit is needed, and none is added. No .asni file, warning or error of the corpus, of tests/valid or of 265 published sets changes, nor any fixture. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
Types given actual parameters in one another, each given the one before
twice, as review 7's pchain (Pi{T} ::= SEQUENCE { a P(i-1){T}, b
P(i-1){T} }), make copies of the parameterized types that double with
each, and met no limit: pchain_19_2 to pchain_22_2 aborted at 2 GiB, and
so did cpar_200_100_100 and cpar_300_100_100 (COMPONENTS OF a type whose
members are each P{INTEGER} of a hundred members), measured on the
commit before; 2.0.0-rc9 aborted from pchain_18_2 and cpar_100_100_100
(A7).
Each type given actual parameters, the copy of its parameterized type
once its dummies are given, is weighed as what COMPONENTS OF copies is
(weight::of_type()) and counted with it, and more than the limit is an
error that names it and the type given them. The limit is a field of the
compiler, TAKEN_IN_BYTES but in tests, so that the tests that meet it,
of types given actual parameters and of COMPONENTS OF in one another,
are unit tests with a limit of 4 MiB: those of checks.rs held up to the
1.25 GiB of the limit each.
And a type assignment as large as such a type was made into the readable
form of the compiled specification, a map for each node, held whole
until it was made compact, as values were before 0eaaeae: while the
compiled specification is written, node() makes the compact node of its
fields at once, and into_compact() moves what it holds. pchain_17_2
peaks at 506 MB, where it took 1131 MB (2.0.0-rc9 1235 MB), pchain_18_2
compiles in 1006 MB, and pchain_19_2 meets the limit at 607 MB;
cpar_100_100_100 compiles in 1295 MB, and cpar_200 and cpar_300 meet the
limit at 850 MB. A test of the memory of one such type of 8192 members
counts 3657 bytes a member before and 1638 now.
No .asni file, warning or error of the corpus, of tests/valid or of 265
published sets changes, nor any fixture.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The errors of COMPONENTS OF a dummy parameter were made once the dummy
was replaced by what it is given, and so named that as if it were the
name of a type: COMPONENTS OF 'CHOICE' of P{CHOICE { a INTEGER }}
(review 7's in/co2.asn, co3), COMPONENTS OF 'W' where the text says
COMPONENTS OF T (h/cdummy_20000_60); and parameterization_step_1() told
its errors without the type assignment or a place, where other errors
end with ", in type 'X', at line L, column C" and the README promises the
place of the COMPONENTS OF (A14).
The type put in place of a dummy that COMPONENTS OF names keeps the name
of the dummy, in the note of the type that is no part of the tree and
held enumerations to renumber (Numbering, now of a Note), so that Type
and Member keep their size; the errors say COMPONENTS OF 'T' in module
'M' (given a CHOICE) or (given 'W'). The errors of step 1 are given the
type assignment and its place by in_type(), which names the type once
where the error names it already. The error of the limit of what is
copied names the type given actual parameters and its module, and the
type assignment with the place.
Ten published sets and tests/files/x683.asn, which fail with such an
error, now tell the type and the place; no other message, and no .asni
file, of the corpus, of tests/valid or of 265 published sets changes,
nor any fixture. Three golden cases have the place in their messages.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
56ea1dd put each value in braces given for a dummy value in a value
assignment of its own, for the constraints to name, also where no
constraint names the dummy, and built the actual parameters of the
constraints by cloning every other one. A value given for a default
alone was so held twice more while the type was given its actual
parameters: one of 2 097 000 integers in a default (P{L:d} ::= SEQUENCE
{ a L DEFAULT d }) peaked at 659 MB, where 0eaaeae had brought it to
532 MB. Measured in checking the numbers of the README and the
changelog.
A value is held so only where a constraint of the parameterized type, at
any depth, names its dummy (names_in_constraints()), and the parameters
of the constraints are those value assignments alone, the others being
the actual parameters themselves. The value of 2 097 000 integers peaks
at 544 MB. A unit test holds that a value that a default alone names
makes no value assignment, and one that a constraint names makes one.
No .asni file, warning or error of the corpus, of tests/valid or of 265
published sets changes, nor any fixture.
Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
The README of asnkit-compiler, the changelog and the comment of TAKEN_IN_BYTES gave numbers measured before later commits lowered them or changed what is counted (A15 of review 7). Measured again on the commit before, each input under 2 GiB of address space: - what COMPONENTS OF copies, and the instances now counted with it, takes 0.89 to 1.11 MiB for each million bytes weighed (ctopc_4100_100_10 1095 MB, ctopn_1100_10_100 1369 MB, cenum_1500_100 1028 MB, cbigdef_1500_100 1128 MB, cpar_100_100_100 1293 MB), and what is past the limit stops by 1.3 GB (ctopc_5000_100_10 1156 MB, vcomp_2000_100000 1294 MB); 4100 types of COMPONENTS OF a type of a hundred members of ten constraints compile in 1.1 GB, not 1.2; - a value in braces given for a dummy value at the limit of the defaults takes 856 MB, 410 bytes a part, not 1.3 GB and 620; one of integers 531 MB. And the README said that COMPONENTS OF a dummy parameter in a module of AUTOMATIC TAGS is not read and is an error, which it has not been since 78bc491: it compiles, and is tagged as if what it takes in were written out. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
tests/fixtures/37b3e2c51d5ac8062cde0ed8.asni is tests/files/character_string.asn compiled before its text last changed. No test makes it any more, and the job fixtures-are-current fails with it, as it compares the two folders both ways. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
… codecs The runtime for Rust read the text of such a default only when it was built with jer, xer or gser, and took it for no default otherwise, in silence: a member left out with DATE DEFAULT "2020-01-02" decoded to no value, and the test of tests/files/defaults.asn failed with --no-default-features. The functions that read those texts are built always; those that write them stay with the text codecs. That test also tried JER and XER where they are not built. It leaves out a codec that is not built in, as the test of CHARACTER STRING does. Signed-off-by: Matheus Xavier <mxavier@boxtheta.com>
xadaemon
temporarily deployed
to
github-pages
November 29, 2026 02:41 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
The compiler reads the information objects of X.681 whole, checks every value against its type, and tells what it does not read or where it meets a limit, where it compiled in silence.
CHARACTER STRINGis encoded and decoded in every runtime. In 112 commits;CHANGELOG.mdlists each change under 2.0.0-rc9 once the release commit that follows this is in.Before 2.0.0, so some of this breaks what rc8 took: what X.680 to X.683 make invalid is now an error, also where specifications in use have it.
Information objects (X.681)
OPTIONAL,UNIQUEandDEFAULTof every field.asnkit-compilerhasinformation_objects(), which gives them resolved: settings, defaults, imports followed, sets flattened..asnstis at version 1.2.UnknownObjectClass,ObjectNotOfSyntaxand the others of objects that are wrong;NotRead, of what is valid and not read, whichasnkitcc --quiethides; andLimitReached, which nothing hides.Values
INTEGER DEFAULT 1.5,007, an item that is not of itsENUMERATED, two members of one name.BIT STRINGdefaults as their bits, aREALin braces as its double,DEFAULT {}, defaults with values of open types (.asni2.1 where a file has one), and a default compared as an abstract value in DER, PER, UPER and OER.ENUMERATEDitems without a number are numbered as X.680 20 says.Types
CHARACTER STRING(X.680 44.5) in the compiler and in the runtimes for Rust, C, C++, WebAssembly, Python and the JVM, withtests/files/character_string.jsonof encodings worked out by hand.COMPONENTS OFat any depth, through parameters and across modules, with the tags of X.680 25.10, and refused where X.680 does not allow it.asnkit-gen-rust-codecmakes.EXTENSIBILITY IMPLIEDapplies to each module by itself, and toENUMERATEDtoo.P{[2] INTEGER}, types written in place as actual parameters.Limits and memory
COMPONENTS OFcopies and each instance of a parameterized type are weighed in bytes, 1 342 177 280 in all, and the compiler stops there with an error that names the limit.Tests
packages/asnkit-compiler/tests:values,limits,valid,reals,defaults,warnings,memoryandtagging.tests/files/defaults.asnandcharacter_string.asn, with encodings worked out by hand, held by the runtimes for Rust, Python and the JVM.The last two commits are what running the jobs of CI on one machine found: a fixture that nothing makes any more, and the defaults of
DATE,TIME-OF-DAYandDATE-TIMEthat the runtime for Rust did not read when built without a text codec.