Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic while reading csv file with more than 300 empty records #89

Closed
sid-habu opened this issue Nov 5, 2022 · 7 comments
Closed

Panic while reading csv file with more than 300 empty records #89

sid-habu opened this issue Nov 5, 2022 · 7 comments

Comments

@sid-habu
Copy link

sid-habu commented Nov 5, 2022

We stumbled upon a use case where a csv file had more than 300 empty rows—doing any operation on the file results in a panic due to divbyzero

Version v1.17.10

Sample File that fails

empty.csv

Sample Query that fails

csvq "select h1 from empty"
panic: runtime error: makeslice: cap out of range

goroutine 35 [running]:
github.com/mithrandie/csvq/lib/query.readRecordSet.func1()
	github.com/mithrandie/csvq/lib/query/load_view.go:1233 +0x12c
created by github.com/mithrandie/csvq/lib/query.readRecordSet
	github.com/mithrandie/csvq/lib/query/load_view.go:1216 +0x17c

We also use this library in an app server and the panic in the load_view.go:1233 goroutine crashes our server as it can't be recovered in the parent goroutine.

As a stop-gap solution, we are patching the library with this fix in our fork https://github.com/deklareddotcom/habu-csvq/pull/1

What are your thoughts on the bug? Please let me know if you have any better suggestions in fixing it - I can help in contributing back

@ondohotola
Copy link

ondohotola commented Nov 5, 2022 via email

@sid-habu
Copy link
Author

sid-habu commented Nov 5, 2022

@ondohotola Thank you for the suggestion. That surely works for the CLI. However, in our app we use the csvq-driver https://github.com/mithrandie/csvq-driver that internally uses csvq as a lib

mithrandie added a commit that referenced this issue Nov 5, 2022
- Prevent divide-by-zero error while loading csv files. ([GitHub #89](#89))
- Handle panics during processor executions.
@mithrandie
Copy link
Owner

This bug has been fixed in version 1.17.11.

@derekmahar
Copy link
Contributor

In the meantime one can get qsv and do qsv dedup empty.csv | csvq “select * from stdin”

Where can I find qsv?

@derekmahar
Copy link
Contributor

In the meantime one can get qsv and do qsv dedup empty.csv | csvq “select * from stdin”

Where can I find qsv?

I found qsv.

@ondohotola
Copy link

ondohotola commented Nov 5, 2022 via email

@sid-habu
Copy link
Author

sid-habu commented Nov 5, 2022

@mithrandie That was quick, thank so you much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants