Unchecked module's attributes should not be cached
A module's extension attributes can be cached (i.e. stored after they are first calculated, so they don't have to be calculated every time they're requested) before the semantic analysis of these attributes changes them (i.e. deletes some of them).
Consider the following example:
A.ttcn:
module A {
import from B all;
type record of Rec RoRec
with { encode "JSON" }
}
B.ttcn:
module B {
import from A all;
type record Rec {
integer num,
charstring str
}
external function f_enc(in Rec x) return octetstring
with { extension "prototype(convert) encode(RAW)" };
}
with {
encode "RAW"
extension "version R3A"
}
The following steps take place, when semantic analysis reaches module B:
- the check for imported module A is intiated (before module B itself is checked),
- the check for type RoRec in module A is initiated,
- the check for type Rec in module B is initiated (because it is contained in type RoRec),
- while checking type Rec's encodings, the parent module's attributes are calculated and cached, before the module has checked them (this results in a vector of 2 attributes, one 'encode' and one 'extension'),
- the check for type RoRec and module A is finished,
- the check for module B is initiated,
- module B's attributes are checked, this results in the extension attribute being deallocated,
- external function f_enc is checked, which requests the parent module's attributes, which returns the previously cached attributes. The result a fatal error, because the 2nd attribute in the cache has already been deallocated.
/cc @aknappqwt @mmagyari
Edited by Botond Baranyi