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

InexactError: trunc(Int64, NaN) #705

Closed
omus opened this issue Jul 31, 2020 · 4 comments
Closed

InexactError: trunc(Int64, NaN) #705

omus opened this issue Jul 31, 2020 · 4 comments

Comments

@omus
Copy link
Member

omus commented Jul 31, 2020

Issue when running tests on the latest master (da0967a)

CSV.File basics: Error During Test at /Users/omus/.julia/dev/CSV/test/basics.jl:18
  Got exception outside of a @test
  InexactError: trunc(Int64, NaN)
  Stacktrace:
   [1] trunc at ./float.jl:702 [inlined]
   [2] ceil at ./float.jl:365 [inlined]
   [3] multithreadparse(::Array{Type,1}, ::Array{UInt8,1}, ::Array{UInt8,1}, ::Int64, ::Int64, ::Parsers.Options{false,false,true,false,Missing,UInt8,Nothing}, ::Nothing, ::Int64, ::Int64, ::Float64, ::Array{CSV.RefPool,1}, ::Int64, ::Dict{Type,Type}, ::Bool, ::Type, ::Int64, ::Int64, ::Bool) at /Users/omus/.julia/dev/CSV/src/file.jl:419
   [4] #File#27(::Nothing, ::Nothing, ::Int64, ::Bool, ::Dict{Type,Type}, ::Int64, ::Bool, ::Type{CSV.File}, ::CSV.Header{false,Parsers.Options{false,false,true,false,Missing,UInt8,Nothing},Array{UInt8,1}}) at /Users/omus/.julia/dev/CSV/src/file.jl:255
   [5] (::Core.var"#kw#Type")(::NamedTuple{(:debug, :typemap, :limit, :threaded),Tuple{Bool,Dict{Type,Type},Int64,Bool}}, ::Type{CSV.File}, ::CSV.Header{false,Parsers.Options{false,false,true,false,Missing,UInt8,Nothing},Array{UInt8,1}}) at ./none:0
   [6] #File#26(::Int64, ::Bool, ::Int64, ::Nothing, ::Int64, ::Bool, ::Nothing, ::Nothing, ::Bool, ::Nothing, ::Nothing, ::Array{String,1}, ::String, ::Nothing, ::Bool, ::Char, ::Nothing, ::Nothing, ::Char, ::Nothing, ::Nothing, ::UInt8, ::Array{String,1}, ::Array{String,1}, ::Nothing, ::Nothing, ::Dict{Type,Type}, ::Nothing, ::Float64, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Base.Iterators.Pairs{Symbol,Integer,Tuple{Symbol,Symbol},NamedTuple{(:limit, :threaded),Tuple{Int64,Bool}}}, ::Type{CSV.File}, ::String) at /Users/omus/.julia/dev/CSV/src/file.jl:217
   [7] (::Core.var"#kw#Type")(::NamedTuple{(:limit, :threaded),Tuple{Int64,Bool}}, ::Type{CSV.File}, ::String) at ./none:0
   [8] top-level scope at /Users/omus/.julia/dev/CSV/test/basics.jl:440
   [9] top-level scope at /Users/omus/Development/Julia/1.3/usr/share/julia/stdlib/v1.3/Test/src/Test.jl:1107
   [10] top-level scope at /Users/omus/.julia/dev/CSV/test/basics.jl:21
   [11] include at ./boot.jl:328 [inlined]
   [12] include_relative(::Module, ::String) at ./loading.jl:1105
   [13] include(::Module, ::String) at ./Base.jl:31
   [14] include(::String) at ./client.jl:424
   [15] top-level scope at /Users/omus/.julia/dev/CSV/test/runtests.jl:17
   [16] top-level scope at /Users/omus/Development/Julia/1.3/usr/share/julia/stdlib/v1.3/Test/src/Test.jl:1107
   [17] top-level scope at /Users/omus/.julia/dev/CSV/test/runtests.jl:17
   [18] top-level scope at /Users/omus/Development/Julia/1.3/usr/share/julia/stdlib/v1.3/Test/src/Test.jl:1107
   [19] top-level scope at /Users/omus/.julia/dev/CSV/test/runtests.jl:15
   [20] include at ./boot.jl:328 [inlined]
   [21] include_relative(::Module, ::String) at ./loading.jl:1105
   [22] include(::Module, ::String) at ./Base.jl:31
   [23] include(::String) at ./client.jl:424
   [24] top-level scope at none:6
   [25] eval(::Module, ::Any) at ./boot.jl:330
   [26] exec_options(::Base.JLOptions) at ./client.jl:263
   [27] _start() at ./client.jl:460
