Bug 695 - CSV import seems to hang indefinitely
Summary: CSV import seems to hang indefinitely
Status: RESOLVED FIXED
Alias: None
Product: sigrok-cli
Classification: Unclassified
Component: Other (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-04 15:50 CET by leonerd
Modified: 2017-06-08 23:42 CEST (History)
2 users (show)



Attachments
CSV that hangs sigrok-cli (336.31 KB, text/csv)
2015-11-04 15:50 CET, leonerd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description leonerd 2015-11-04 15:50:59 CET
Created attachment 181 [details]
CSV that hangs sigrok-cli

A trivial one-line case works:

$ cat onesample.csv 
1,1,0,0

$ sigrok-cli -i onesample.csv -I csv:samplerate=2000000 -o onesample.sr

$ ls -l onesample.*
-rw-r--r-- 1 leo leo   8 Nov  4 14:38 onesample.csv
-rw-r--r-- 1 leo leo 428 Nov  4 14:47 onesample.sr


I have a larger dump file that doesn't work so well. It is of the same format, but much longer. Its behaviour is that sigrok-cli seems to get stuck in a loop, never finishing. It has created a file, but watching it on strace it seems to be doing something to it over and over again, never finishing.

$ sigrok-cli -i max7221-part0.csv -I csv:samplerate=2000000 -o max7221-part0.sr
[never finishes; spins CPU]

Attached is my actual .csv file.

Versions:
  libsigrok-0.2.1-1878-gee95d6b
  sigrok-cli-0.5.0-100-g1ef118a
Comment 1 leonerd 2015-11-04 15:55:02 CET
The patch in http://sigrok.org/bugzilla/show_bug.cgi?id=635 doesn't seem to help here.
Comment 2 Gerhard Sittig 2017-06-05 18:09:44 CEST
A recent commit fixed an out-of-bounds access to an array, which could have 
corrupted memory and resulted in unpredictable behaviour.  Does the issue 
still reproduce for you?  Current mainline works here for the attached file.
Comment 3 leonerd 2017-06-05 18:55:52 CEST
Ah tricky. I don't appear to have the original CSV file referred in the bug any more, so I can't retest it. In any case I haven't had to import CSV files for a while now, so even if this bug still remains, it doesn't seem to be impacting me at the moment.

Thanks.
Comment 4 leonerd 2017-06-05 19:08:53 CEST
(In reply to comment #3)
> Ah tricky. I don't appear to have the original CSV file referred in the bug
> any more, so I can't retest it.

Oops. Of course, I attached it to the original bug report in order to avoid precisely this problem. Thanks past me :)

Having rerun it it does seem to still be spinning though. I've left it a good 2 minutes now on a 2.4GHz Intel i5 machine, chewing on the original file which was 43 thousand lines long. So unless it's operating at a momentously slow rate of under 400 samples/sec and will eventually succeed, I think it's still hung.
Comment 5 Uwe Hermann 2017-06-07 00:35:30 CEST
A few quick tests suggest that the CSV loading itself is fast enough (both sigrok-cli and PulseView), but it's loading at a chunksize of 1.

It's *saving* that data to .sr which is *very* slow.

The srzip output module will need some chunking-up support for such cases, to force a minimum chunk size for performance reasons.
Comment 6 Uwe Hermann 2017-06-08 23:42:08 CEST
Fixed in cd59e6eca13632f8fc749a63fb8ccbadbb77e21b, thanks!

This makes the csv import a lot faster. A new bug for similarly fixing srzip is open as #974.