Debugger.jl + CSV.jl => crash

How to fix the following crash:

using Debugger
using CSV

function csv1()
    fPath = joinpath(@__DIR__, "test1.csv");
    @assert isfile(fPath)
    csvFile = CSV.File(fPath, header = true, delim = '\t');

    @bp

    return nothing
end

julia> csv1() # this works fine

@run csv1() # this crashes, but only with tab delimiter
ERROR: type UnionAll has no field hasfreetypevars
Stacktrace:
 [1] parsepooled!(::Int8, ::Array{UInt64,1}, ::Array{UInt8,1}, ::Int64, ::Int64, ::Parsers.Options{false,true,false,Missing,UInt8,Nothing}, ::Int64, ::Int64, ::Int64, ::Float64, ::Array{Dict{String,UInt64},1}, ::Array{UInt64,1}, ::Array{Int8,1}, ::Bool, ::Array{Array{UInt64,1},1}) at /Users/lutz/.julia/packages/CSV/1IQPk/src/CSV.jl:1057
 [2] parsetape(::Val{false}, ::Bool, ::Int64, ::Dict{Int8,Int8}, ::Array{Array{UInt64,1},1}, ::Array{Array{UInt64,1},1}, ::Array{UInt8,1}, ::Int64, ::Int64, ::Int64, ::Nothing, ::Array{Int64,1}, ::Float64, ::Array{Dict{String,UInt64},1}, ::Array{UInt64,1}, ::Int64, ::Array{Int8,1}, ::Array{Int64,1}, ::Bool, ::Parsers.Options{false,true,false,Missing,UInt8,Nothing}, ::Bool) at /Users/lutz/.julia/packages/CSV/1IQPk/src/CSV.jl:686
 [3] file(::String, ::Bool, ::Bool, ::Int64, ::Nothing, ::Int64, ::Int64, ::Bool, ::Nothing, ::Bool, ::Bool, ::Array{String,1}, ::String, ::Char, ::Bool, ::Char, ::Nothing, ::Nothing, ::Char, ::Nothing, ::UInt8, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Dict{Int8,Int8}, ::Bool, ::Float64, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::Nothing) at /Users/lutz/.julia/packages/CSV/1IQPk/src/CSV.jl:454
 [4] #File#15(::Bool, ::Bool, ::Int64, ::Nothing, ::Int64, ::Int64, ::Bool, ::Nothing, ::Bool, ::Bool, ::Array{String,1}, ::String, ::Char, ::Bool, ::Char, ::Nothing, ::Nothing, ::Char, ::Nothing, ::UInt8, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Dict{Int8,Int8}, ::Bool, ::Float64, ::Bool, ::Bool, ::Nothing, ::Bool, ::Bool, ::Nothing, ::UnionAll, ::String) at /Users/lutz/.julia/packages/CSV/1IQPk/src/CSV.jl:260
 [5] (::Core.var"#kw#Type")(::NamedTuple{(:header, :delim),Tuple{Bool,Char}}, ::UnionAll, ::String) at none:0
 [6] csv1() at /Users/lutz/Documents/projects/p2019/college_stratification/CollegeStrat/src/AA.jl:11

This is using Julia 1.3 and Debugger 0.6.2 and CSV 0.5.22.

Thanks!

1 Like

Following up, the problem has nothing to do with CSV.jl. It appears that a breakpoint not inside an if clause causes an error. MWE:

julia> function foo()
           x = "abc"
           @bp
           println(x)
       end
foo (generic function with 1 method)

julia> function bar()
           x = "abc"
           if length(x) > 1
               @bp
           end
           println(x)
       end
bar (generic function with 1 method)

julia> bar()
abc

julia> foo()
abc

julia> @enter bar()
In bar() at REPL[22]:2
 1  function bar()
 2      x = "abc"
>3      if length(x) > 1
●4          @bp
 5      end
 6      println(x)
 7  end

About to run: (length)("abc")
1|debug> c
Hit breakpoint:
In bar() at REPL[22]:2
 2      x = "abc"
 3      if length(x) > 1
●4          @bp
 5      end
>6      println(x)
 7  end

About to run: (println)("abc")
1|debug> c
abc

julia> @enter foo()
ERROR: AssertionError: expr !== nothing
Stacktrace:
 [1] print_next_expr(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JuliaInterpreter.Frame) at /Users/lutz/.julia/packages/Debugger/XqeyI/src/printing.jl:76
 [2] #print_status#41(::Bool, ::typeof(Debugger.print_status), ::Base.TTY, ::JuliaInterpreter.Frame) at /Users/lutz/.julia/packages/Debugger/XqeyI/src/printing.jl:140
 [3] (::Debugger.var"#kw##print_status")(::NamedTuple{(:force_lowered,),Tuple{Bool}}, ::typeof(Debugger.print_status), ::Base.TTY, ::JuliaInterpreter.Frame) at ./none:0
 [4] #RunDebugger#7(::Bool, ::typeof(Debugger.RunDebugger), ::JuliaInterpreter.Frame, ::Nothing, ::Nothing) at /Users/lutz/.julia/packages/Debugger/XqeyI/src/repl.jl:154
 [5] RunDebugger at /Users/lutz/.julia/packages/Debugger/XqeyI/src/repl.jl:4 [inlined] (repeats 2 times)
 [6] top-level scope at /Users/lutz/.julia/packages/Debugger/XqeyI/src/Debugger.jl:108

What might be going on here? Thanks.

I believe that the original problem is indeed with CSV.read(). I had the same problem, and when I use CSVFiles instead of CSV to read the file, it went away. I am using Juno. I define the functions in a file, and run the file code in Juno:

""" debug_test.jl """
using CSV
using CSVFiles
using DataFrames

function csvfiles_read_df()
    df = DataFrame(Name = ["Jon","Bill"], 
                     Age = [22,43]
                     )
    CSV.write("test_df.csv", df)
    reloaded_df = DataFrame(load("test_df.csv"))  # load() comes from CSVFiles
    println("$(reloaded_df[2,:Name]) is $(reloaded_df[2,:Age]) years old")
end

function csv_read_df()
    df = DataFrame(Name = ["Jon","Bill"], 
                     Age = [22,43]
                     )
    CSV.write("test_df.csv", df)
    reloaded_df = CSV.read("test_df.csv")
    println("$(reloaded_df[2,:Name]) is $(reloaded_df[2,:Age]) years old")
end

I set a breakpoint in the IDE at the top of each function, and step through line-by-line. When I do:

Juno.@run csvfiles_read_df()

I get no problem, but step through after:

Juno.@run csv_read_df()

I get:

ERROR: type UnionAll has no field hasfreetypevars

I’m using JuliaPro 1.3.1 on MacOS 10.15.3, CSV v0.5.26, and CSVFiles v1.0.0. I have not tried tab-delimited.

However I don’t find the debugger very usable. For starters, loading 4 csv files at the top of my script, mostly under 1 kb and the largest being 40kb, takes me 77 seconds. And I can’t inspect variables.

Thank you for that follow-up. It seems that we have two unrelated problems here.

The CSVFiles tip is useful.