Open kaxap opened 5 years ago
My guess would be one of those structures in the CallEventRecord
which does not have tag 160 defined, though it is present in the serialization.
The other way to approach this is to enable pyasn1 debugging:
from pyasn1 import debug
debug.setLogger(debug.Debug('all'))
It will reveal more information on the decoding process.
It should be doable to define the missing element in the ASN.1 spec to get the decoder going over it.
You can try to set defaultErrorState to stDumpRawValue
, though I am not certain it won't fail somewhere later along the way.
So the first approach with debug is really slow and it's still executing (has been executing for last ~20 hours).
The second approach with setting defaultErrorState to stDumpRawValue raises the following exception:
Traceback (most recent call last):
File "/home/r/dev/cdr-py/run2.py", line 12, in <module>
data = ber_decoder(bytes_read, asn1Spec=CallEventDataFile())
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 1498, in __call__
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 608, in valueDecoder
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 1498, in __call__
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 694, in valueDecoder
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 1498, in __call__
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 939, in valueDecoder
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 1498, in __call__
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 608, in valueDecoder
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 1498, in __call__
File "/home/r/Anaconda3/lib/site-packages/pyasn1-0.4.6-py3.6.egg/pyasn1/codec/ber/decoder.py", line 1015, in valueDecoder
AttributeError: 'TagMap' object has no attribute 'tagSet'
while executing the following code:
from cdr import CallEventDataFile
from pyasn1.codec.native.encoder import encode
from pyasn1.codec.ber.decoder import decode as ber_decoder, stDumpRawValue
bytes_read = open("test-data/1546606507938713068", "rb").read()
ber_decoder.defaultErrorState = stDumpRawValue
data = ber_decoder(bytes_read, asn1Spec=CallEventDataFile())
Well, the first approach is meant for a single run, to figure out what's missing. That's not for production use of course.
Anyway, let's try #152 with the second approach? If it still does not help, I'd appreciate a reproducer e.g. the test data blob that causes decoder failure.
I am not using it in production, it took 50+ hours to process a single 10MB ANS.1 encoded file. Anyways, I was able to find the missing ASN.1 notation by looking at local variables at the exception time.
I will try #152 with the missing annotation and see if it helps. Thank you for you help!
@etingof I am having the same issue. How you interpret the debugged information. Below is my debug info.
2020-11-11 16:41:38,361 pyasn1: decoder called at scope with state 0, working with up to 1088 octets of substrate:
00000: 00 00 04 40 00 00 41 E8 E8 94 56 A1 80 94 56 A1
00016: 80 FF FF FF FF FF FF FF FF 01 FF FF FF 13 FF FF
00032: FF 00 00 00 00 20 FF FF FF FF FF FF FF FF FF FF
00048: FF FF FF FF FF FF FF FF FF 80 00 01 00 FF FF FF
00064: FF 03 FA E8 46 00 BF 53 80 80 01 53 82 06 49 4E
00080: 56 49 54 45 83 01 00 A4 80 81 32 64 65 6E 63 6F
00096: 30 30 6D 74 61 73 2D 52 46 52 4F 2E 69 6D 73 2E
00112: 6D 6E 63 30 34 30 2E 6D 63 63 33 31 31 2E 33 67
00128: 70 70 6E 65 74 77 6F 72 6B 2E 6F 72 67 00 00 85
00144: 7F 64 65 6E 63 6F 30 30 6D 74 61 73 2D 52 46 52
00160: 4F 2E 69 6D 73 2E 6D 6E 63 30 34 30 2E 6D 63 63
00176: 33 31 31 2E 33 67 70 70 6E 65 74 77 6F 72 6B 2E
00192: 6F 72 67 3B 33 37 32 34 34 31 3B 38 36 31 34 32
00208: 30 38 38 33 3B 31 36 38 3B 37 37 3B 30 3B 73 69
00224: 70 3A 2B 31 37 32 30 37 33 34 30 39 39 38 40 69
00240: 6D 73 2E 6D 6E 63 30 34 30 2E 6D 63 63 33 31 31
00256: 2E 33 67 70 70 6E 65 74 77 6F 72 6B 2E 6F 72 67
00272: A6 80 80 32 73 69 70 3A 2B 31 37 32 30 37 33 34
00288: 30 39 39 38 40 69 6D 73 2E 6D 6E 63 30 34 30 2E
00304: 6D 63 63 33 31 31 2E 33 67 70 70 6E 65 74 77 6F
00320: 72 6B 2E 6F 72 67 81 10 74 65 6C 3A 2B 31 37 32
00336: 30 37 33 34 30 39 39 38 00 00 A7 80 80 3D 73 69
00352: 70 3A 2B 31 35 32 30 34 37 39 30 39 39 39 40 69
00368: 6D 73 2E 6D 6E 63 30 34 30 2E 6D 63 63 33 31 31
00384: 2E 33 67 70 70 6E 65 74 77 6F 72 6B 2E 6F 72 67
00400: 3B 75 73 65 72 3D 70 68 6F 6E 65 00 00 89 09 20
00416: 09 08 21 39 36 2D 06 00 8B 07 14 14 09 08 15 29
00432: 24 8C 09 20 09 08 21 39 36 2D 06 00 8D 09 20 09
00448: 08 21 39 36 2D 06 00 AE 80 30 80 80 21 69 6D 73
00464: 2E 6D 6E 63 30 34 30 2E 6D 63 63 33 31 31 2E 33
00480: 67 70 70 6E 65 74 77 6F 72 6B 2E 6F 72 67 00 00
00496: 00 00 91 01 01 93 34 64 65 6E 63 6F 30 30 73 62
00512: 67 2E 69 6D 73 2E 6D 6E 63 30 34 30 2E 6D 63 63
00528: 33 31 31 2E 33 2D 31 35 39 39 2D 36 32 32 37 37
00544: 36 2D 32 30 31 39 34 2D 33 30 39 B5 80 30 80 80
00560: 09 20 09 08 21 39 36 2D 06 00 81 09 20 09 08 21
00576: 39 36 2D 06 00 86 01 5D 87 02 00 AB 00 00 00 00
00592: 97 03 34 30 33 B9 80 30 80 06 0D 04 00 7F 00 05
00608: 02 02 00 00 00 02 00 01 81 01 FF A2 80 A0 80 31
00624: 80 A0 80 0C 0F 2B 67 2E 65 72 69 63 73 73 6F 6E
00640: 2E 6D 6D 74 0C 29 75 72 6E 25 33 41 75 72 6E 2D
00656: 37 25 33 41 33 67 70 70 2D 73 65 72 76 69 63 65
00672: 2E 69 6D 73 2E 69 63 73 69 2E 6D 6D 74 65 6C 00
00688: 00 B6 80 83 01 00 87 32 73 69 70 3A 2B 31 37 32
00704: 30 37 33 34 30 39 39 38 40 69 6D 73 2E 6D 6E 63
00720: 30 34 30 2E 6D 63 63 33 31 31 2E 33 67 70 70 6E
00736: 65 74 77 6F 72 6B 2E 6F 72 67 88 01 00 8C 01 02
00752: 8E 32 73 69 70 3A 2B 31 37 32 30 37 33 34 30 39
00768: 39 38 40 69 6D 73 2E 6D 6E 63 30 34 30 2E 6D 63
00784: 63 33 31 31 2E 33 67 70 70 6E 65 74 77 6F 72 6B
00800: 2E 6F 72 67 B3 80 30 80 81 01 00 82 02 0A F0 00
00816: 00 00 00 00 00 00 00 00 00 89 01 01 00 00 00 00
00832: 00 00 9D 35 33 47 50 50 2D 45 2D 55 54 52 41 4E
00848: 2D 46 44 44 3B 75 74 72 61 6E 2D 63 65 6C 6C 2D
00864: 69 64 2D 33 67 70 70 3D 33 31 31 30 34 30 30 33
00880: 65 34 30 32 39 36 35 30 31 9E 11 31 32 2E 33 32
00896: 32 36 30 40 33 67 70 70 2E 6F 72 67 BF 1F 80 31
00912: 80 80 01 02 81 32 73 69 70 3A 2B 31 37 32 30 37
00928: 33 34 30 39 39 38 40 69 6D 73 2E 6D 6E 63 30 34
00944: 30 2E 6D 63 63 33 31 31 2E 33 67 70 70 6E 65 74
00960: 77 6F 72 6B 2E 6F 72 67 00 00 00 00 BF 65 80 80
00976: 6B 73 69 70 3A 35 32 30 34 37 39 30 39 39 39 3B
00992: 70 68 6F 6E 65 2D 63 6F 6E 74 65 78 74 3D 69 6D
01008: 73 2E 6D 6E 63 30 34 30 2E 6D 63 63 33 31 31 2E
01024: 33 67 70 70 6E 65 74 77 6F 72 6B 2E 6F 72 67 40
01040: 69 6D 73 2E 6D 6E 63 30 34 30 2E 6D 63 63 33 31
01056: 31 2E 33 67 70 70 6E 65 74 77 6F 72 6B 2E 6F 72
01072: 67 3B 75 73 65 72 3D 70 68 6F 6E 65 00 00 00 00
2020-11-11 16:41:38,361 pyasn1: tag decoded into <TagSet object at 0x7600668 tags 0:0:0>, decoding length
2020-11-11 16:41:38,361 pyasn1: value length decoded into 0, payload substrate is:
2020-11-11 16:41:38,362 pyasn1: codec
This looks very similar to #143 ?
I am using a CDR spec from asn1ate and have several CDR files from Huawei hardware I want to decode.
I have translated the spec using asn1ate and using pyasn1 from the master branch as following:
This throws an exception
Now, is it possible to fix the asn spec given the traceback? Or maybe there is an option to ignore records with unknown tags?