@omus
Copy link
Member Author

omus commented Jul 31, 2020

Seems to only happen locally and not on the CI

@omus
Copy link
Member Author

omus commented Jul 31, 2020

A more minimal reproduction. Occurs on macOS 10.14.6 on Julia 1.3.1, 1.4.2, and 1.5.0-rc2 with CSV.jl 0.7.2 onwards:

julia> using CSV

julia> CSV.File(joinpath("test", "testfiles", "promotions.csv"); threaded=true)
ERROR: InexactError: trunc(Int64, NaN)
Stacktrace:
 [1] trunc at ./float.jl:703 [inlined]
 [2] ceil at ./float.jl:365 [inlined]
 [3] multithreadparse(::Array{Type,1}, ::Array{UInt8,1}, ::Array{UInt8,1}, ::Int64, ::Int64, ::Parsers.Options{false,false,true,false,Missing,UInt8,Nothing}, ::Nothing, ::Int64, ::Int64, ::Float64, ::Array{CSV.RefPool,1}, ::Int64, ::Dict{Type,Type}, ::Bool, ::Type, ::Nothing, ::Int64, ::Bool) at /Users/omus/.julia/dev/CSV/src/file.jl:419
 [4] CSV.File(::CSV.Header{false,Parsers.Options{false,false,true,false,Missing,UInt8,Nothing},Array{UInt8,1}}; startingbyteposition::Nothing, endingbyteposition::Nothing, limit::Nothing, threaded::Bool, typemap::Dict{Type,Type}, tasks::Int64, debug::Bool) at /Users/omus/.julia/dev/CSV/src/file.jl:255
 [5] CSV.File(::String; header::Int64, normalizenames::Bool, datarow::Int64, skipto::Nothing, footerskip::Int64, transpose::Bool, comment::Nothing, use_mmap::Nothing, ignoreemptylines::Bool, select::Nothing, drop::Nothing, missingstrings::Array{String,1}, missingstring::String, delim::Nothing, ignorerepeated::Bool, quotechar::Char, openquotechar::Nothing, closequotechar::Nothing, escapechar::Char, dateformat::Nothing, dateformats::Nothing, decimal::UInt8, truestrings::Array{String,1}, falsestrings::Array{String,1}, type::Nothing, types::Nothing, typemap::Dict{Type,Type}, categorical::Nothing, pool::Float64, lazystrings::Bool, strict::Bool, silencewarnings::Bool, debug::Bool, parsingdebug::Bool, kw::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:threaded,),Tuple{Bool}}}) at /Users/omus/.julia/dev/CSV/src/file.jl:217
 [6] top-level scope at REPL[2]:1

@quinnj
Copy link
Member

quinnj commented Jul 31, 2020

Can you share how many threads you're running julia with? CI runs w/ 2 by default, so it seems like it might depend on # of threads. (this is adjustable by passing tasks=N as well)

@omus
Copy link
Member Author

omus commented Jul 31, 2020

The failure only occurs when nthreads is 1. I tried with 2 and 4 and no error occurred.

quinnj added a commit that referenced this issue Aug 1, 2020
The issue here is that a user can pass `threaded=true`, which means
we'll do parsing across `tasks` chunks of a file in parallel, which
causes this error when the number of tasks happens to be 1. This could
be the user passing `tasks=1` manually, in which case they should not
do, or it defaulted to `Threads.nthreads()` and the user's Julia session
started with only 1 thread.

We already do a few other hard-checks for multithreaded parsing, like
ensuring your Julia version is > 1.3, so the fix is pretty simple: if a
user passes `threaded=true`, then we'll also require the `tasks`
parameter to be `> 1`. Fixes #705
@quinnj quinnj closed this as completed in b3f7292 Aug 1, 2020
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

2 participants