Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPER decoded struct does not UPER encode #192

Closed
gbaumgardner opened this issue Aug 24, 2017 · 1 comment
Closed

UPER decoded struct does not UPER encode #192

gbaumgardner opened this issue Aug 24, 2017 · 1 comment

Comments

@gbaumgardner
Copy link

Generated from the SAEJ2735 2016 specification using the new v0.9.29 compiler. The code looks good and compiles, but I am having trouble with one of the types, MessageFrame. That type is new to J2735 2016 and is really a container frame for any other type. The code generated produces a CHOICE union called value, but it seems that encoding that type fails. I took a known UPER encoded set of bytes (00130b0000003781000000000005), and it seems to decode with uper_decode_complete just fine to the MessageFrame (see Decoding MessageFrame as SEQUENCE.txt and the XER encoding in MessageFrame.txt). However, that same structure was passed into the uper_encode_to_buffer, and it fails to encode. (see Encoding MessageFrame.txt). For comparison, I took a SPAT message based on the 2014 XML (removing unused elements), and was able to XER decode to the structure, which was then encoded as UPER, decoded back to a new structure, then encoded again with UPER. Everything worked fine for that structure (see SPAT 2016 Encode_Decode_Encode Test.txt) and the bytes looked identical and the XER output looked identical. I then, tried to do the exact same test using the XML tags around that same SPAT, and it SEG faults trying to XER decode.

Relavent debug output:
XER/SEQUENCE: tcv = 1, ph=0 [MessageFrame] (../src/r63/constr_SEQUENCE.c:711)
XER/SEQUENCE: tcv = 5, ph=1 [MessageFrame] (../src/r63/constr_SEQUENCE.c:711)
XER/SEQUENCE: tcv=5, ph=1, edx=0 (../src/r63/constr_SEQUENCE.c:770)
INTEGER body 2 0x31..0x39 (../src/r63/INTEGER.c:343)
Freeing INTEGER as a primitive type (../src/r63/asn_codecs_prim.c:125)
XER/SEQUENCE phase => 1, step => 1 (../src/r63/constr_SEQUENCE.c:685)
XER/SEQUENCE: tcv = 5, ph=1 [MessageFrame] (../src/r63/constr_SEQUENCE.c:711)
XER/SEQUENCE: tcv=5, ph=1, edx=1 (../src/r63/constr_SEQUENCE.c:770)

Relavent stack trace
#0 0x0000000000000000 in ?? ()
#1 0x00007ffff74deb6e in SEQUENCE_decode_xer (opt_codec_ctx=0x7fffffffda60, td=0x7342c0 <asn_DEF_MessageFrame>, struct_ptr=0x7fffffffdab8, opt_mname=0x0, buf_ptr=0x7377bf, size=1754)
at ../src/r63/constr_SEQUENCE.c:676
#2 0x00007ffff74971eb in xer_decode (opt_codec_ctx=0x7fffffffda60, td=0x7342c0 <asn_DEF_MessageFrame>, struct_ptr=0x7fffffffdab8, buffer=0x737798, size=1793) at ../src/r63/xer_decoder.c:37

Note that DER encoding/decoding seems to work great for the MessageFrame, so the problem seems to be UPER and XER related. And it seems to be specific to MessageFrame.

SPAT 2016 Encode_Decode_Encode Test.txt
Encoding MessageFrame.txt
MessageFrame.txt
Decoding MessageFrame as SEQUENCE.txt

@vlm
Copy link
Owner

vlm commented Aug 27, 2017

Fixed. Check it out (in examples/sample.source.J2735):

./j2735-dump -ixer -oper sample-MessageFrame-1.xer | ./j2735-dump -iper -oxer -

or just

make check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants