Bug 1306 - Incorrect reset of input device vcd
Summary: Incorrect reset of input device vcd
Status: RESOLVED FIXED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: Input: vcd (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-12 10:14 CEST by stegu13
Modified: 2018-10-13 15:28 CEST (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stegu13 2018-10-12 10:14:26 CEST
I tried to use Pulseview functionality of pressing on RUN button to reload input file *.vcd.

> sigrok-cli -d demo --config samplerate=20k --channels D1,D2,D3 --samples 20k -O vcd -o sample.vcd
> pulseview -i sample.vcd -I vcd:downsample=200 -D


1. problem, reported through dbg messages: 
sr: input/vcd: Invalid timestamp: 5977920 (smaller than previous timestamp)

FIX: fixed by adding a line to input/vcd.c
in function reset():
inc->prev_timestamp = 0;

2. problem, segmentation fault when dereferencing vcd_ch
in function free_channel()

FIX:
if (vcd_ch) {
	g_free(vcd_ch->name);
	g_free(vcd_ch->identifier);
	g_free(vcd_ch);
}

3. segmentation fault:

pv::devices::InputFile::run (this=0x555555f84010)
    at /home/luftek/sw/pulseview/pv/devices/inputfile.cpp:172
172		vector<char> buffer(BufferSize);
(gdb) 
174		interrupt_ = false;
(gdb) 
172		vector<char> buffer(BufferSize);
(gdb) 
174		interrupt_ = false;
(gdb) 
175		while (!interrupt_ && !f->eof()) {
(gdb) 
176			f->read(buffer.data(), BufferSize);
(gdb) 
177			const streamsize size = f->gcount();
(gdb) 
178			if (size == 0)
(gdb) 
181			input_->send(buffer.data(), size);
(gdb) 

Thread 8 "pulseview" received signal SIGSEGV, Segmentation fault.
0x00007ffff694adfe in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
(gdb)
Comment 1 Gerhard Sittig 2018-10-12 12:14:09 CEST
Could reproduce the issue here, and got a local change to improve the 
robustness of the .reset() (and .cleanup()) routines.

An issue remains, that Pulseview doesn't like the input module's (or 
acquisition device driver's) changing or re-building the channel list. 
This is discussed in bug 1215 and bug 1241.

When the .reset/.cleanup improvements went mainline, this report here can 
get closed as a duplicate of the above items.
Comment 2 stegu13 2018-10-12 15:01:14 CEST
Thank you for referencing other bug reports. I thought it had to do only with *.vcd
Comment 3 Uwe Hermann 2018-10-13 15:28:34 CEST
Fixed in 4237ab9e5ba85153b632b43b7eb2411530e11df8 and 08f8421a9e82fec8bb2fa4e561fea8cb468abcca for vcd, thanks!