Bug 876

Summary: PV crashes when using PDv3 API decoders
Product: PulseView Reporter: Uwe Hermann <uwe>
Component: Protocol decodingAssignee: Nobody <nobody>
Status: RESOLVED FIXED    
Severity: critical CC: fesnouf, karlp
Priority: Normal    
Version: unreleased development snapshot   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Uwe Hermann 2016-12-09 20:56:32 CET
There are some regressions / crashes / issues with running PDv3 decoders in PulseView that need to be investigated.

Here's an i2c->eeprom24xx example to reproduce this.

First, let's make sure the setup survives sigrok-test:

$ LD_LIBRARY_PATH=$HOME/sr/lib ./decoder/pdtest -r -v eeprom24xx/lcsoft-mini-board-fx2-init
eeprom24xx/lcsoft-mini-board-fx2-init/annotation ........................... OK
eeprom24xx/lcsoft-mini-board-fx2-init/binary/binary ........................ OK

This works fine, also many times in a row.

Now using sigrok-cli manually:

$ LD_LIBRARY_PATH=$HOME/sr/lib ~/sr/bin/sigrok-cli -i i2c/eeprom_24xx/atmel_at24c128/lcsoft-mini-board-fx2-init.sr -P i2c:scl=SCL:sda=SDA,eeprom24xx
Control code bits: 1010
Address bit 2: 0
Address bit 1: 0
Address bit 0: 0
R/W bit: read
Control word
Warning: STOP expected (not RESTART)
Data byte 00: FF
Data
Current address read: FF
Control code bits: 1010
Address bit 2: 0
Address bit 1: 0
Address bit 0: 0
R/W bit: write
Control word
Control code bits: 1010
Address bit 2: 0
Address bit 1: 0
Address bit 0: 0
R/W bit: read
Control word
Word address byte: 00
Word address
Data byte 00: FF
Data
Random access read (addr=00, 1 byte): FF

This works fine too, also multiple times in a row.

However, using PulseView to decode the same data from the same *.sr file causes crashes.

 - Sometimes it crashes upon adding the stacked eeprom24xx PD, other times that works.

 - Sometimes there are crashes when pressing "Run" multiple times. E.g. just add the i2c PD for that *.sr file, then press Run again and again. Eventually it will crash.


The issue could be in libsigrokdecode itself, or in PulseView, or a combination of both.

The fact that sigrok-test and sigrok-cli seem to work just fine might hint at a PV problem, but it could also be that their usage simply doesn't invoke the same code paths / problems as the PV use-case does.

Some potential things to look into: PV might feed in data / memory locations that are invalid (or not valid yet); there could be some double-free, stack overflow or similar issues in both repos; there could be thread related issues (both PV and also libsigrokdecode now use threads; in libsigrokdecode, each PD stack has its own worker thread).
Comment 1 Uwe Hermann 2017-02-26 19:32:41 CET
This should be fixed in e8bb7c69bce723ed2b116598012cf85deb191ba8, thanks a lot!

There may be some additional similar issues that need to be addressed, but the bulk of it should be fixed by the commit above. Will open other bugs as necessary.
Comment 2 Uwe Hermann 2017-02-26 19:33:43 CET
(e8bb7c69bce723ed2b116598012cf85deb191ba8 in PulseView that is)
Comment 3 Uwe Hermann 2017-02-26 19:45:26 CET
*** Bug 877 has been marked as a duplicate of this bug. ***
Comment 4 Uwe Hermann 2017-03-01 10:54:06 CET
*** Bug 901 has been marked as a duplicate of this bug. ***