Bug 1663 - Protocol decoder terminates PV with message "Caught exception of type St12out_of_range (map::at)"
Summary: Protocol decoder terminates PV with message "Caught exception of type St12out...
Status: RESOLVED FIXED
Alias: None
Product: PulseView
Classification: Unclassified
Component: Data display (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-13 13:19 CET by Ralf
Modified: 2022-09-18 22:31 CEST (History)
1 user (show)



Attachments
Evil protocol decoder (1.26 KB, application/gzip)
2021-02-13 13:19 CET, Ralf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf 2021-02-13 13:19:50 CET
Created attachment 722 [details]
Evil protocol decoder

If a protocol decoder uses an annotation id, that is not assigned to any annotation row, PV crashes with the error message
"Caught exception of type St12out_of_range (map::at)"

How to reproduce
1. Install attached protocol decoder evil_pd or have SIGROKDECODE_DIR point to it
2. Start PV with demo device
3. Add protocol decoder evil_pd and assign any logic channel to "in (input)"
4. Capture some data
5. Zoom in

If you remove the comment ('#') from line 48 in pd.py, PV runs fine.

I can reproduce the crash with current nightly build PulseView-NIGHTLY-x86_64.AppImage.

I am unsure, whether this is a libsigrokdecode or PV bug.
sigrok-cli works fine with that decoder.
Comment 1 Soeren Apel 2021-02-13 13:33:17 CET
Hello Ralf, thanks for your report.

A crash in PV is never good and I'll fix this of course. However, that's a bug in the offending protocol decoder, as annotation classes must be assigned to a row. Otherwise, it is unclear which row shall receive such annotations.
Comment 2 Ralf 2021-02-13 15:55:35 CET
Hello Soeren,

Thanks for looking into this.
I agree, that the PD behaves badly, but would prefer a proper error message.

OTOH if it is required to have all annotation ids assigned to an annotation row, shouldn't it be enforced by libsigrokdecode, so that all applications benefit from it?
If I can help with testing or by looking into libsigrokdecode, please let me know.
Comment 3 Soeren Apel 2021-02-13 16:51:47 CET
I assume a strict enforcement wasn't intended or else Uwe would've added it, I'm sure. So maybe there's some reasoning there that I'm not aware of.

As for PV, I'll have annotations without rows placed into a catch-all row named "UNASSIGNED" or such. That way, the annotations will appear but users will see that something's not quite right. Would that work for you?
Comment 4 Ralf 2021-02-13 17:02:16 CET
That would be perfectly fine for me.
It does not crash and gives a hint where to look.
Comment 5 Soeren Apel 2022-09-18 22:31:46 CEST
Fixed in eb31c238473de0784ec57b9782e11082613a7a7a