mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
97 stars 71 forks source link

aper: Fix printf formatting on 32bit archs #101

Closed pespin closed 2 years ago

mouse07410 commented 2 years ago

I think we tried something like this a while ago, and people complained because it presumably broke something...

I'll give this PR a little time for others to try, and since it seems to pass the CI, merge it - unless there are complaints.

mouse07410 commented 2 years ago

@pespin it's not related to this PR - but would you be able to take a look at #103 and maybe figure why it fails the tests? Does it look like a minor thing, or that PR really breaks the ASN.1 compiler?

pespin commented 2 years ago

Hi, Regarding this PR, I tested it in both x86_64 and armv7l (raspbian, 32bit) and it seems to be working fine on both and removing tons of warnings in the later. I'm waiting for this to be merged in order to incorporate it to osmo-cbc. Hopefully that fixes the segfault I'm seeing in osmo-cbc unit test when encoding SBc-AP with asn1c (only happening in 32 bit arm in OBS, not happening when I compile manually in a rpi with raspbian...). So I hope his gets merged soon.

https://obs.osmocom.org/package/live_build_log/osmocom:nightly/osmo-cbc/Raspbian_10/armv7l

[  508s] stderr:
[  508s] Encoding "SBC-AP-PDU" using ALIGNED PER
[  508s] Encoding SBC-AP-PDU as CHOICE using ALIGNED PER
[  508s] Encoding SBC-AP-PDU CHOICE element 0
[  508s] [PER put 1 bits 0 to 0xfff8c8b0+0 bits]
[  508s] [PER out 1 0/0 (t=0,o=1) 32&0=0]
[  508s] [PER out 0/0 => 00 buf+0]
[  508s] [PER put 2 bits 0 to 0xfff8c8b0+1 bits]
[  508s] [PER out 2 0/0 (t=1,o=3) 0&80=0]
[  508s] [PER out 0/0 => 00 buf+0]
[  508s] Encoding InitiatingMessage as SEQUENCE (APER)
[  508s] first_extension = -1, elements = 3
[  508s] About to encode ProcedureCode
[  508s] Encoding InitiatingMessage->procedureCode
[  508s] Encoding NativeInteger ProcedureCode 0 (APER)
[  508s] Value 0 (00/1) lb 0 ub 0 (null)
[  508s] Encoding integer 0 (0) with range 0 bits
[  508s] Aligning 5 bits
[  508s] [PER put 5 bits 0 to 0xfff8c8b0+3 bits]
[  508s] [PER out 5 0/0 (t=3,o=8) 0&e0=0]
[  508s] [PER out 0/0 => 00 buf+0]
[  508s] [PER put 8 bits 0 to 0xfff8c8b0+8 bits]
[  508s] [PER out 8 0/0 (t=0,o=8) 0&0=0]
[  508s] [PER out 0/0 => 00 buf+1]
[  508s] Freeing INTEGER as a primitive type
[  508s] About to encode Criticality
[  508s] Encoding InitiatingMessage->criticality
[  508s] Encoding Criticality as NativeEnumerated
[  508s] [PER put 2 bits 0 to 0xfff8c8b1+8 bits]
[  508s] [PER out 2 0/0 (t=0,o=2) 0&0=0]
[  508s] [PER out 0/0 => 00 buf+2]
[  508s] About to encode value
[  508s] Encoding InitiatingMessage->value
[  508s] Encoding value OPEN TYPE element 0
[  508s] Open type put Write-Replace-Warning-Request ...
[  508s] Encoding Write-Replace-Warning-Request as SEQUENCE (APER)
[  508s] [PER put 1 bits 0 to 0xfff8c678+0 bits]
[  508s] [PER out 1 0/0 (t=0,o=1) d4&0=0]
[  508s] [PER out 0/0 => 00 buf+0]
[  508s] Element ptr wtv Write-Replace-Warning-Request->protocolExtensions is absent
[  508s] [PER put 1 bits 0 to 0xfff8c678+1 bits]
[  508s] [PER out 1 0/0 (t=1,o=2) 0&80=0]
[  508s] [PER out 0/0 => 00 buf+0]
[  508s] first_extension = 2, elements = 2
[  508s] About to encode ProtocolIE-Container
[  508s] Encoding Write-Replace-Warning-Request->protocolIEs
[  508s] Encoding ProtocolIE-Container as SEQUENCE OF size (8) using ALIGNED PER
[  508s] /usr/src/packages/BUILD/tests/testsuite.dir/at-groups/1/test-source: line 14: 61396 Segmentation fault      (core dumped) $abs_top_builddir/tests/sbcap/sbcap_test
pespin commented 2 years ago

FYI, this PR seems to have fixed the crash above on 32bit armv7l raspbian 10.

mouse07410 commented 2 years ago

Good! Which issue does this PR fix (so I can close it)?

pespin commented 2 years ago

no associated ticket, I was tracking this crash internally ;)