Atom StackOverFlowError


#1

I get the following error in Atom (using julia 0.5.2 and the latest uber-juno and Atom versions), such that I cannot do anything non-basic (anything except arithmetic, almost) in Atom
Sorry, the error message is super long, so i have to cut it

StackOverflowError:
 in resize!(::Array{UInt8,1}, ::UInt64) at array.jl:512
 in ensureroom at iobuffer.jl:194 [inlined]
 in unsafe_write(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Ptr{UInt8}, ::UInt64) at iobuffer.jl:275
 in write(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Array{UInt8,1}) at io.jl:175
 in print(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::String) at io.jl:70
 in #print_to_string#317(::Void, ::Function, ::String, ::Vararg{Any,N}) at io.jl:61
 in print_to_string(::String, ::Vararg{Any,N}) at io.jl:50
 in string(::String, ::String, ::Vararg{Any,N}) at io.jl:68
 in joinpath(::String, ::String) at path.jl:84
 in map!(::CodeTools.##11#13{String}, ::Array{String,1}, ::Array{String,1}) at abstractarray.jl:1685
 in dirs(::String) at module.jl:21
 in #dirsnearby#16(::Int64, ::Int64, ::Set{String}, ::Function, ::String) at module.jl:41
 in (::CodeTools.#kw##dirsnearby)(::Array{Any,1}, ::CodeTools.#dirsnearby, ::String) at <missing>:0
 in #dirsnearby#16(::Int64, ::Int64, ::Set{String}, ::Function, ::String) at module.jl:48
 in find_include(::String) at module.jl:142
 in filemodule_(::String) at module.jl:153
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]
 in filemodule_(::String) at module.jl:157
 in get!(::CodeTools.##2#4{Tuple{String},CodeTools.#filemodule_}, ::Dict{Any,Any}, ::Tuple{String}) at dict.jl:672
 in macro expansion at dict.jl:690 [inlined]
 in #1 at utils.jl:5 [inlined]

#2

It seems you’re working in a file with “looped” includes (or at least CodeTools thinks they are). Can you share the code you were working on at the time?


#3

The strange thing is that I don’t actually run any file at all

I have several tabs open and its true, one of the tabs might actually contain “looped” includes (its code that loads al my dependencies/includes for the entire project)

I run 2+2 in the console, which returns 4 and as soon as I just click into the file editor Atom starts being busy and then delivers this error (after some time)

Even though I did not even run any file at all!

Does CodeTools fail if I click into the code of a file with “looped” includes even though I don’t run it?


#4

Yes – we’re trying to detect which module the opened file belongs to by looking for include statements in your code.
This should definitely be fixed in CodeTools, but you might still want to fix your include statements (is what you have actually valid code?).


#5

Crazily, even after I uncomment the entire file, I still have the same problem
So there is no code actually

Here is the code anyways, before being uncommented:
(it defines all my modules and dependencies [this might have “loops” without me realising], where each dependency only [should] contains import and using and defines a function R() that re-includes modified files)

# using statements for Main module, useful for dev
using MySQL,DataFrames

# prepare sources
MODULE = Dict{String,Dict{Symbol,Any}}()
# MODULE["html"] = Dict(:source => "utils/html.jl")
MODULE["optim_NM"] = Dict(:source => "maths/optim_NM.jl")
MODULE["optim"] = Dict(:source => "maths/optim.jl")
MODULE["db"] = Dict(:source => "data/code/db/db.jl")
MODULE["zmq"] = Dict(:source => "utils/zmq.jl")
# MODULE["tws"] = Dict(:source => "utils/tws.jl")
MODULE["log"] = Dict(:source => "utils/log.jl")
MODULE["io"] = Dict(:source => "utils/io.jl")
MODULE["params"] = Dict(:source => "utils/params.jl")
MODULE["config"] = Dict(:source => "utils/config.jl")
MODULE["table"] = Dict(:source => "utils/table.jl")
MODULE["general"] = Dict(:source => "utils/general.jl")
MODULE["dates"] = Dict(:source => "utils/dates.jl")
MODULE["csi"] = Dict(:source => "utils/csi.jl")
MODULE["stats"] = Dict(:source => "maths/stats.jl")
MODULE["mv_allocation"] = Dict(:source => "maths/mvallocation.jl")
MODULE["market_params"] = Dict(:source => "data/code/marketparams.jl")
MODULE["data"] = Dict(:source => "data/code/main.jl")
MODULE["data_raw"] = Dict(:source => "data/code/raw.jl")
MODULE["data_backadj"] = Dict(:source => "data/code/backadj.jl")
MODULE["trading_general"] = Dict(:source => "trading/general.jl")
MODULE["summary"] = Dict(:source => "utils/summary.jl")
MODULE["mom_general"] = Dict(:source => "strategies/trend/general.jl")
MODULE["mom"] = Dict(:source => "strategies/trend/run.jl")
MODULE["vol_data"] = Dict(:source => "strategies/volatility/create_data.jl")
MODULE["vol_slope"] = Dict(:source => "strategies/volatility/slope.jl")
MODULE["vol_curvature"] = Dict(:source => "strategies/volatility/curvature.jl")
MODULE["vol"] = Dict(:source => "strategies/volatility/run.jl")
MODULE["pr"] = Dict(:source => "strategies/pattern_recognition/run.jl")
# MODULE["executor"] = Dict(:source => "trading/executor.jl")
# MODULE["op_positions"] = Dict(:source => "operations/positions.jl")
# bb_dir = "/home/imran/trading/bb"
bb_dir = "/Users/imran/trading/bb"
# bb_dir = "/Users/imrankim/Google Drive/Trading/bb"
# bb_dir = pwd()
map(k-> MODULE[k][:source] = joinpath(bb_dir,MODULE[k][:source]) ,keys(MODULE))
map(k-> MODULE[k][:dep] = [] ,keys(MODULE))

# define dependencies
# MODULE["tws"][:dep] = ["zmq"]
MODULE["optim"][:dep] = ["optim_NM"]
MODULE["stats"][:dep] = ["general"]
MODULE["table"][:dep] = ["stats"]
MODULE["params"][:dep] = ["db"]
MODULE["config"][:dep] = ["db"]
# MODULE["executor"][:dep] = ["config"]
MODULE["log"][:dep] = ["db"]
MODULE["dates"][:dep] = ["general"]
MODULE["csi"][:dep] = ["dates","table"]
MODULE["market_params"][:dep] = ["io","db","general","table","dates"]
# MODULE["op_positions"][:dep] = ["zmq","db","market_params","tws","dates"]
MODULE["data"][:dep] = ["market_params","io","general","table","db","stats"]
MODULE["data_raw"][:dep] = ["market_params","data","db","config","table","dates","csi","io","general"]
MODULE["data_backadj"][:dep] = ["market_params","data","data_raw","general","table","dates","io","stats"]
MODULE["trading_general"][:dep] = ["table","general","params","data","db"]
MODULE["summary"][:dep] = ["table","db","data","params","general","stats"]
MODULE["mom_general"][:dep] = ["market_params","data","table","general","stats","mv_allocation"]
MODULE["mom"][:dep] = ["data_raw","data_backadj","io","mom_general","params","stats","data","trading_general","market_params","db"]
MODULE["vol_data"][:dep] = ["market_params","table","data","general","stats"]
MODULE["vol_slope"][:dep] = ["table","general"]
MODULE["vol"][:dep] = ["table","stats","mv_allocation","vol_data","general","trading_general","vol_slope","vol_curvature"]
MODULE["pr"][:dep] = ["table","stats","mv_allocation","data","market_params","trading_general","dates","summary"]

function include_deep(n)
 haskey(MODULE[n],:module) && return
 map(include_deep,MODULE[n][:dep])
 try
  info("Loading $n")
  MODULE[n][:module] = "$(include(MODULE[n][:source]))"
 catch e
  error("error loading $(MODULE[n][:source]): $e")
 end
 MODULE[n][:last_modified_time] = stat(MODULE[n][:source]).mtime
end
info("Loading all modules")
map(include_deep,keys(MODULE))
info("Loading all modules...DONE")

function R(n)
 # reload(MODULE[n][:module])
 include(MODULE[n][:source])
 MODULE[n][:last_modified_time] = stat(MODULE[n][:source]).mtime
 for k in keys(MODULE)
  (n ∈ MODULE[k][:dep]) && R(k)
 end
end
modified_keys = filter(k-> MODULE[k][:last_modified_time] < stat(MODULE[k][:source]).mtime ,keys(MODULE))
R() = map(R,modified_keys)
R_ALL() = map(R,keys(MODULE))

#6

Atom is working again for me since a recent update (several Atom packages, ink and two more)