TASTE bugtrack - Taste
View Issue Details
0000888Taste[All Projects] ASN.1 Compiler v4public2019-11-07 13:092020-08-31 15:32
shd01 
gmamais 
normalmajoralways
closedfixed 
0000888: Bad ACN Decoder generated if ACN key field does not precede its dependent
Using this ASN... Test DEFINITIONS ::= BEGIN MyEnum ::= ENUMERATED {a,b,c} T-Thing ::= CHOICE { alt1 INTEGER, alt2 MyEnum } T-ThingHolder ::= SEQUENCE { random INTEGER, thing T-Thing } END ... with this ACN ... Test DEFINITIONS ::= BEGIN T-ThingHolder [] { random [], thing [], selector INTEGER [encoding pos-int, size 32] } T-Thing [] { alt1 [present-when selector == 1], alt2 [present-when selector == 10] } END ... I get an ACN Decoder that compiles but which crashes at runtime. The problem is that the code generator expects the key field "selector" to be located before the "thing" in the encoded packet. flag T_ThingHolder_ACN_Decode(T_ThingHolder* pVal, BitStream* pBitStrm, int* pErrCode) { flag ret = TRUE; asn1SccUint T_ThingHolder_selector; asn1SccUint intVal; /*Decode random */ ret = BitStream_DecodeUnConstraintWholeNumber(pBitStrm, (&(pVal->random))); *pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_RANDOM; if (ret) { /*Decode thing */ *pErrCode = 0; if ((T_ThingHolder_selector == 1)) { <<<<<<<<<<<<<<<<<<<< uninitialised! pVal->thing.kind = alt1_PRESENT; ret = BitStream_DecodeUnConstraintWholeNumber(pBitStrm, (&(pVal->thing.u.alt1))); *pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_THING_ALT1; } else if ((T_ThingHolder_selector == 10)) { pVal->thing.kind = alt2_PRESENT; ret = BitStream_DecodeConstraintPosWholeNumber(pBitStrm, (&(intVal)), 0, 2); *pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_THING_ALT2; if (ret) { switch (intVal) { case 0: pVal->thing.u.alt2 = a; break; case 1: pVal->thing.u.alt2 = b; break; case 2: pVal->thing.u.alt2 = c; break; default: ret = FALSE; /*COVERAGE_IGNORE*/ *pErrCode = ERR_ACN_DECODE_T_THINGHOLDER_THING_ALT2; /*COVERAGE_IGNORE*/ } } } else { *pErrCode = ERR_ACN_DECODE_T_THINGHOLDER_THING; /*COVERAGE_IGNORE*/ ret = FALSE; /*COVERAGE_IGNORE*/ } if (ret) { /*Decode T_ThingHolder_selector */ ret = Acn_Dec_Int_PositiveInteger_ConstSize_big_endian_32(pBitStrm, (&(T_ThingHolder_selector))); *pErrCode = ret ? 0 : ERR_ACN_DECODE_T_THINGHOLDER_SELECTOR; } } return ret && T_ThingHolder_IsConstraintValid(pVal, pErrCode); }
No tags attached.
? shit.acn (269) 2019-11-07 13:37
https://taste.tuxfamily.org/mantis/file_download.php?file_id=313&type=bug
Issue History
2019-11-07 13:09shd01New Issue
2019-11-07 13:23shd01Note Added: 0003667
2019-11-07 13:23shd01Note Edited: 0003667View Revisions
2019-11-07 13:24shd01Note Edited: 0003667View Revisions
2019-11-07 13:24shd01Note Edited: 0003667View Revisions
2019-11-07 13:25shd01Note Edited: 0003667View Revisions
2019-11-07 13:30shd01Note Edited: 0003667View Revisions
2019-11-07 13:30shd01Note Edited: 0003667View Revisions
2019-11-07 13:34shd01Note Edited: 0003667View Revisions
2019-11-07 13:35shd01Note Added: 0003668
2019-11-07 13:37shd01File Added: shit.acn
2019-11-07 13:37maximeAssigned To => gmamais
2019-11-07 13:37maximeStatusnew => assigned
2019-11-07 13:37shd01Note Edited: 0003668View Revisions
2019-11-07 17:10gmamaisNote Added: 0003670
2019-11-08 18:22shd01Note Added: 0003672
2019-11-17 09:41gmamaisNote Added: 0003682
2019-11-17 09:41gmamaisStatusassigned => resolved
2019-11-17 09:41gmamaisResolutionopen => fixed
2020-08-31 15:32maximeStatusresolved => closed

Notes
(0003667)
shd01   
2019-11-07 13:23   
(edited on: 2019-11-07 13:34)
The above ACN looks wrong because I didn't escape it. Here is the correct one (I hope): Test DEFINITIONS ::= BEGIN T-ThingHolder [] { random [], thing [], selector INTEGER [encoding pos-int, size 32] } T-Thing [] { alt1 [present-when selector == 1], alt2 [present-when selector == 10] } END
(0003668)
shd01   
2019-11-07 13:35   
(edited on: 2019-11-07 13:37)
Nope, give up. You'll have to imagine the parameters in the ACN EDIT: I've uploaded a text file
(0003670)
gmamais   
2019-11-07 17:10   
I understand the erroneous behavior of the generated code, but I am not sure I understand the requirement. (1) Do you want the ASN.1 compiler to report an error when then the selector (or determinant using the uPER terminology) is after its dependent? or (2) Do you want the ASN.1 compiler to support such grammars? This is much more difficult since the generated code must first decode the selector and the decode 'thing' although 'thing' appears before 'selector'. Obviously, this can be done only if the encoding size of 'thing' is constant, which may not be the case.
(0003672)
shd01   
2019-11-08 18:22   
Ah yes, I see the issue. I guess this should be (1), report an error. And perhaps I should not have made this a "major".
(0003682)
gmamais   
2019-11-17 09:41   
fixed in the latest GitHub commit. The ASN.1 compiler reports now an error.