Stacktrace on badly formed CAN_ErrorFrame (?)
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 45/100
Piste de recherche
Commencez dans can/io/mf4.py vers la ligne 410, où CAN_ErrorFrame.DataBytes est indexé à l’aide de la valeur DataLength indiquée. Reproduisez le problème avec le fichier MF4 de Kvaser et examinez la forme et la valeur de CAN_ErrorFrame.DataBytes avant cet accès. C’est terminé lorsque can.LogReader consomme la trame d’erreur sans lever d’IndexError et que l’itération fournie fonctionne.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
We have an MF4 file from Kvaser that causes the following stack trace when run:
Traceback (most recent call last):
File "load.py", line 43, in <module>
sys.exit(main(args))
File "load.py", line 27, in main
for msg in can.LogReader(args.mf4_file):
File "/home/john/.pyenv/versions/3.8.20/lib/python3.8/heapq.py", line 373, in merge
value = next()
File "/home/john/tmp/keep_1y/python-can/can/io/mf4.py", line 410, in __iter__
kv["data"] = data["CAN_ErrorFrame.DataBytes"][i][
IndexError: invalid index to scalar variable.
The test code is essentially:
for msg in can.LogReader(mf4_file):
if msg.is_error_frame:
count["error"] += 1
else:
count["other"] += 1
I put some debug at site of the error (line 407 of can/io/mf4.py):
data_length=4
data["CAN_ErrorFrame.DataBytes"][i]=16777216
2^24?
To Reproduce
I was unable to create a file with python-can with the error data.
Expected behavior
No crash. :)
Additional context
OS and version: Linux
Python version: 3.8.20
python-can version: 654a02ae 2024-11-28 | Changelog for v4.5.0 (#1897) (HEAD -> main, origin/main, origin/HEAD)
python-can interface/s (if applicable): None
Traceback and logs
If I make this hack it consumes the error frame:
diff --git a/can/io/mf4.py b/can/io/mf4.py
index 4f5336b4..099395b4 100644
--- a/can/io/mf4.py
+++ b/can/io/mf4.py
@@ -405,9 +405,9 @@ class MF4Reader(BinaryIOMessageReader):
and "CAN_ErrorFrame.DataBytes" in names
):
data_length = int(data["CAN_ErrorFrame.DataLength"][i])
- kv["data"] = data["CAN_ErrorFrame.DataBytes"][i][
+ kv["data"] = data["CAN_ErrorFrame.DataBytes"][i].tobytes()[
:data_length
- ].tobytes()
+ ]
yield Message(**kv)
- Langage dominant
- Python
- Étoiles
- 1.6k
- Forks
- 697
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de hardbyte/python-can
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
hardbyte/python-can#2103 ·
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
hardbyte/python-can#2077 · 1 commentaire · 1 réaction ·
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
hardbyte/python-can#1922 · 1 réaction ·
-
enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
hardbyte/python-can#2102 ·
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
hardbyte/python-can#2092 ·
Toutes les issues de hardbyte/python-can
Issues similaires
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Ouvertearea: harness bug status: needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Human-Agent-Society/reef#625 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 80/100
learningequality/kolibri#15351 · 2 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Name consistency Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
eellak/triplestore#65 · 1 commentaire ·