Skip to content

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

@sid-habu

Description

@sid-habu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions