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

Crash on inf value in CSV #2400

Closed
vlmutolo opened this issue Aug 24, 2020 · 3 comments · Fixed by #2652
Closed

Crash on inf value in CSV #2400

vlmutolo opened this issue Aug 24, 2020 · 3 comments · Fixed by #2652

Comments

@vlmutolo
Copy link

vlmutolo commented Aug 24, 2020

Describe the bug
When the value inf is found in a CSV file, the BigDecimal From<f64> implementation crashes. I haven't finished investigating, but it seems like that crate assumes all f64s can be turned into a BigDecimal. Not sure they accounted for inf values. I was going to open a PR when I found the issue, but now I''m not sure if this is better solved in the BigDecimal crate or in nu_protocol::UntaggedValue::decimal.

To Reproduce
Steps to reproduce the behavior:

  1. Create the following CSV file. Name it bad.csv.
1,2
3,inf
  1. Start nushell (nu).
  2. Execute open bad.csv. This step should panic.

Expected behavior
I expected it to display the CSV file. It crashes instead.

Screenshots
If applicable, add screenshots to help explain your problem.

@thegedge
Copy link
Contributor

Probably the same as #2349

BigDecimal can't represent infinity 😞

@vlmutolo
Copy link
Author

Yeah, I also found that bug. Figured it was different enough (float vs int) to warrant another issue.

Good news is that there's a PR in the bigdecimal crate to at least fix the nan and inf issue. Bad news is that it doesn't look like there's been any activity since late May.

@thegedge
Copy link
Contributor

I also created akubera/bigdecimal-rs#67, but if a PR has been sitting around this long, it may not end up getting addressed. If there's no movement, I think there are some other options:

  1. find other crates that can represent infinity,
  2. build checks to verify these special conditions, or
  3. wrap these types ourselves and add the behaviour we need.

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

Successfully merging a pull request may close this issue.

2 participants